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'
Related
I'm trying to use Ransack on RoR app.
https://github.com/activerecord-hackery/ransack
Unfortunately latest ransack only support ruby 2.6+. Mine is 2.5.8.
So what should I do? Any available version is there on Ransack?
You can use an older version, namely 2.4.1.
If you look on rubygems.org, you can quickly see the minimum required ruby version for each version of the gem:
2.4.2 requires ruby >= 2.6
2.4.1 requires ruby >= 2.3
However, you shouldn't even ordinarily need to check this manually!! If you run bundler update ransack on a project, it will automatically fetch the latest compatible version of the gem, given all your other dependencies.
I've just started working on a very old legacy app for a client, which is running on Ruby 1.9.3, Rails 3.2, and using JRuby on the production server. (Obstacles in upgrading the server has been a contributor to remaining on 1.9.3.)
Adding a gem to the Gemfile, even though the gem is compatible with 1.9.3, and even though I've added
ruby '1.9.3', :patchlevel => '551'
to the top of the Gemfile, Bundler continually chooses versions of other gems that require Ruby 2.0, and so updating fails. How can I get around this, without having to manually specify every single gem version that it fails on.
For example:
...
Using quiet_assets 1.1.0
Using rails 3.2.22
Using ref 2.0.0
Using rspec-rails 2.14.2
Fetching rspec_junit_formatter 0.3.0 (was 0.2.3)
Installing rspec_junit_formatter 0.3.0 (was 0.2.3)
Gem::InstallError: rspec_junit_formatter requires Ruby version >= 2.0.0.
An error occurred while installing rspec_junit_formatter (0.3.0), and Bundler cannot continue.
Make sure that `gem install rspec_junit_formatter -v '0.3.0'` succeeds before bundling.
I had to specify gem 'rspec_junit_formatter', '0.2.3', as well as all of the previous failures, in order to get this working. But that seems to defeat the purpose of Bundler. Why is Bundler ignoring Ruby versions when it builds its dependency graph, even though I've explicitly told it what version of Ruby to use?
Bundler is not ignoring the ruby version. When it installs gems it does not look at each gem and do a smart pick of which one to choose to get rid of any dependency issues (including the ruby version dependency).
In your gemfile, by not specifying the gem version, bundler will try to install the highest version it can. This is why it is good practice to specify exact versions for all your gems- so that if an update comes out for a gem in the repo you are getting the gem from- your project does not break.
Specifying the ruby version in the gem file is just like specifying the gem version for particular gem- it installs that version but does not affect the installation of any other gems.
I'm trying to install capybara on a setup with Ruby 1.8.7 and Rails 2.3, but I received this message:
capybara requires Ruby version >= 1.9.3.
I have two questions.
The more relevant question:
What is the latest capybara version compatible with that setup?
The more important question:
How I can check that on my own?
Regarding Capybara's Ruby version dependency, I went to the capybara source code and read its History. Searching for "Ruby" quickly got me to the statement that Capybara dropped support for Ruby 1.8 in version 2.0.0. So the previous version, 1.1.4, is the most recent version compatible with Ruby 1.8.
Unfortunately that file says nothing about Rails versions. My Rails 2 projects used webrat, so I don't have any personal data points. However, Googling '"rails 2" capybara version' turns up examples of using Capybara 1.1 with Rails 2 (for example in the Cucumber documentation), so the most recent Capybara version that is compatible with your Ruby is also compatible with your Rails.
In your gemfile, specify a version so you can install it. Looking at an REE app i have at work, we're using 1.1.4:
gem 'capybara', '~> 1.1.4'
The ~> with 1.1.x will ensure it always stays at a 1.1.x patch level. Similarly if you use ~> 1.2 it will always stay at a 1.x patch level.
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)
I'm installing ruby on rails on my OS X 10.7 machine and trying to follow along with this book: Agile Web Development with Rails.
Anyway I have installed Ruby 1.9.3 and then ran gem install rails and it pulled down rails 3.1.3, now the book says when I run 'rails -v' I should get 3.2.0 or NEWER.
I checked out http://rubygems.org/gems/rails and it says the latest version is rails 3.2.0 RC2, how is it that the book specifies (in multiple places to it's not a typo) that it should be 3.2.0 or NEWER when 3.2.0 isn't even released?
Actually, if you want the latest unstable version, run this:
gem install rails --pre
It'll install the latest RC.
EDIT: as to why the included 3.2.0 when it is not out yet, I can't answer for them! Maybe you have a "beta" version of the book?
Looks like you're specifying an explicit dependency on a future version of Rails, probably something like gem 'rails', '3.2.0'. If you indeed want to use this version, you'll have to settle for one of the release candidates for now:
gem 'rails', '3.2.0.rc2'
Or borrow a time machine.