When I invoke commands using bundle exec
it takes the parameters I pass in. An example for this would be:
bundle exec my_command run --verbose
In this case --verbose
is used as a bundler argument where as it should be used for my_command
. I know the following way would work:
bundle exec 'my_command run --verbose'
Is it possible to avoid the quotes? The command I use has already a lot of quotes. I expected something like this would work but it didn't:
bundle exec -- my_command run --verbose
I don't see much documentation about this for bundler. Any ideas would be greatly appreciated.
This looks like what is a common problem when passing one command to another in the shell, and it looks like you're close to what I'd use. Instead of using:
bundle exec my_command run --verbose
Or:
bundle exec -- my_command run --verbose
Try:
bundle exec my_command -- run --verbose
Using bundle exec --
breaks the command-chain for bundle exec
. exec
is a sub-command for bundle
and my_command
is a parameter for exec
. The parameters for my_command
, well, neither bundle
or exec
needs to know about them so the --
goes where you want to break that chain of parameters to bundle
.
Inspecting from source of bundler, it is default behavior to pass all the parameters after bundle exec
to Kernel.exec
, so the --verbose
parameters will be passed to your command, not bundle
.
bundle exec my_command run --verbose
will run the following under the context of bundle
Kernel.exec('my_command', 'run', '--verbose')
and
bundle exec -- my_command run --verbose
results in an error because no command/script is named --
.
Check the test case here:
#!/usr/bin/env ruby
# coding: utf-8
# file: test.rb
p ARGV
test:
$ bundle exec ruby test.rb --verbose --arg1
["--verbose", "--arg1"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With