Tim Ferrell
2005-Feb-17 14:47 UTC
annoying bash issue (I know this is something stupid...)
I am just getting started with rails on gentoo linux and am working through the cookbook example ... when I try to execute "script/generate" I get the following: timf@skoodge cookbook $ script/generate -bash: script/generate: /usr/bin/ruby18: bad interpreter: Permission denied timf@skoodge cookbook $ ll /usr/bin/ruby18 -rwxr-xr-x 1 root root 4148 Jan 31 08:50 /usr/bin/ruby18* timf@skoodge cookbook $ ll script/generate -rwxr-xr-x 1 timf users 2020 Jan 24 11:58 script/generate* when I run "ruby script/generate" all is well... how can I fix this? Cheers, Tim
Stefan Arentz
2005-Feb-17 14:52 UTC
Re: annoying bash issue (I know this is something stupid...)
On Feb 17, 2005, at 3:47 PM, Tim Ferrell wrote:> I am just getting started with rails on gentoo linux and am working > through the cookbook example ... when I try to execute > "script/generate" I get the following: > > timf@skoodge cookbook $ script/generate > -bash: script/generate: /usr/bin/ruby18: bad interpreter: Permission > denied > > timf@skoodge cookbook $ ll /usr/bin/ruby18 > -rwxr-xr-x 1 root root 4148 Jan 31 08:50 /usr/bin/ruby18* > > timf@skoodge cookbook $ ll script/generate > -rwxr-xr-x 1 timf users 2020 Jan 24 11:58 script/generate* > > when I run "ruby script/generate" all is well... how can I fix this?What is the first line of script/generate? (It is probably set to /usr/bin/ruby, if that does not exist then you can either change the script files to point to your ruby18 or simply symlink /usr/bin/ruby18 to /usr/bin/ruby which is a more conventional name anyway) S.
Tim Ferrell
2005-Feb-17 15:18 UTC
[Rails] annoying bash issue (I know this is something stupid...)
Well, I found a solution ... it seems that since my user home dir is on a second drive I had to add "exec" to the fstab options... Cheers, Tim Stefan Arentz wrote:> > On Feb 17, 2005, at 3:47 PM, Tim Ferrell wrote: > >> I am just getting started with rails on gentoo linux and am working >> through the cookbook example ... when I try to execute >> "script/generate" I get the following: >> >> timf@skoodge cookbook $ script/generate >> -bash: script/generate: /usr/bin/ruby18: bad interpreter: Permission >> denied >> >> timf@skoodge cookbook $ ll /usr/bin/ruby18 >> -rwxr-xr-x 1 root root 4148 Jan 31 08:50 /usr/bin/ruby18* >> >> timf@skoodge cookbook $ ll script/generate >> -rwxr-xr-x 1 timf users 2020 Jan 24 11:58 script/generate* >> >> when I run "ruby script/generate" all is well... how can I fix this? > > > What is the first line of script/generate? (It is probably set to > /usr/bin/ruby, if that does not exist then you can either change the > script files to point to your ruby18 or simply symlink /usr/bin/ruby18 > to /usr/bin/ruby which is a more conventional name anyway) > > S. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Ara.T.Howard
2005-Feb-17 15:42 UTC
[Rails] annoying bash issue (I know this is something stupid...)
On Thu, 17 Feb 2005, Tim Ferrell wrote:> I am just getting started with rails on gentoo linux and am working through > the cookbook example ... when I try to execute "script/generate" I get the > following: > > timf@skoodge cookbook $ script/generate > -bash: script/generate: /usr/bin/ruby18: bad interpreter: Permission denied > > timf@skoodge cookbook $ ll /usr/bin/ruby18 > -rwxr-xr-x 1 root root 4148 Jan 31 08:50 /usr/bin/ruby18* > > timf@skoodge cookbook $ ll script/generate > -rwxr-xr-x 1 timf users 2020 Jan 24 11:58 script/generate* > > when I run "ruby script/generate" all is well... how can I fix this? > > Cheers, > Tim[ahoward@localhost cookbook]$ head script/generate #!/usr/local/bin/ruby require File.dirname(__FILE__) + ''/../config/environment'' require ''rails_generator'' ARGV.shift unless ARGV.empty? or not [''--help'', ''-h''].include?(ARGV[0]) def find_synonyms(word) require ''open-uri'' require ''timeout'' notice the path to ruby on the first line - change it to point to your ruby. this is the same for all scripts. HTH. rails developers : why not use #!/usr/bin/env ruby ?? kind regards. -a -- ==============================================================================| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | When you do something, you should burn yourself completely, like a good | bonfire, leaving no trace of yourself. --Shunryu Suzuki ===============================================================================
Jeremy Kemper
2005-Feb-17 16:34 UTC
Re: annoying bash issue (I know this is something stupid...)
Ara.T.Howard wrote:> rails developers : why not use #!/usr/bin/env ruby ??/usr/bin/env ruby would point to Ruby 1.6 on MacOS X and would be meaningless on Windows. Apps created with the ''rails'' command use File.join(Config::CONFIG[''bindir''], Config::CONFIG[''ruby_install_name'']) for shebang lines in script/* and public/dispatch.* jeremy
Ara.T.Howard
2005-Feb-17 17:05 UTC
Re: annoying bash issue (I know this is something stupid...)
On Thu, 17 Feb 2005, Jeremy Kemper wrote:> /usr/bin/env ruby would point to Ruby 1.6 on MacOS X and would be > meaningless on Windows.ah - that''d be true on rh enterprise too - ;-(> Apps created with the ''rails'' command use > File.join(Config::CONFIG[''bindir''], Config::CONFIG[''ruby_install_name'']) for > shebang lines in script/* and public/dispatch.*guess something like [ahoward@localhost ~]$ diff -u Rakefile.org Rakefile --- Rakefile.org 2005-02-17 09:58:57.016644679 -0700 +++ Rakefile 2005-02-17 10:01:01.093563070 -0700 @@ -184,6 +184,7 @@ def copy_with_rewritten_ruby_path(src_file, dest_file) ruby = File.join(Config::CONFIG[''bindir''], Config::CONFIG[''ruby_install_name'']) + abort "interpreter <#{ ruby }> not executable" unless File.executable? ruby File.open(dest_file, ''w'') do |df| File.open(src_file) do |sf| would have illuminated OP''s problem... cheers. -a -- ==============================================================================| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | When you do something, you should burn yourself completely, like a good | bonfire, leaving no trace of yourself. --Shunryu Suzuki ===============================================================================
Jeremy Kemper
2005-Feb-17 17:11 UTC
Re: annoying bash issue (I know this is something stupid...)
Ara.T.Howard wrote:> guess something like > > + abort "interpreter <#{ ruby }> not executable" unless > File.executable? ruby > > would have illuminated OP''s problem...Does #executable? attempt to execute or only look at file permissions? I''m guessing it''d give a false positive since noexec is marked on the filesystem itself. jeremy
Dick Davies
2005-Feb-17 17:21 UTC
Re: annoying bash issue (I know this is something stupid...)
* Ara.T.Howard <Ara.T.Howard-32lpuo7BZBA@public.gmane.org> [0207 17:07]:> guess something like > > [ahoward@localhost ~]$ diff -u Rakefile.org Rakefile > --- Rakefile.org 2005-02-17 09:58:57.016644679 -0700 > +++ Rakefile 2005-02-17 10:01:01.093563070 -0700 > @@ -184,6 +184,7 @@ > > def copy_with_rewritten_ruby_path(src_file, dest_file) > ruby = File.join(Config::CONFIG[''bindir''], > Config::CONFIG[''ruby_install_name'']) > + abort "interpreter <#{ ruby }> not executable" unless File.executable? > ruby > > File.open(dest_file, ''w'') do |df| > File.open(src_file) do |sf| > > > would have illuminated OP''s problem...And what would run the rakefile......? :) -- ''You were doing well until everyone died'' -- God Rasputin :: Jack of All Trades - Master of Nuns
Ara.T.Howard
2005-Feb-17 17:24 UTC
Re: annoying bash issue (I know this is something stupid...)
On Thu, 17 Feb 2005, Jeremy Kemper wrote:> Ara.T.Howard wrote: >> guess something like >> >> + abort "interpreter <#{ ruby }> not executable" unless >> File.executable? ruby >> >> would have illuminated OP''s problem... > > Does #executable? attempt to execute or only look at file permissions? > I''m guessing it''d give a false positive since noexec is marked on the > filesystem itself.on linux it''s a stat of file only: harp:~ > strace ruby -e"require ''rbconfig'';File::executable?(File.join(Config::CONFIG[''bindir''],Config::CONFIG[''ruby_install_name'']))" 2>&1|tail read(3, "[\"configure_args\"] = \"\''--host=i3"..., 4096) = 1693 read(3, "", 4096) = 0 close(3) = 0 munmap(0xb75af000, 4096) = 0 stat64("/usr/bin/ruby", {st_mode=S_IFREG|0755, st_size=3548, ...}) = 0 geteuid32() = 447 getegid32() = 447 getgid32() = 447 getgroups32(32, [447, 11111]) = 2 exit_group(0) = ? but i am unable to test on windoze. anyone? perhaps this would be safer then: [ahoward@localhost ~]$ diff -u Rakefile.org Rakefile --- Rakefile.org 2005-02-17 09:58:57.016644679 -0700 +++ Rakefile 2005-02-17 10:23:24.512960563 -0700 @@ -184,6 +184,12 @@ def copy_with_rewritten_ruby_path(src_file, dest_file) ruby = File.join(Config::CONFIG[''bindir''], Config::CONFIG[''ruby_install_name'']) + executable = begin; system "#{ ruby } -ep"; rescue Exception; false; end + unless executable + msg = "ruby interpreter <#{ ruby }> is not executable!\n" << + "check exec permissions on file/drive and try again." + abort msg + end File.open(dest_file, ''w'') do |df| File.open(src_file) do |sf| cheers. -a -- ==============================================================================| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | When you do something, you should burn yourself completely, like a good | bonfire, leaving no trace of yourself. --Shunryu Suzuki ===============================================================================
Ara.T.Howard
2005-Feb-17 17:37 UTC
Re: annoying bash issue (I know this is something stupid...)
On Thu, 17 Feb 2005, Dick Davies wrote:> * Ara.T.Howard <Ara.T.Howard-32lpuo7BZBA@public.gmane.org> [0207 17:07]: > >> guess something like >> >> [ahoward@localhost ~]$ diff -u Rakefile.org Rakefile >> --- Rakefile.org 2005-02-17 09:58:57.016644679 -0700 >> +++ Rakefile 2005-02-17 10:01:01.093563070 -0700 >> @@ -184,6 +184,7 @@ >> >> def copy_with_rewritten_ruby_path(src_file, dest_file) >> ruby = File.join(Config::CONFIG[''bindir''], >> Config::CONFIG[''ruby_install_name'']) >> + abort "interpreter <#{ ruby }> not executable" unless File.executable? >> ruby >> >> File.open(dest_file, ''w'') do |df| >> File.open(src_file) do |sf| >> >> >> would have illuminated OP''s problem... > > And what would run the rakefile......? :)i wondered that too but the OP managed it somehow. one scenario is doing development while having the RUBYLIB env (which i do all the time) set, then running rakefile and picking up the wrong rbconfig. who knows... other possible sources of error are RUBYLIB_PREFIX env, -I command line switch, and mucking about with $: (say from within irb). so long as there are > 1 rbconfig files on the system it''s possible. cheers. -a -- ==============================================================================| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | When you do something, you should burn yourself completely, like a good | bonfire, leaving no trace of yourself. --Shunryu Suzuki ===============================================================================
Jeremy Kemper
2005-Feb-17 18:05 UTC
Re: annoying bash issue (I know this is something stupid...)
Ara.T.Howard wrote:> so long as there are > 1 rbconfig files on the system it''s possible.Also, the ''rails'' script in beta gems takes a --ruby option to specify the shebang line. jeremy
Tim Ferrell
2005-Feb-17 18:19 UTC
Re: annoying bash issue (I know this is something stupid...)
Actually my problem came about because I migrated my home dir to a second drive after installing rails... and I had been noticing this behavior on my shell and perl scripts as well - rails was just the tipping point to me actually finding out why ... I am used to perl giving me grief :-) Since I prefer using the "#!/usr/bin/env ruby" approach in my scripts, I test RUBY_VERSION to avoid choking on an old version of ruby... Is there some loophole in this that I am not aware of? I really hate hard coding interpreter paths in my scripts... Cheers, Tim Ara.T.Howard wrote:> On Thu, 17 Feb 2005, Dick Davies wrote: > >> * Ara.T.Howard <Ara.T.Howard-32lpuo7BZBA@public.gmane.org> [0207 17:07]: >> >>> guess something like >>> >>> [ahoward@localhost ~]$ diff -u Rakefile.org Rakefile >>> --- Rakefile.org 2005-02-17 09:58:57.016644679 -0700 >>> +++ Rakefile 2005-02-17 10:01:01.093563070 -0700 >>> @@ -184,6 +184,7 @@ >>> >>> def copy_with_rewritten_ruby_path(src_file, dest_file) >>> ruby = File.join(Config::CONFIG[''bindir''], >>> Config::CONFIG[''ruby_install_name'']) >>> + abort "interpreter <#{ ruby }> not executable" unless >>> File.executable? >>> ruby >>> >>> File.open(dest_file, ''w'') do |df| >>> File.open(src_file) do |sf| >>> >>> >>> would have illuminated OP''s problem... >> >> >> And what would run the rakefile......? :) > > > i wondered that too but the OP managed it somehow. > > one scenario is doing development while having the RUBYLIB env (which i > do all > the time) set, then running rakefile and picking up the wrong rbconfig. > who > knows... > > other possible sources of error are RUBYLIB_PREFIX env, -I command line > switch, and mucking about with $: (say from within irb). > > so long as there are > 1 rbconfig files on the system it''s possible. > > cheers. > > -a
Ara.T.Howard
2005-Feb-17 18:31 UTC
Re: annoying bash issue (I know this is something stupid...)
On Thu, 17 Feb 2005, Tim Ferrell wrote:> Actually my problem came about because I migrated my home dir to a second > drive after installing rails... and I had been noticing this behavior on my > shell and perl scripts as well - rails was just the tipping point to me > actually finding out why ... I am used to perl giving me grief :-)tough for rails to fix this ;-)> Since I prefer using the "#!/usr/bin/env ruby" approach in my scripts, I > test RUBY_VERSION to avoid choking on an old version of ruby... Is there > some loophole in this that I am not aware of? I really hate hard coding > interpreter paths in my scripts...i''m with you but this is tougher than it sounds: harp:~ > cat a.rb BEGIN { puts "i can''t tell you this" if RUBY_VERSION != ''1.9.0'' } def ruby_16_syntax_error &b; end puts "after checking syntax i can tell you this" harp:~ > ruby16 a.rb a.rb:6: syntax error def ruby_16_syntax_error &b; end ^ a.rb:6: syntax error harp:~ > ruby18 a.rb after checking syntax i can tell you this FYI. the rails approach (hard coding paths) is by far the safest. -a -- ==============================================================================| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | When you do something, you should burn yourself completely, like a good | bonfire, leaving no trace of yourself. --Shunryu Suzuki ===============================================================================
>>>>> "Jeremy" == Jeremy Kemper <jeremy-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> writes:Jeremy> Ara.T.Howard wrote: >> rails developers : why not use #!/usr/bin/env ruby ?? Jeremy> /usr/bin/env ruby would point to Ruby 1.6 on MacOS X and Jeremy> would be meaningless on Windows. If your PATH is set correctly then ''/usr/bin/env ruby'' should just do the right thing: lemur:~ 704> /usr/bin/env ruby --version ruby 1.8.2 (2004-12-25) [powerpc-darwin7.8.0] If that''s not working then just ''ruby foo.rb'' on the command line would be finding the wrong version as well. -- Fletch | "If you find my answers frightening, __`''/| fletch at phydeaux.org| Vincent, you should cease askin'' \ o.O'' | scary questions." -- Jules =(___) | U