Is there a way to specify a range for ruby version?
ruby '~> 2.1.0'
Your Ruby version is 2.1.1, but your Gemfile specified ~> 2.1.0
ruby '>= 2.1.0'
Your Ruby version is 2.1.1, but your Gemfile specified >= 2.1.0
Obviously, ranges works for gems, but maybe it's not possible for ruby version. Or did I get my syntax wrong?
You can't set a range for the ruby version, see here
Syntax is like so:
ruby 'RUBY_VERSION', :engine => 'ENGINE', :engine_version => 'ENGINE_VERSION', :patchlevel => 'RUBY_PATCHLEVEL'
It is not possible in Bundler 1.x because it cannot be done maintaining backward compatibility with the format of Gemfile.lock.
As discussed there, this is arguably a bad idea unless the lockfile contains the ruby version. Adding the ruby version to the lockfile means Bundler 2 at the earliest.
(from an issue that has been filed requesting the addition of a range feature for Ruby versions)
Related
If a Rails 6 Gemfile includes ruby "~> 3.0" and the current Ruby version in the project is 3.0.1, how does one upgrade Ruby to the highest current minor release (3.0.2 at this time) without modifying the Gemfile to specify an exact minor release (which would defeat the purpose of the "~> 3.0")?
The specifier ~> has a special meaning, best shown by example. ~> 3.0 is identical to >= 3.0 and < 3.1. So all minor patches are included. See https://bundler.io/gemfile.html.
No need to change your Gemfile just install the gems in the newly installed Ruby version.
I'm a newbie at Ruby on Rails. I'm trying to update the Gem file but it keeps giving me this error.
Your Ruby version is 2.3.3, but your Gemfile specified 2.3.0
The reason I'm trying to update the gem file is because of a security vulnerability .
check your gemfile, there will be
ruby '2.3.0'
you need to change it to
ruby '2.3.3'
more you can read here https://bundler.io/v1.12/gemfile_ruby.html and https://devcenter.heroku.com/articles/ruby-versions
Just change your ruby version at gem file to the version suggested by the error. Let's see if this works
I have downgraded my ruby-2.2.2 to ruby 1.9.3p551 and rails 4.2.4 to 3.2 version for my project now i am getting the dependency error of gemfile. How can I resolve these errors .? Is it possible to downgrade like this?
You need to change version of your gems, and then invoke
bundle update
You have few options to specify how bundler should resolve dependencies. But when you didn't specify version of gem, then bundler choose latest compliant version.Eg
gem 'sample_gem'
gem 'sample_gem', '1.0.0'
gem 'sample_gem', '>=1.0'
gem 'sample_gem', '~>1.1'
So remove version from gem version you don't care and then let bundler resolve dependencies.
I am trying to install rails after having installed ruby 2.4.1p111 on windows 8.1 from 'Start Command Prompt with Ruby(this is just like command prompt that got installed with ruby)'.
I use the command gem install rails and after a few seconds of pause the Title of the question is thrown as error.
I tried the command gem install nokogiri -v 1.7.1 and it throws the same error.
If I run gem list, it does not list nokogiri at all.
A possible solution I came across read. Change nokogiri version in gem Gemfile with some command gem 'nokogiri', '~> 1.6.8'. I don't know if that even applies to the version of rails I have installed. If this is the solution, how do I implement it?
How do I rectify this error and install rails?
Apparently there is an issue1 in Nokogiri compatibility with Ruby 2.4+, you can check the report here; it will be fixed in Nokogiri 1.8.0.
In the meantime, you could use Ruby 2.3.4, until version 1.8.0 is released.
I don't know if that even applies to the version of rails I have
installed.
No, it don't since you will be downgrading Nokogiri version and will not solve the compatibility issue. That worked for users whose Ruby version was prior to 2.1.0
1 Please notice (as pointed out in the comments) that this a Windows-only issue.
Edit:
You can update now your gemfile:
gem "nokogiri", (RUBY_VERSION >= "2.1" ? "~> 1.8" : "~> 1.6.8")
I'm trying to specify factory_girl_rails version less than 3.0 as I don't have ruby 1.9 installed and 3.0 isn't compatible with 1.8.x. I've tried a few ways round but it always tries to install 3.0.0 and fails on the ruby dependency.
According to this, Rails 3.0 should still be compatible with Ruby 1.8.7 (they aren't dropping Ruby 1.8 support until 4.0).
But, if you put this in your Gemfile, bundler should use the latest 2.3 version (the last minor version before 3.0) of Rails:
gem 'rails', '~>2.3'