2

I'm trying to use a .rb file from within a shell script like so:

ruby file.rb "input data"

In file.rb (it's in the root of a rails app), it requires another file which is throwing an error when I try the chmod method. Any suggestions?

Doing ruby file.rb "input data" outside of the .sh file works completely fine.

I've tried the answers here: Run .rb (Ruby) file on a Shell Script, and chmod and adding #!/usr/bin/ruby do not work. Would be grateful for any suggestions.

I'm on a mac, ruby-2.1.4.

When I try to run it, I get:

"/Users/user/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bundler/setup (LoadError)"

1 Answer 1

1

How about replacing ruby file.rb "input data" with

bundler exec ruby file.rb "input data" ?

You should also check bundle-exec manpage for more information on how bundler will run your script.

Sign up to request clarification or add additional context in comments.

2 Comments

Stops the first error, now getting: > /Library/Ruby/Site/2.0.0/rubygems/dependency.rb:298:in to_specs': Could not find 'bundler' (>= 0) among 93 total gem(s) (Gem::LoadError)` any suggestions?
Just reinstalled bundler (sudo gem install bundler), what an interesting solution, who would've thought. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.