rubyinstaller icon indicating copy to clipboard operation
rubyinstaller copied to clipboard

rake doesn't work in 2.3.0 installer

Open bratsche opened this issue 8 years ago • 13 comments

$ rake
bash: /c/Ruby23/bin/rake: c:/Users/Justin/Projects/rubyinstaller/sandbox/ruby23_mingw/bin/ruby.exe: bad interpreter: No such file or directory

On my machine there is no user Justin, this is likely this way from the machine where the installer was built.

For me it's fixable by changing the first line of the rake command to #!/c/Ruby23/bin/ruby.exe or (because it's in my PATH) #!ruby.exe

bratsche avatar Apr 23 '16 01:04 bratsche

That fix also worked for me.

griest024 avatar Apr 28 '16 21:04 griest024

erb.cmd:#!C:/Users/Justin/Projects/rubyinstaller/sandbox/ruby23_mingw/bin/ruby
gem.cmd:#!C:/Users/Justin/Projects/rubyinstaller/sandbox/ruby23_mingw/bin/ruby
irb.cmd:#!C:/Users/Justin/Projects/rubyinstaller/sandbox/ruby23_mingw/bin/ruby
Binary file libeay32.dll matches
rdoc.cmd:#!C:/Users/Justin/Projects/rubyinstaller/sandbox/ruby23_mingw/bin/ruby
ri.cmd:#!C:/Users/Justin/Projects/rubyinstaller/sandbox/ruby23_mingw/bin/ruby
Binary file ruby.exe matches
Binary file rubyw.exe matches

There are other examples of this in the same directory; they are all in the .cmd (where presumably the DOS-based shell would see them), or in the binaries where I don't think they'll be visible except in error reports.

In any case, this should be patched somehow in the build process.

technogeeky avatar May 14 '16 06:05 technogeeky

Hmmm, I'll look into this.

But the full executable path has never been hard coded like that before.

Azolo avatar Jul 19 '16 00:07 Azolo

Go into the bin folder of your ruby installation and edit the rake file. Change the first line from #!C:/Users/Justin/Projects/rubyinstaller/sandbox/ruby23_mingw/bin/ruby.exe to #!ruby.exe or the absolute path your ruby executable if its not in your PATH.

ymma avatar Jul 28 '16 02:07 ymma

i tried the way you guys said,but it seems didn't work on me. i changed the first line, and the alert was disappear, but the rake file still did not work.

aspirinor avatar Sep 24 '16 11:09 aspirinor

The issue is caused by bash using extensionless rake file instead of rake.cmd or rake.bat that are present in the same directory.

You can solve that permantly by installing gem-exefy and ensuring all executables exposed by gems are .exe.

To install perform gem install gem-exefy and then follow the project instructions:

https://github.com/bosko/gem-exefy#synopsis

The only requirement is RubyInstaller + DevKit in place and working. See the installation instructions on the wiki for the DevKit here

Remember to use the correct DevKit for your Ruby installation.

luislavena avatar Oct 08 '16 19:10 luislavena

You can also workaround that by setting --env-shebang when installing any gem (gem install rake --env-shebang)

C:\Users\Luis>ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [i386-mingw32]

C:\Users\Luis>where rake
C:\Ruby23\bin\rake
C:\Ruby23\bin\rake.bat

C:\Users\Luis>type C:\Ruby23\bin\rake
#!C:/Users/Justin/Projects/rubyinstaller/sandbox/ruby23_mingw/bin/ruby.exe
#
# This file was generated by RubyGems.
...

C:\Users\Luis>gem pristine rake --env-shebang
Restoring gems to pristine condition...
Restored rake-10.4.2

C:\Users\Luis>type C:\Ruby23\bin\rake
#! ruby
#
# This file was generated by RubyGems.
...

You can apply that to all gems (gem pristine --all --env-shebang) and also make that setting permanent by updating .gemrc file in your home directory:

---
gem: --no-document --env-shebang

Hope that helps.

luislavena avatar Oct 08 '16 19:10 luislavena

--- gem: --no-document --env-shebang

Hope that helps.

Immensely! Thanks!

Joe

swatosh avatar Oct 09 '16 04:10 swatosh

@luislavena does it maybe make sense to make the above ~/.gemrc the default for oneclick installer?

wycats avatar Apr 17 '17 05:04 wycats

@wycats I think is possible using operating_system.rb RubyGems hook, but that will need confirmation.

luislavena avatar Apr 17 '17 16:04 luislavena

@luislavena @wycats This is only happening with prepackaging rake. So even if you made it the default the problem would persist unless it was fixed during packaging. Installing/reinstalling rake or using gem pristine rake should just fix it.

Interestingly enough all the other prepackaged binaries use #!/usr/bin/env ruby. I think this is either a patched when packaging or Ruby issue. rake is being treated differently from the other gem binaries that are shipped with ruby though.

Azolo avatar Apr 17 '17 20:04 Azolo

@luislavena Also the way to set the defaults in operating_system.rb (from the best that I can tell) is like this:

Gem::ConfigFile::OPERATING_SYSTEM_DEFAULTS.merge!({'gem' => '--env-shebang'})

But any configuration in your .gemrc seem to overwrite those default configs.

Azolo avatar Apr 17 '17 20:04 Azolo

I solved this issue in RubyInstaller2 here: https://github.com/oneclick/rubyinstaller2/blob/master/recipes/sandbox/40-generate-rake-cmd.rake

larskanis avatar Apr 18 '17 05:04 larskanis