I accidentally changed my rails version to 4.0.0. I've tried gem uninstall rails --version=4.0.0.rc1 and install version 3.2.13 but when rails -v it's still version 4.0.0. I then tried gem uninstall rails, which gives me "Successfully uninstalled rails-3.2.13". Thought this was easy to do, but I can't find a simple solution.
Try this:
rvm use <ruby version>
You can also check your installed ruby versions using rvm list and then switch over. Then do:
rvm gemset create rails3.2.13
rvm <ruby version>#rails3.2.13
gem install rails --version=3.2.13
Remove your Gemfile.lock and install rails again. Make sure you specify the version of Rails.
source 'http://production.cf.rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.13'
Related
I want to change ruby 2.3.5 line in gemfile to ruby 2.4.2
but i did not know how?
inside your working folder there is file .ruby-version, change the content from 2.3.5 to 2.4.2 and then run steps below, if you working with rbenv
gem install bundler
rbenv rehash
ruby -v
# make sure it said 2.4.2
bundle install
Just open your Gemfile in a text editor and change the
ruby '2.3.5'
to
ruby '2.4.2'
You need to open your Gemfile and update ruby version ruby '2.4.2' Then you will need to go to terminal and install that version if not already installed. Use rvm use 2.4.3 (if you are using rvm) command to select 2.4.3 version.
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 previously installed rails with the preinstalled ruby that comes with mac. I have recently installed ruby through rvm.
I then did
rails -v
and got the following error
kingsosina$ rails -v
/Library/Ruby/Site/2.0.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'railties' (>= 0) among 5 total gem(s) (Gem::LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/dependency.rb:309:in `to_spec'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/bin/rails:22:in `<main>'
What has gone wrong here? Do I need to gem install rails again?
my lastest output
kingsosina$ which ruby
/Users/kingsosina/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
kingsosina$ which rails
/Users/kingsosina/.rvm/gems/ruby-2.0.0-p353/bin/rails
kingsosina$ which gem
/Users/kingsosina/.rvm/rubies/ruby-2.0.0-p353/bin/gem
kingsosina$
Does everything seem ok? and how does terminal know to reference this version of ruby instead of the pre-installed version on the mac, when i do ruby -v?
For what it's worth, the paths shown in your error output indicate that you're still referencing the OSX version of ruby. You'll want to enter the directory and type
rvm use X.X.X-pXXX
where X.X.X-pXXX is the ruby version that you want rvm to use. You can also add a file called .ruby-version with X.X.X-pXXX in it and rvm and other ruby version managers will switch to the appropriate version for you. Adding a .ruby-gemset file will also switch to the appropriate set of gems.
Finally, you'll need to make sure that the gems are installed in the rvm ruby/gemset combination. Putting that all together, to get started with the latest ruby and latest rails gem you would...
rvm install 2.0.0
rvm use 2.0.0
rvm gemset use --create my-project-gems
gem install rails
Did you install newer version of ruby along with the rvm install? Do rvm list to find out what rubies your have installed. Then do rvm use <ruby-version-here> to select a ruby with rvm. Then you need to gem install rails again because its a new ruby. If you get a permission denied error trying to install gems try rvmsudo gem install rails.
I had already installed rails 1.8.7, forgot about it, then installed 1.9.3 through RVM. I was getting weird errors, so I purged my Mac of the system version of Ruby and started again using RVM. So far I've
Installed Ruby:
rvm reinstall 1.9.3-p0
which ruby
/Users/User/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
Manually setup Rubygems
which gem
/Users/User/.rvm/rubies/ruby-1.9.3-p0/bin/gem
Tried to install rails
sudo gem install rails
Successfully installed rails-3.2.1
1 gem installed
gem list
rails (3.2.1, 3.2.0)
It says rails is installed, but which gem does not work, and when I try to use rails new I get:
-bash: rails: command not found
I'm definitely missing something here. The only explanation I can think of is that there are remnants of a previous ruby or rails install that's causing problems. Is there a way to start completely from scratch?
If you are using RVM, you should not use "sudo" when you install gems. That will install gems to your system ruby version (not on the RVM rubies).
First, set up default rvm ruby like
rvm use ruby-1.9.3-p0 --default
Then, install rails on it by running:
gem install rails -v=3.2.1
It's actually better to use gemsets so you can have different gems set for the same ruby version. Check here for more info.