mais-oui
mais-oui

Reputation: 2741

Execution of ruby file fails from within shell script

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)"

Upvotes: 2

Views: 313

Answers (1)

egwspiti
egwspiti

Reputation: 987

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.

Upvotes: 1

Related Questions