have a existing Rails project, which was build on version 2.3.4.
On my local machine a have Rails version 3.0.3.
When a call rake db:migrate in the terminal, then the terminal replies following:
Missing the Rails 2.3.4 gem. Please gem install -v=2.3.4 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
A new created Project can be invoked by rake db:migrate
How can get running this project?
rake db:migrate loads up the rails environment, which loads up your gems, for which on this project rails 2.3.4 is used.
try using rvm to manage your projects, or you need to do gem install -v=2.3.4 rails to get this running. If that version is installed, rubygems will load it for you.
Related
I am configuring a Rails APP. I did bundle install properly. Also using ruby 1.8.7 using RVM. Now after bundle install, it is throwing the below given error while doing rails s.
/usr/local/lib/site_ruby/1.8/rubygems.rb:335:in `bin_path': can't find
executable rails for rails-3.2.9 (Gem::Exception)
Can anyone help me to sort out this?
Using ruby: 1.8.7
Rails Version: 3.0.3
After running bundle install, your Gemfile.lock has a list of all the gems and their versions that are needed.
However, you need to run bundle exec in order for bundler to make those gem versions available to you.
The rails script is an exception, as it invokes bundler for you, but it sounds like something isn't working in your environment.
Try executing the rails script using bundle exec like so:
bundle exec rails s
And see if that helps. Also, from the man who wrote bundler: http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/
You have two rails gem versions in same gemset so it is picking latest version. So you need to specify rails version for rails commands.
Try this:
$ rails _3.0.3_ server
I was working on a project just fine, logged off for the night and the next morning when I tried to start again I was getting this error:
Missing the Rails 2.3.12 gem. Please `gem install -v=2.3.12 rails`,
update your RAILS_GEM_VERSION setting in config/environment.rb
for the Rails version you do have installed, or comment out RAILS_GEM_VERSION
to use the latest version installed.
I did a gem list and it's definitely installed:
rails (3.1.0, 2.3.14, 2.3.12, 2.3.8)
I also made sure that 2.3.12 was the required Gem in the environment.rb:
RAILS_GEM_VERSION = '2.3.12' unless defined? RAILS_GEM_VERSION
Before I logged off I deployed my changes to demo, which was working fine, and when I checked it the next morning I was getting the same error message.
I'm still pretty new to RoR so I am not sure how to trouble shoot this.
I had this problem before and it was because I was defaulting to the system version of ruby. Run "ruby -v" in console and make sure you are using the version you want to. If you are not run this in the console:
$ rvm use "x"
Where "x" is the version of ruby you want to use.
Also, make sure your gemsets are in order. You can create and start using a new gemset by running this in the console ("xxx" = what you want to call your gemset):
$ rvm gemset create xxx
$ rvm gemset use xxx
After creating (and switching to) the gemset you can try reinstalling rails. Creating a new gemset means that there are no gems associated with whatever project you are working on anymore. So you will need to reinstall all your other gems too. Should be easy with a "bundle install"
Hope this helps.
I've got a Rails 2.3.5 app that I want to upgrade to Rails 3. In the Rails 3 upgrade Railscast, they suggest upgrading to 2.3.8 before going to 3. I've tried Googling but the information I find is all about upgrading to Rails 3. I found this question, which seems to suggest doing gem update rails and rake rails:update, but wouldn't these commands upgrade to Rails 3, as it's the latest version? How do I upgrade to Rails 2.3.8? Thanks for reading.
There's not much difference between 2.3.5 and 2.3.8 (also, 2.3.10 is the latest version on the 2.3 branch - you should upgrade to that).
Install Rails 2.3.10:
gem install rails -v=2.3.10
Then edit config/environment.rb and change your Rails version to 2.3.10 near the top of the file. Start up webrick, deal with any deprecation warnings it throws at you while you click through your app, and you're pretty much done.
Citation from the Rails blog:
"We’ve released Ruby on Rails 2.3.9
(gem and git tag) to extend the 2.3.8
bridge a few steps closer to Rails 3
and Ruby 1.9. If your app runs on
Rails 2.3.9 without deprecation
warnings, you’re looking good for an
upgrade to Rails 3."
Edit:
Jeremy is on the money. Don't install 2.3.9, it has a serious security flaw. I've updated my answer to 2.3.10.
You can run rake rails:update - this updates the stock javascripts and config files. However, they probably won't need to be changed from 2.3.5 to 2.3.10.
$ gem install rails -v 2.3.8
Then change the RAILS_VERSION in your environment.rb file and run
$ rake rails:update
I had Rails 2.3.5 installed, and wanted to upgrade to 2.3.10 as a stepping stone to Rails 3. I thought running gem install rails -v=2.3.10 would install 2.3.10 and keep 2.3.5 as well. But now when I do rails -v, it only lists Rails 2.3.10. How can I install different versions of Rails and keep the existing ones?
gem list rails should show you all installed versions of Rails. You can specify which one you want each project to use in the config/environment.rb file.
Alternately (or "additionally"), look in to RVM (particularly the "gemset" function) for maintaining separate gem sets for each project.
Updated May 2017 Instead of RVM gemsets, best practice for managing gems in Rails projects (including the Rails gem itself) is to use Bundler. Bundler's Gemfile will list all the gems your project uses, and allows you to "pin" versions, so by changing the version pin for Rails and running bundle you can update your project to the new version.
<sarcasm>Now that I've said that, though, Bundler is probably on the way out to be replaced by something else. </sarcasm>
You still have both versions, as the other answers have mentioned. However, you don't want to call rails newapp and then change the config/environment.rb file. This will cause problems for any files that have changed between versions. Instead, create a new 2.3.5 app this way:
rails _2.3.5_ newapp
And you'll run the exact version of rails you want, to create the file structure correctly. I don't know why this isn't documented better.
To answer your question, you can install many versions of the rails gem without conflict. However, each project is created using a specific version. To install a new version of the rails gem as follow;
Change the version 3.2.18 with any version you like (see link below for all available versions).
gem install rails --version=3.2.18
To install the latest version
gem install rails
To check all the rails version available, check out this link
Here is a link to all the version of rails
You might consider updating your gem software by this command prior to loading new gems.
gem update --system
As per #pjmorse, list the version installed with this command
gem list rails
Hope that helps
You can define the Rails version of an application in config/enviroment.rb.
You can vendor the version of rails you want into your vendor/rails folder. At the command line just run rake `rake rails:freeze:edge RELEASE=2.2.2'. You don't need any version of rails installed for this to work it will take the source and build it from the remote source in your vendor directory.
rake rails:freeze:edge RELEASE=2.2.1
rake rails:freeze:edge RELEASE=2.2.2
rake rails:freeze:edge RELEASE=2.2.3
rake rails:freeze:edge RELEASE=2.2.4
rake rails:freeze:edge RELEASE=2.2.5
rake rails:freeze:edge RELEASE=2.2.6
rake rails:freeze:edge RELEASE=2.2.7
rake rails:freeze:edge RELEASE=2.2.8
I've just upgraded my rails version to rails 3.0.
But suddenly I need a new rails app with old version of rails.
I know the new version of rails change command line usage with rails new.
How can I create an old version of Rails in this new Rails 3 environment?
Use the following command:
rails _2.3.5_ new APP_NAME
This will create a rails project with version 2.3.5
Leonid Shevtsov provided instructions for how to do this here.
The easiest way to do it was:
Create the directory for the project
Create a Gemfile there containing
gem "rails", "2.3.9"
gem "sqlite3-ruby", :require => "sqlite3"
Runbundle install
Run bundle exec rails . to create an app in the current path
You don't even need rvm to do this.
If you need to switch back and forth, I would recommend using RVM. You can install different versions of Ruby and each can have its own set of gems. I use my system installed ruby (1.8.6?) on my Mac for Rails 2 dev, and then I installed Ruby 1.9.2 with RVM for my Rails 3 dev. Its as simple as doing this after you have RVM installed:
#install and use 1.9.2 for Rails 3
rvm install 1.9.2
rvm 1.9.2
rails new whatever
#switch back to system installed ruby for Rails 2
rvm system
rails whatever