Ruby executables using current RVM installation for local user?

I would like ruby ​​scripts with the title #! /usr/bin/ruby #! /usr/bin/ruby executed using the currently used version of ruby ​​rvm. I ran into a problem when I use the given version, but after executing the script, the system ruby ​​is called. Installing RVM for each user in the system is not an option.

Problem:

 ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.3.0] /usr/bin/ruby -v ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0] 

How to do this next without performing an RVM system installation?

 ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.3.0] ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.3.0] 
+6
source share
1 answer

If you run which ruby , you will find that the RVM ruby does not lie on /usr/bin/ruby . Use instead:

 #!/usr/bin/env ruby 

This will say to see which ruby use in the current environment (essentially $PATH ).

You can also execute your script through ruby yourself: ruby myscript.rb

+27
source

Source: https://habr.com/ru/post/910040/


All Articles