/ usr / bin / ruby ​​vs. rvm

After performing the effort finally packages for cleaning ruby ruby packages from my Ubuntu isolated development environment to replace the recommended rvm, I must be misunderstanding something fundamental:

I dont want to change all shebang lines in all my source .rb files from

#!/usr/bin/ruby

      

in / usr / local / rvm / bin directory / ruby , and nothing depends on the version.

My source files should stay persistent with their counterparts on production servers using the default ruby ​​binaries (not rvm).

Any suggestions for keeping the code universally? Should I switch shebangs, once and for all, to something like

#!/usr/bin/env ruby

      

or (despite what this linking site says ) is there some clean way for rvm to connect to / usr / bin / ruby, assuming all conflicting .debs have been removed? Not to mention how to get other .deb packages depending on the presence of ruby ​​+ libs to recognize the non-distributive ruby ​​... but that could be a separate issue.

+3


source to share


2 answers


the only sane way is:

#!/usr/bin/env ruby

      



it will always use the currently selected ruby ​​in the environment, independent of any instrument

+16


source


Using env (1) , the shebang adds a layer of complexity and a set of security concerns, but this is the commonly used solution. One problem is that it does not include an interpreter, but makes it specific to the PATH values ​​for each user.

You can replace /usr/bin/ruby

with a symbolic link. On modern Linux, the recursive shebang will work and / usr / bin / ruby ​​could be script like:



 #!/bin/sh
 exec /some/other/ruby "$@"

      

+2


source







All Articles