How do I reference the local ruby in a hash-bang e

2019-06-21 14:03发布

问题:

I have a Ruby executable (it's a bundler binstub) which starts with

#!/usr/bin/env ruby

On my server I have Ruby 193 installed via RVM.

$ which ruby
-> /home/dtuite/.rvm/rubies/ruby-1.9.3-p0/bin/ruby

On my local machine, I also have Ruby installed via RVM, but in a different location (obviously!)

$ which ruby
-> /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p0/bin/ruby

When I try to run this executable on the server I get an error

/usr/bin/env: ruby: No such file or directory

Is there a way I can reference the locally available ruby in the hash-bang so that the same script will execute on both the server and the local machine?

回答1:

Try rvm-auto-ruby - it is explained in a somewhat different context in RVM's Textmate documentation.