After installing RVM, I have installed Ruby 1.8.7 then Rails 3.
When I do which rails I get /Users/davidbenhamou/.rvm/gems/ruby-1.8.7-p302/bin/rails.
But when I do rails -v I get -bash: /usr/bin/rails: No such file or directory
Why is Rails not working?
Note: I have followed all steps from RVM website and Ruby command line work fine (ruby -v).
To see the rubies you have installed:
rvm list rubies
And you'll see something like this:
ree-1.8.7-2011.03 [ i686 ]
* ruby-1.9.2-p290 [ x86_64 ]
ruby-1.9.3-p0 [ x86_64 ]
=> ruby-1.9.3-p125 [ x86_64 ]
ruby-1.9.3-p125-perf [ x86_64 ]
To use a specific one:
rvm use ruby-1.9.3-p125
then if you do ruby --version, you'll see:
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.7.0]
In each of these rubies you need to install all the gems you want to use. The way I do it is actually by using Bundler to install all the gems for a project. But for the simple case here, just do:
rvm all do gem install rails
This will install the rails gem in all your ruby versions. To install to a particular one, use:
rvm ruby-1.9.3-p125 do gem install rails
after you installed RVM and after you set the default Ruby version in RVM, you need to re-install all ruby gems, e.g.
gem install rails
you need to install those gems as the user, not as root.
Because from now on RVM will keep track of all installed gems by the ruby version which was used to install them!
Related
How do I uninstall the old ruby versions and how do can I update to GemFile to 2.4.2?
Sandys-MacBook-Pro:roughhouse-web sandychow$ bundle install
Your Ruby version is 2.4.2, but your Gemfile specified 2.2.5
Sandys-MacBook-Pro:roughhouse-web sandychow$ rvm list
rvm rubies
ruby-2.1.5 [ missing bin/ruby ]
ruby-2.2.5 [ missing bin/ruby ]
* ruby-2.4.1 [ x86_64 ]
=> ruby-2.4.2 [ x86_64 ]
To specify a Ruby version in your Gemfile, simply include the version towards the top:
For Ruby 2.4.2, you can do this:
# Gemfile
source "https://rubygems.org"
ruby "2.4.2"
# ... your gems on the following lines ...
If you want to uninstall a Ruby version, execute:
$ rvm uninstall <version_number>
So to uninstall version 2.2.5, execute:
$ rvm uninstall 2.2.5
Note: don't include the $ sign. That's just there to represent your terminal window.
More information on specifying Ruby versions in your Gemfile can be found at these links:
Heroku - Ruby versions
Coderwall
If you still experience issues, you may need to install or update bundler:
$ gem install bundler
or
$ gem update bundler
As your Gemfile specified ruby 2.2.5 and your rvm ruby version is 2.4.2, you can simply update the project gems bundle to fix the issue by doing
bundle update
This will update all the gems in your Gemfile file to get compatible with your current ruby version.
I have this
# Gemfile
source 'https://rubygems.org'
ruby '2.1.5'
and
#.ruby-version
2.1.5
and this
$ rvm list
rvm rubies
ruby-1.9.3-p484 [ x86_64 ]
ruby-2.0.0-p451 [ x86_64 ]
ruby-2.1.0 [ x86_64 ]
ruby-2.1.1 [ x86_64 ]
ruby-2.1.2 [ x86_64 ]
ruby-2.1.3 [ x86_64 ]
* ruby-2.1.5 [ x86_64 ]
And yet I keep getting this:
$ rails s
Your Ruby version is 2.1.2, but your Gemfile specified 2.1.5
Ruby 2.1.5 is installed.
Already installed ruby-2.1.5.
To reinstall use:
rvm reinstall ruby-2.1.5
ruby - v
ruby 2.1.2p95
$ rvm use --default 2.1.5
Using /home/alex/.rvm/gems/ruby-2.1.5
But then when I open a new tab or terminal, it reverts back to 2.1.2
ruby - v
ruby 2.1.2p95
If you want to use the ruby version just for now , you can choose it by
rvm use 2.1.5
And if you want to always be on that version of ruby just type
rvm --default use 2.1.5
Your error clearly indicate that you do have another method in your code which setting default ruby-2.1.2 also.
There must be some other file than .ruby-version which setting your default ruby version. Due to which your .ruby-version file not setting default version for you nor your Gemfile.
Look into your application root directory and try find hidden file like .rvmrc or .ruby-version or similar try update or delete that file and then run rails s.
After update or delete don't forgot to reopen your application directory. (cd .. and cd /app_directory) Otherwise it won't affect changes.
I was following along with the directions here under the section Rails Installation With RVM Gemsets
Per the directions above I created a new rvm gemset:
$ rvm use ruby-2.2.1#rails4.2.1 --create
$ gem install rails
The rails installation was successful, running
$ rails -v
returns rails version 4.2.1 as expected.
Next I ran
$ rvm list
it returns my list of gemsets as:
rvm rubies
ruby-2.0.0-p247 [ x86_64 ]
ruby-2.0.0-p598 [ x86_64 ]
ruby-2.1.1 [ x86_64 ]
=* ruby-2.2.1 [ x86_64 ]
Why isn't ruby-2.2.1#rails4.2.1 one of my gemsets? I thought I was specifically creating a ruby 2.2.1 gemset with rails 4.2.1, which would then also allow me to keep a separate ruby 2.2.1 gemset with previous versions of rails?
rvm list shows the list of Ruby versions installed, not the gemsets. Try rvm gemset list to see a list of the gemsets.
I'm developing two different projects: one using ruby-1.9.3 and another using ruby-2.0.0 (the version of Rails changes too). I was developing the 2º project and now I'm coming back to the 1º (ruby 1.9.3), but I'm having some troubles.
Before start explain my problem, this is the result when I run rvm list:
rvm rubies
=> ruby-1.9.3-p484 [ i686 ]
* ruby-2.0.0-p353 [ i686 ]
# => - current
# =* - current && default
# * - default
If I run ruby -v I got:
ruby 1.9.3p484 (2013-11-22 revision 43786) [i686-linux]
And you can find in my gemfile of the first project:
ruby '1.9.3'
gem 'rails', '3.2.3'
My problem is: I can't run the server and download/install the gems. When I try to run rails s in my first project I get:
Could not find rake-10.1.0 in any of the sources
Run `bundle install` to install missing gems.
And when I try to run sudo bundle install I get:
Your Ruby version is 2.0.0, but your Gemfile specified 1.9.3
But you saw above that my gemfile specify 'ruby-1.9.3', not 'ruby-2.0.0'. What can I do to start work hard in my old project?
I'm guessing that there is some conflict between the native ruby installation and the RVM installation.
I recommend you try this:
$ cd /path/to/ruby-1.9.3/project1
$ rvm use 1.9.3
$ rvm gemset create project1
$ rvm gemset use project1
$ bundle install
I installed Ruby 1.9.2. I used rvm use 1.9.2 and then when I type ruby -v it says 1.9.2. Then when I quit terminal and reopen it, it says 1.8.7 again.
What am I doing wrong?
Your default ruby is most likely not set to ruby 1.9.2. Try:
rvm --default use 1.9.2
Also if you want to see all ruby versions installed, you can run 'rvm list'. The default ruby is prefixed with a => symbol, as shown below.
$ rvm list
rvm rubies
ruby-1.9.1-p243 [ x86_64 ]
=> ruby-1.9.2-p136 [ x86_64 ]
ruby-1.9.2-p180 [ x86_64 ]
Once you switch over using rvm --default use 1.9.2, be sure to check your gem list. Once you switch over, your gem list will be almost empty.
Additionally, you can check to see more information regarding what version of ruby and gemset you're using with the command rvm info.
If it is in fact empty, simply install rails with the command gem install rails. Be sure to not use sudo with this command.