1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix Ruby version in .ruby-version

Since #30016 Rails generates `.ruby-version` file
in order to help Ruby version manager tools like `rbenv`, `rvm`
determine which Ruby version should be used for the current Rails
project.

Since #32649 Rails sets Ruby version to the file compatible with MRI/JRuby
by default.

Pull Request #31496 reports that `.ruby-version` doesn't match ruby version other
than stable version and recommends to use `ENV["RBENV_VERSION"]`, and
`ENV["rvm_ruby_string"]` in order to set correct Ruby version to the file
that `rbenv` or `rvm` can understand.
Also, there is another similar issue that reports the same case if use
JRuby https://github.com/jruby/jruby/issues/5144.

Closes #31496, https://github.com/jruby/jruby/issues/5144.
This commit is contained in:
bogdanvlviv 2018-06-18 19:44:39 +00:00
parent 38dbc8e2b8
commit 1aace5e2cc
No known key found for this signature in database
GPG key ID: E4ACD76A6DB6DFDD
2 changed files with 8 additions and 2 deletions

View file

@ -1 +1 @@
<%= "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}" -%>
<%= ENV["RBENV_VERSION"] || ENV["rvm_ruby_string"] || "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}" -%>

View file

@ -891,7 +891,13 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_match(/ruby '#{RUBY_VERSION}'/, content)
end
assert_file ".ruby-version" do |content|
assert_match(/#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}/, content)
if ENV["RBENV_VERSION"]
assert_match(/#{ENV["RBENV_VERSION"]}/, content)
elsif ENV["rvm_ruby_string"]
assert_match(/#{ENV["rvm_ruby_string"]}/, content)
else
assert_match(/#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}/, content)
end
end
end