I have a Ruby script called foo.rb, and I want to run it within the context of the bundler environment. How?
bundle exec foo.rb
doesn\'t work, because exec
You can just make it a script - add
#!/usr/bin/env ruby
to the start of the file, and make it executable. Then bundle exec foo.rb
will work as expected.
(This is on unix or OSX - not sure about Windows)
See http://bundler.io/v1.15/man/bundle-exec.1.html#Loading
Also see https://coderwall.com/p/kfyzcw/execute-ruby-scripts-directly-without-bundler-exec for how to run ruby scripts with bundled dependencies, without needing bundle exec