oneclick / rubyinstaller

RubyInstaller for Windows - Build recipes
http://rubyinstaller.org
BSD 3-Clause "New" or "Revised" License
1.19k stars 304 forks source link

rake doesn't work in 2.3.0 installer #317

Open bratsche opened 8 years ago

bratsche commented 8 years ago
$ 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

griest024 commented 8 years ago

That fix also worked for me.

technogeeky commented 8 years ago
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.

Azolo commented 8 years ago

Hmmm, I'll look into this.

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

ymma commented 8 years ago

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.

aspirinor commented 7 years ago

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.

luislavena commented 7 years ago

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 commented 7 years ago

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.

swatosh commented 7 years ago

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

Hope that helps.

Immensely! Thanks!

Joe

wycats commented 7 years ago

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

luislavena commented 7 years ago

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

Azolo commented 7 years ago

@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 commented 7 years ago

@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.

larskanis commented 7 years ago

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