My ruby shell scripts specify the ruby interpreter in the first line of the script as:
#!/Users/me/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
The problem is that when I upgrade to a new ruby version, I have to edit all the script files to update the interpreter. There is an environment variable available, $MY_RUBY_HOME, that expands to the current path (minus the /bin/ruby part). However, all my attempts to use:
#!{$MY_RUBY_HOME}/bin/ruby
#!${MY_RUBY_HOME}/bin/ruby
etc
fail (“bad interpreter: No such file or directory”). I suspect environment expansion isn’t done on the first line, so I may just be out of luck. I would be interested if anybody has been able to use environment variable expansion on the program definition line in a shell script.
Put
${MY_RUBY_HOME}/binin your$PATHand use#!/usr/bin/env ruby. See here.