Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to pass arguments to shell commands #375

Closed
cbandy opened this issue Feb 23, 2019 · 5 comments
Closed

Unable to pass arguments to shell commands #375

cbandy opened this issue Feb 23, 2019 · 5 comments

Comments

@cbandy
Copy link

cbandy commented Feb 23, 2019

Steps to reproduce

$ gem install dotenv
Fetching: dotenv-2.7.0.gem (100%)
Successfully installed dotenv-2.7.0
1 gem installed

$ echo --color
--color

$ dotenv echo --color
Traceback (most recent call last):
	4: from /home/dev/.gem/ruby/2.5.0/bin/dotenv:23:in `<main>'
	3: from /home/dev/.gem/ruby/2.5.0/bin/dotenv:23:in `load'
	2: from /home/dev/.gem/ruby/2.5.0/gems/dotenv-2.7.0/bin/dotenv:4:in `<top (required)>'
	1: from /home/dev/.gem/ruby/2.5.0/gems/dotenv-2.7.0/lib/dotenv/cli.rb:16:in `run'
/home/dev/.gem/ruby/2.5.0/gems/dotenv-2.7.0/lib/dotenv/cli.rb:36:in `parse_argv!': invalid option: --color (OptionParser::InvalidOption)

Expected behavior

I expect to be able to pass arguments to commands prefixed by dotenv.

Actual behavior

Arguments appear to go to dotenv.

System configuration

dotenv version: 2.7.0

Rails version: n/a

Ruby version: 2.5.1

@drews256
Copy link

I'm seeing the same thing as above.

➜  myproj git:(49.0.0.rc2) ✗ gem install dotenv
Fetching: dotenv-2.7.0.gem (100%)
Successfully installed dotenv-2.7.0
Parsing documentation for dotenv-2.7.0
Installing ri documentation for dotenv-2.7.0
Done installing documentation for dotenv after 0 seconds
1 gem installed
➜  myproj git:(49.0.0.rc2) ✗ ~/.rbenv/shims/dotenv ~/.rbenv/shims/bundle install --without development:test:staging
/home/andrew-stuntz/.gems/gems/dotenv-2.7.0/lib/dotenv/cli.rb:36:in `parse_argv!': invalid option: --without (OptionParser::InvalidOption)
        from /home/andrew-stuntz/.gems/gems/dotenv-2.7.0/lib/dotenv/cli.rb:16:in `run'
        from /home/andrew-stuntz/.gems/gems/dotenv-2.7.0/bin/dotenv:4:in `<top (required)>'
        from /home/andrew-stuntz/.gems/bin/dotenv:23:in `load'
        from /home/andrew-stuntz/.gems/bin/dotenv:23:in `<main>'
➜  myproj git:(49.0.0.rc2) ✗ gem install dotenv -v 2.6.0
Fetching: dotenv-2.6.0.gem (100%)
Successfully installed dotenv-2.6.0
Parsing documentation for dotenv-2.6.0
Installing ri documentation for dotenv-2.6.0
Done installing documentation for dotenv after 0 seconds
1 gem installed
➜  myproj git:(49.0.0.rc2) ✗ rbenv rehash
➜  myproj git:(49.0.0.rc2) ✗ gem when dotenv
ERROR:  While executing gem ... (Gem::CommandLineError)
    Unknown command when
➜  myproj git:(49.0.0.rc2) ✗ gem which dotenv
/home/andrew-stuntz/.gems/gems/dotenv-2.7.0/lib/dotenv.rb
➜  myproj git:(49.0.0.rc2) ✗ gem uninstall dotenv -v 2.7.0
Successfully uninstalled dotenv-2.7.0
➜  myproj git:(49.0.0.rc2) ✗ gem which dotenv
/home/andrew-stuntz/.gems/gems/dotenv-2.6.0/lib/dotenv.rb
➜  myproj git:(49.0.0.rc2) ✗ rbenv rehash
➜  myproj git:(49.0.0.rc2) ✗ ~/.rbenv/shims/dotenv ~/.rbenv/shims/bundle install --without development:test:staging
Using rake 12.3.0
Using concurrent-ruby 1.0.5
Using i18n 0.9.3
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.4

System configuration

dotenv version: 2.7.0

Rails version: n/a

Ruby version: 2.4.3

Only seeing this issue with 2.7.0

@cadwallion
Copy link
Collaborator

Yep, this is fallout from #374 to use a proper options parser instead of args hacking. For now, you can invoke with dotenv "command to execute" while I get a PR to resolve this. I'll cut 2.7.1 as soon as it's in master.

@cadwallion
Copy link
Collaborator

Again, apologies for the inconvenience on this!

@drews256
Copy link

@cadwallion no apologies! Thanks for the swift response!

cadwallion pushed a commit that referenced this issue Feb 23, 2019
This adds a flag matcher in addition to OptionParser that ensures that 
we only parse the flags leading up to the command we attempt to execute. 
 Resolves #375
@cadwallion
Copy link
Collaborator

PR is up that appears to resolve the problem without a revert of #374.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants