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?
The opening line is called a shebang because of the first two characters #! . This line provides the shell (in our case, bash) with the absolute path to the Ruby interpreter. If we were writing a script in another language, we'd provide the path to that interpreter instead.
#!/usr/bin/env ruby. ...uses the PATH to look up the location of the ruby executable. Because the path to the env executable is fully specified, this is a valid shebang line (which #! ruby is not).
Try rvm-auto-ruby
- it is explained in a somewhat different context in RVM's Textmate documentation.
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