From: "Iñaki Baz Castillo" Date: 2009-12-13T08:36:30+09:00 Subject: Re: Is it possible to force a Ruby program to run as a proc name different than "ruby"? El Sábado, 12 de Diciembre de 2009, Shot (Piotr Szotkowski) escribió: > Iñaki Baz Castillo: > > However in /proc/PID/status I still have the same described > > issues: "Name: ruby1.9", so I cannot do "killall rb_program". > > > > This can be solved by using: > > #!/usr/local/bin/ruby1.9 > > rather than: > > #!/usr/bin/env ruby1.9 > > > > but of course hardcoding the location of ruby is not very good > > approach (specially when you want your code to run on any Linux > > system). > > I was wondering about exactly this problem recently. I’m using > hand-rolled Ruby 1.9.1 and 1.8.7 versions in ~/opt – and once I finally > got to rolling my own gem I found out that when RubyGems install an > executable, they put a wrapper script in the given Ruby installation > path, with the hashbang hardcoded to that interpreter’s binary. I suffer same issues. I've installed ruby 1.9.1 (installed from sources) under /usr/local. and ruby 1.8.7 (Debian package) under /usr. I compile ruby1.9 with these options: /configure --prefix=/usr/local/ --program-suffix=1.9 ; make ; make install so all its runnable files are sufixed by 1.9 (ruby1.9, gem1.9, irb1.9...). Unfortunatelly executables installed by gems are not sufixed so there is conflict between ruby1.8 gems and ruby1.9 gems. By default /usr/local/bin/ appears before than /usr/bin/ in usual PATH environment variable, so executables belonging to ruby1.9 gems take preference. This is ugly when you install a ruby1.8 gem which requires some ruby executtable (as racc, rake and so). So finally my "solution/workaround" is a script that rewrites the PATH variable and sets /usr/bin/ before /usr/local/bin/. And I must run it before installing a gem for ruby1.8. Ugly but works :) > In other words – while the executables in my repo start with > ‘#!/usr/bin/env ruby’ (and so pick up the ‘current’ Ruby interpreter), > once I roll and install a gem RubyGems create a custom executable > wrappers for them, and the ones installed with Ruby 1.9.1 start with > ‘#!/home/shot/opt/ruby-1.9.1-p376/bin/ruby’ (and if I link them from > my ~/bin I don’t even need to do any $PATH munging to get them running > through a given Ruby binary). > > Hence, my conclusion is that if you turned your code into a gem prior > to installing it, you could still keep the ‘#!/usr/bin/env ruby1.9’ > hashbang in your repo (and for testing), but once you want to get > a given version into ‘production’, RubyGems will turn that into > ‘#!/usr/local/bin/ruby1.9’ upon the gem’s installation. Ok, I'll do it. Thanks a lot. -- Iñaki Baz Castillo