Downgrade my ruby and rails version.! - ruby-on-rails

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.

Related

Ruby version error Bundle install error in Rails

I am using Ruby 2.4.2. When I run bundle install, it shows the following error:
Your Ruby version is 2.4.1, but your Gemfile specified 2.3.3
It showing this error because in your Gemfile you have specified Ruby version '2.3.3'.
You have two options: one is to remove the Ruby version declaration from your Gemfile, the second to specify the version that is installed on the system in Gemfile.
ruby '2.4.1'
It should be like that in your gemfile.
If you want to use Ruby '2.4.2' then install it in your system and specify the same in Gemfile. You can use RVM or rbenv to manage multiple versions of Ruby.

Why is Bundler repeatedly choosing gems that require a newer version of Ruby

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.

Error Installing rails: nokogiri requires Ruby version < 2.4, >= 2.1.0

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")

Bundler could not find compatible versions for gem "bundler" asking me for the incompatible versions of the bundler i have and the bundler required

I am new to ruby on rails and trying to install the bundle in my rails app and getting the same error this whole time ..
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (= 1.0.18) ruby
Current Bundler version:
bundler (1.7.4)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running gem install bundler?
I have tried almost each suggestions that've been suggested but none so far worked for me.
Can anybody help..??
Thank you in advance..
Usually, Bundler does not need to be on Gemfile.
You can remove the line that contains bundler in Gemfile, then run bundle again.
The reason this is failing is because your system has probably a newer version of bundler than the Gemfile is asking for.

Bundler could not find compatible versions for gem "bundler":

Complete new person to Ruby and Rails here... Have tried some tutorials in the past, but that's about it. I'm trying to follow 'Ruby on Rails 3 Tutorial' book and have hit a roadblock that I haven't been able to find any help for after searching on here and the Google..
I haven't actually done anything yet; only:
rails new first_app
then changed the Gemfile sqlite3 to
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
When I run 'bundle install' I get the following:
Fetching gem metadata from http://rubygems.org/.........
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 3.0.1) ruby depends on
bundler (~> 1.0.0) ruby
Current Bundler version:
bundler (1.1.3)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
I've tried uninstalling the bundler via
gem uninstall bundler -v 1.1.3
and then installing bundler v1.0.0 via
gem install bundler -v 1.0.0
but it seems to get me bundler 1.1.2..
I just feel like I've hit a dead end and can't find any more information on how to solve this issue.
Any help would be greatly appreciated and rewarded with copious amounts of bacon...
UPDATE UPDATE UPDATE
I couldn't get bundler v 1.1.2 to uninstall. I finally was able to uninstall all of the gems by doing:
sudo gem list | cut -d" " -f1 > gem_list.txt
cat gem_list.txt | xargs sudo gem uninstall -aIx
cat gem_list.txt | xargs sudo gem install
And then reinstalling... This allowed me to then do the 'bundle install' and get on track.. Thank you all for your help!
it is because gems are also installed in global gemset, and you can uninstall it using:
rvm #global do gem uninstall bundler
but you can also use the other version of bundler using:
gem install bundler -v '~>1.0.0'
bundle _1.0.0_ install
replace 1.0.0 with the version that got installed (if other)
First verify your versions to be sure they're all current:
$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
$ rails -v
Rails 3.2.2
$ gem list bundler
*** LOCAL GEMS ***
bundler (1.1.3)
If you need to update ruby, you can download it from https://www.ruby-lang.org or use tools like ruby-build. If you have any version of Ruby 1.9.3 that's fine for now.
To update all your gems:
gem update --system
gem update
Gem may install gems in a few different places, and these can interfere with each other. There are system gems (typically installed by root or by using sudo) and your personal user gems. My favorite way to manage these is with a simple tool called rbenv. A related tool is rvm. Either is fine.
For your first tutorial, you can skip using version numbers in your Gemfile:
- gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
+ gem 'sqlite3-ruby', :require => 'sqlite3'
Bundler will sort everything out the right way. Eventually you'll want to specify version numbers if you're coordinating with other developers, or building production systems.
Feel free to ask questions here and I'll add to this answer.
Maybe you had bundler 1.1.2 AND 1.1.3 installed on your machine (and possibly more versions)
use
gem list bundler
to check which version(s) of bundler you have installed.
Then remove the ones you don't want with
gem uninstall bundler -v VERSION_NUMBER
You can use latest version of Rails 3.0 (3.0.12). It supports the latest bundler, and isn't fundamentally different from 3.0.1
I had this problem and the source was a version specification for bundler in the .gemspec file:
spec.add_development_dependency "bundler", "~> 1.16"
Removing the version number solved the issue:
spec.add_development_dependency "bundler"
Bundler is a dependent gem of rails, because of which you can see it only in gemfile.lock instead of gemfile.
For a particular rails version only a range of bundler gems are compatible. I also got this error and I tried uninstalling that version of bundler gem which I didn't need. I also tried to install forcefully using bundle_x.x.x_install, but when things didn't work I explicitly mentioned the gem specifying the version falling within the range required by rails version I am using. May be it's not the right way but that is how things worked for me.
Sometimes to fix the issue mentioned in the title of this question it is enough to delete Gemfile.lock and run bundle update. I hope it will be helpful for someone.

Resources