Allow compiling from source on windows:#3690
Conversation
| Dir.chdir(File.expand_path("../..", __dir__)) do | ||
| if !File.exist?("include/prism/ast.h") && Dir.exist?(".git") | ||
| system("templates/template.rb", exception: true) | ||
| system(Gem.ruby, "templates/template.rb", exception: true) |
There was a problem hiding this comment.
I think this is okay, but I just want to make sure there's not an environment when Gem isn't available. @tenderlove do you know if that could possibly be the case?
Since we know we already have RbConfig because of the explicit require, maybe safer to just implement it ourselves:
| system(Gem.ruby, "templates/template.rb", exception: true) | |
| ruby = File.join(RbConfig::CONFIG["bindir"], "#{RbConfig::CONFIG["ruby_install_name"]}#{RbConfig::CONFIG["EXEEXT"]}") | |
| system(ruby, "templates/template.rb", exception: true) |
There was a problem hiding this comment.
Using Gem should be fine. The only time it won't be available is if someone does --disable-gems, but since we're using RubyGems to install the gem, then I think it's OK.
There was a problem hiding this comment.
There is RbConfig.ruby, that seems safer to use and is just as expressive.
There was a problem hiding this comment.
The user could have RUBYOPT=--disable-gems in env, then Gem.ruby here would likely break (probably many other things too, but that's out of scope), hence RbConfig.ruby is better.
|
Thanks for the review folks. Let me know if you'd like to go with the custom suggested solution or just |
|
@Edouard-chin Can you change to |
- I'm trying to compile Prism from source on a Windows machine but it unforunately fails when trying to render the template due to the shebang that doesn't exist on Windows. I modified the `system` call to call ruby with its full path directly instead.
d22ba0f to
c0dfdd4
Compare
👋
I'm trying to compile Prism from source on a Windows machine but it unforutnately fails when trying to render the template due to the shebang that doesn't exist on Windows
prism/templates/template.rb
Line 1 in 2e577c0
I modified the
systemcall to call ruby with its full path directly instead.