rails version not found, even though it's available in the rubygems - ruby-on-rails

I wanted to switch from Rails 4.1.1 to Rails 3.2, because I heard some specific features I am interested in work best in 3.2.
gem install --http-proxy http://web-proxy:8088 rails –v '3.2.18' --no-rdoc --no-ri - this command didn't work, no such version (3.2.18) is available so rails 4.1.1 (most recent version) was (re)installed automatically.
Here is the reason:
Fetching: rails-4.1.1.gem (100%)
Successfully installed rails-4.1.1
ERROR: Could not find a valid gem 'ûv' (>= 0) in any repository
ERROR: Could not find a valid gem '3.2.18' (>= 0) in any repository
1 gem installed
So: I go to rubygems.org, check list of available rails versions and I see that 3.2.18 (https://rubygems.org/gems/rails/versions/3.2.18) is actually an available version. What am I doing wrong. Why is 3.2.18 not found, if it's on the rubygems site?
I really need Rails 3.2 to have an issue fixed that works poorer in newer Rails versions (according to research in the internet) - many thanks in advance

It seems like you copied and pasted parts of your command resulting to non ASCII characters.
In particular, the dash (-) seems to be the issue here. Try again with this:
gem install --http-proxy http://web-proxy:8088 rails -v '3.2.18' --no-rdoc --no-ri
The error message partly gives it away (at least it points to encoding issues) in Could not find a valid gem 'ûv' (>= 0).

First you uninstall latest rails version in your gem. Then install rails 3.2 in your local system and bundle it in your project terminal. And then edit in your gem file as
gem 'rails','~3.2'
now restart server and run it

Related

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

Cannot install state_machines gem in Windows environment

I am new to Rails and would like to check how Spree ecommerce solution looks like before the customization. That's why I installed Ruby from RubyInstaller, DevKit, Rails, Spree etc.
During installation of state_machines gem, below error appears and the gem is eventually not installed.
C:\>gem install state_machines
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument # rb_sysopen - C:/Dev/Ruby/lib/ruby/gems/2.1.0/gems/state_m
achines- 0.2.2/test/unit/node_collection/node_collection_after_being_copied_test.rb
This has impact on the bundle install of spree project later on:
Errno::EINVAL: Invalid argument # rb_sysopen - C:/Dev/Ruby/lib/ruby/gems/2.1.0/g
ems/state_machines-0.2.2/test/unit/node_collection/node_collection_after_being_c
opied_test.rb
An error occurred while installing state_machines (0.2.2), and Bundler cannot
continue.Make sure that `gem install state_machines -v '0.2.2'`
succeeds before bundling.
Current ruby version installed is:
ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32] + devkit
rails version is 4.2.0
I am running on Windows environment, without any possibility to move to Linux.
I ran into this too.
Looks like state_machines has some test case files that have a newline in the name.
I'd bet that is the cause of the issue.
I've submitted a pull request over here: https://github.com/state-machines/state_machines/pull/11
In the meantime, my branch doesn't have the issue: https://github.com/jeff-hamm/state_machines
The specific fix (for the moment, until the pullrequest is accepted) is:
git clone https://github.com/jeff-hamm/state_machines
cd state_machines
bundle gem state_machines
rake install
After doing that, 'gem install spree_core' worked just fine on windows.
Keep in mind I am not planning on keeping my branch up to date (I will delete it if the request is accepted), so, that clone url won't be ideal for long

downgrading rails 4 to 3.2

