This is what I have done:
gem uninstall rails
gem uninstall railties
gem install rails 3.2
And terminal shows this code:
Done installing documentation for rails, railties after 1189 seconds
ERROR: Could not find a valid gem '3.2' (>= 0) in any repository
2 gems installed
weare138#mycomp:~$ rails -v
Rails 4.1.5
How to fix it?
You are missing the -v flag so rubygems is thinking that 3.2 is the name of a different gem and you are installing the current version (4.1.5). Instead try:
gem install rails -v 3.2.19
You should not need to remove up-to-date versions as you can specify the older rails version when starting a project with:
rails _3.2.19_ new myapp
If you are using RVM, create a new gemset
rvm gemset create <name>
Then you can switch to that gemset using
rvm use 1.9.3#<name> #assuming your ruby version is 1.9.3
That gives a clean gemset you can install Rails 3.2 to. Maintain multiple gemsets and switch between them
Related
I attempt to upgrade to Rails 5.1.4. Seems to update without an issue, however, a version check still shows 5.0.4. Any ideas?
Ruby Version:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
Terminal Output:
$ rails -v
Rails 5.0.4
$ gem install rails --version=5.1.4
Successfully installed rails-5.1.4
Parsing documentation for rails-5.1.4
Done installing documentation for rails after 0 seconds
1 gem installed
$ rails -v
Rails 5.0.4
Uninstall all versions of rails installed in your system by:
gem uninstall rails
It should prompt you with something like below
Select gem to uninstall:
1. rails-4.2.6
2. rails-5.1.4
3. All versions
Choose Option "All Versions" and uninstall all
Install the desired rails version:
gem install rails --version=5.1.4
rails -v
5.1.4
Update: Since you mentioned using bundle install, check if rails is specified with 5.1.4 in your Gemfile or not.
Sometimes, i met this problem, because you have two versions of rails in your railties. You can do this
gem uninstall railties
Select gem to uninstall:
1. railties-5.1.4
2. railties-5.0.4
3. All versions
Type 3 to remove all, then you can reinstall rails 5.1.4 again.
Either use
bin/rails -v
or
bundle exec rails -v
to select the version of rails specified in your Gemfile
Or do what I do and install https://direnv.net/ and add a .envrc file to the project. Then when you cd to that project, the path will be updated appropriately and rails -v will work as expected:
PATH_add "./bin"
What gives?
I typed this in gem install rails -v 4.2.2
After that, I tried rails -v, and it keeps coming out Rails 3.2.13
Why is this?
My ruby version after ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
You can manage gems with bundler (http://bundler.io/)
Put this on your Gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.2'
gem install bundler
and then
bundle install
bundle exec rails -v
If you still working without bundler, you can make
gem list
look at your rails version and then uninstall older versions
gem uninstall rails --version 3.2.13
and then
rails -v
I've encountered this before. And this is what I did.
Change version of rails
Just change the versions.
If you have multiple versions of Rails installed, you'll get conflicting information like this.
If you need to run a command with a specific version of Rails, you can specify the version as part of the command, eg.
rails _4.2.2_ -v
That will tell you you are using Rails 4.2.
Once you've created a new app by doing something like rails _4.2.2_ new app_name, then the Gemfile for that app will specify Rails 4.2.2 and you can drop the special prefix.
Hi i'm new to ruby on rails
I have 3 ruby version in my computer.
In a project i had to use rails 3.2.1 and ruby 1.9.2
So I switched using rvm use 1.9.2 in terminal. But after that my rails commands are not detected.
$ rails g model abc
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Why is this happening? And how to solve this?
You may need to differentiate your gem set that contains that specific version of rails from the old ones.
rvm use 1.9.2#new_gem_set_of_yours --create --default
And then retry installing the 3.2.1 rails
gem install rails --version 3.2.1
Or specify the new rails version in your Gemfile and let Bundler take care of it
gem 'rails', '3.2.1'
and run bundle install.
Type in your terminal
gem install rails -v 3.2.1
if it does not work, first try
rvm install 1.9.3
then
rvm rubygems current
and repeat.
I want to create a new rails app in 3.0.10 but the latest rails in my machine is 3.1.3. If I run:
gem list rails
Then I get the following output:
*** LOCAL GEMS ***
rails (3.1.3, 3.0.11, 3.0.10, 3.0.9, 3.0.7, 3.0.6, 3.0.4.rc1)
rails3-jquery-autocomplete (1.0.5)
Now I have applications in both 3.1 and 3.0 so I don't want to remove 3.1. How can I create this new rails app in 3.0.10?
To create a rails application for a specific version you can use this syntax:
$rails _3.0.10_ new appname
NOTE: The underscores are needed.
You should definitely use RVM (ruby version manager), to use different versions of rails can be reached easily:
rvm gemset create rails3
rvm gemset create rails3.2
rvm gemset create rails3.1
then, to you should use on of them to create rails project
rvm gemset use rails3 && gem install rails -v 3.0.10
rvm gemset use rails3.2 && gem install rails -v 3.2.2
rvm gemset use rails3.1 && gem install rails -v 3.1
I just installed RoR 3 with sudo gem install rails. I tried this multiple times, but every time I run $ rails I get an error and I hate it:
imac:~ rsonic$ rails
/Users/rsonic/.gem/ruby/1.8/bin/rails:19:in `load': no such file to load -- rails (LoadError)
from /Users/rsonic/.gem/ruby/1.8/bin/rails:19
How can I fix this? I want to use Rails again!
1.Install rvm(Ruby version manager)
sudo gem install rvm
2.Go to install path of rvm and do
rvm-install
3.Check if the install was successful by running
rvm
4.Check for current version of ruby
ruby -v
5.Install ruby 1.9.2 using rvm
rvm install 1.9.2
6.User ruby 1.9.2 with the help of rvm do
rvm 1.9.2
(you can switch back to system's default ruby version by running command >rvm system)
7.Install gems using rvm do
rvm gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
This will install gems locally for ruby1.9.2 without touchin the sytem ruby
8.Install RAILS3 beta release
rvm gem install rails --pre
9.Install railties which are required for RAILS3
rvm gem install railties --pre
10.For generating a new app with RAILS3 skeleton now do
rails myapp
Note all ruby script/ commands have changed to rails *
e.g: RAILS<3
ruby script/server -p 3004
RAILS3
rails server -p 3004
Hope it helps...