I have the Rails 4.0.0.beta1 installed but I need downgrade to Rails 3.2.13.
I've used gem install rails 3.2 but Rails continues as 4.0.0.beta1.
I searched existing doubts and try to follow the answers however none worked for me.
Think this is a simple doubt and I need to solve.
This answer my question: How to set default rails version for a project?
You have the same problem as listed here.
Here is what worked for me, and should also for you. It's a more general solution that works regardless of your specific version of the Rails beta. Please note that in order to shift back to 3.2.13 (or whatever version you'd like to go back to), you must remove Railties as well as Rails.
Just do:
gem uninstall rails
Then, select the version of Rails 4 you have and delete it.
Then, do:
gem uninstall railties
And do the same thing.
When I uninstalled the Rails 4 version of railties, it told me that dependencies for a couple gems (coffee-rails and sass-rails) wouldn't be met. So I just did the same thing with both of them as I did above, and deleted their Rails 4 versions as well (for example, for sass-rails, I had a version installed called sass-rails-4.0.0.rc1).
And done! The terminal should list 3.2.13 as your current Rails version.
Unless you're using bundle exec, Rubygems will always use the latest installed version of a gem. You need to uninstall the version you don't want.
gem uninstall rails --version 4.0.0.beta1
The answers to gem uninstall rails --version xxx should remove the rails gem just fine.
However, in the event you want or need to have multiple versions of rails available simultaneously, you can use bundler to load the correct versions of gems (as intended).
$ bundle exec rails in the project directory that lists the version of rails in the Gemfile should let you load the required gems without conflict.
Additionally, rvm and its gemset feature could also let you accomplish the same goal without needing to wrap everything with a bundle exec
Rails will use the version specified in Gemfile:
gem "rails", "4.0.0.beta1"
Replace it with the version you'd like to use instead:
gem "rails", "~> 3.2.0"
Of course, you will also need to change your code and config to use the old Rails API.
I had the same problem with Rails 4.0.0 final version. To check what is currently installed you can run the following:
>pik gem list
Then I checked the rails versions. It showed rails 3.2.14 (what I wanted) with railties 4.0.0, 4.0.0.rc2 and 3.2.14.
I then ran
>gem uninstall railties
and uninstalled all other versions except 3.2.14 and now it works well. The problem was that when Rails 3.2 installation is called, the latest (or all) versions of railties is installed.
If you have other versions of rails other tan the one you want, you can removed them with
>gem uninstall rails
and remove the versions of rails you do not want to have.
Try the following in your console. It will update or install rails to the specified version.
gem update rails 3.2.13

(MacOSx) Earlier version Rails2.3.8, i installed Rails3.2.0 but i still not able to access new version of Rails. Please help me fix it

Parsing documentation for bundler-1.3.2
Installing ri documentation for bundler-1.3.2
Parsing documentation for rails-3.2.12
Installing ri documentation for rails-3.2.12
Done installing documentation for i18n, multi_json, activesupport, builder, activemodel, rack, rack-cache, rack-test, journey, hike, tilt, sprockets, erubis, actionpack, arel, tzinfo, activerecord, activeresource, mime-types, polyglot, treetop, mail, actionmailer, rack-ssl, thor, rdoc, railties, bundler, rails (58 sec).
29 gems installed
204-252:~ narendra$ rails -v
Rails 2.3.8
204-252:~ narendra$ gem update rails
Updating installed gems**strong text**
Nothing to update
If you're using rbenv you can try running rbenv rehash after updating rails.
If you're in a rails project folder that was built with Rails 2.3.8 then when you run rails -v in that folder it will return that version of rails instead of the latest one. So you could try moving to another folder and see if running rails -v gives you the version you're expecting.
Also, if you installed rails with sudo gem install rails sometimes /usr/bin/rails still points to the old version, so you could update that to point to the new one.
Since rails 3.2.12 is not included in the output of gem list, I suspect you installed the gem with sudo. Installing with sudo and then trying to list the gems without it (or other operations) can give you a different list. Try doing sudo gem list, and if rails 3.2.12 is in there, thats your problem. Try installing it without sudo.

update to rails 3 on ubuntu

Hopefully this is an easy one - I'm trying to install rails on my netbook. I can#'t seem to get it to update to rails 3 (seems stuck on 2.3.5). Here's some terminal output to show you what I mean...
mike#Ubuntu-Netbook:~$ rails -v
Rails 2.3.5
mike#Ubuntu-Netbook:~$ gem update rails
Updating installed gems
Nothing to update
mike#Ubuntu-Netbook:~$ sudo gem install rails
[sudo] password for mike:
Successfully installed rails-3.1.0
1 gem installed
Installing ri documentation for rails-3.1.0...
file 'lib' not found
Installing RDoc documentation for rails-3.1.0...
file 'lib' not found
mike#Ubuntu-Netbook:~$ rails -v
Rails 2.3.5
See? Stuck at 2.3.5! I have done a whole bunch of rails installs on other machines and never had this problem before - what am I missing?
The 2.3.5 install is completely working.
EDIT: I did not get an answer to this question. I got around it by investigating rvm and installing that way instead.
Are you using bundler? Are you in an rvm gemset?
If you're using the latter, once you sudo, you're in a different user's rvm install, so installation won't be the same. If you're using bundler and have locked rails to 2.3.5, that's what it'll be regardless whether you run gem update or not.
If you can answer the above two questions, we can probably narrow down your issue.

Resources