I'm having touble installing rails on my new installation of Ubuntu 12.04 LTS. I have RVM and rubygems 2.2.2 installed but when I go to install rails I get an error;
anesu#ubuntu:~$ gem install rails
[sudo] password for anesu: #I enter my passsword here
ERROR: Error installing rails:
activesupport requires Ruby version >= 1.9.3.
anesu#ubuntu:~$ ruby -v
ruby 1.9.3p545 (2014-02-24 revision 45159) [x86_64-linux]
The ruby required is clearly installed. I've also tried
gem install rails #without sudo
but still get the same error. What could be the problem?
Do you have rvm in your path? If not, add the following line to your ~.bashrc file...
PATH=$PATH:$HOME/.rvm/bin
Be sure and open and close the terminal after you all this. At the terminal you should be able to type 'echo $PATH' and see RVM listed.
Related
I am trying to install Ruby on rails on a Mac Mojave:
$ brew install ruby
Warning: ruby 2.7.1 is already installed and up-to-date
To reinstall 2.7.1, run `brew reinstall ruby`
This shows me that I am running Ruby 2.7.1.
But when I check the version I get:
$ ruby --version
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
This tells me I am using Ruby 2.3.7.
I don't understand.
To run Rails I need >= 2.4.4 apparently:
$ sudo gem install rails
.....................
ERROR: Error installing rails:
zeitwerk requires Ruby version >= 2.4.4.
and
$ which ruby
/usr/local/opt/ruby/bin/ruby
So until I get ruby version to at least 2.4.4 I can't run rails.
Update
Install RVM on MAC as follows
$ brew install gpg
$ curl -L https://get.rvm.io | bash -s stable --autolibs=enabled --ruby
$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin18]
Got these instructions from:
https://null-byte.wonderhowto.com/how-to/mac-for-hackers-install-rvm-maintain-ruby-environments-macos-0174401/
But then I install Rails:
$ sudo gem install rails
Successfully installed rails-6.0.2.2
Parsing documentation for rails-6.0.2.2
Done installing documentation for rails after 0 seconds
1 gem installed
and so I tried to crate a Rails project:
$ rails new blah
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
What is going on there? I seem to have successfully installed Rails but cannot create a Rails project.
The output from this command brew install ruby is not telling you that you're running ruby 2.7.1. That just says you already have ruby 2.7.1 installed for brew. But you could have other ruby versions installed in other ways. When you do
ruby -v
ruby executable is looked for in paths listed inside your environment variable PATH, in order. You can see those paths with
echo $PATH
So, managing different versions of ruby is hard and version managers exist for this reason. I suggest you to install rvm
I want to use Rails with Ruby 2.1.0, but it's using Ruby 1.9.3 (the system's version).
I'm using rbenv to manage my Ruby versions. My steps were something along the lines of:
$ rbenv install 2.1.0
$ rbenv global 2.1.0
$ sudo gem install rails -v 4.0.2
$ rbenv rehash
$ rbenv versions
system
* 2.1.0 (set by /home/dennis/.rbenv/version)
$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
$ rails new app && cd app
$ rails server
Rails is using is Ruby 1.9.3 (x86_64-linux), according to localhost:3000/rails/info/properties. A log message from rails server gives: INFO ruby 1.9.3 (2012-04-20) [x86_64-linux].
I think Rails is using the system version of Ruby because the versions match.
$ rbenv local system
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
$ rbenv local --unset # Unset local Ruby version, go back to 2.1.0
Some things I've tried with no luck:
setting the local and shell versions of Ruby to 2.1.0 with rbenv
rehash rbenv shims (rbenv says to do this after installing executables)
made new Rails projects after switching to 2.1.0 just in case I made the projects while using 1.9.3
putting 2.1.0 in a .ruby-version file in the root of my project (suggested by #Agis)
restarting terminal session and starting a login bash shell (suggested by #Russel)
specifying the desired Ruby version in the project's Gemfile (suggested by #rlecaro2)
FWIW, I'm using Ubuntu 13.10 with the fish shell.
Sounds silly, but did you restart terminal session?
Otherwise try and type
/bin/bash --login
You didn't tell how you installed rbenv, but I think it is per-user installation (which is default). In this case you should install gems without using sudo. When you did sudo gem install rails, it was installed in system ruby, not rbenv's selected one.
Solution - install rails without sudo:
rbenv global 2.1.0
gem install rails
rbenv rehash
Try creating a .ruby-version file in the root of your project with the following contents:
2.1.0
I'm getting the next error installing RoR
How can I set the correct Ruby Version?
#####:path$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
#####:path$ sudo gem install rails
ERROR: Error installing rails:
activesupport requires Ruby version >= 1.9.3.
#####:path$
You shouldn't have to use sudo with gem install .... That's what's causing the mismatch between Ruby versions, since root is using the default installed Ruby, whereas your own account is using RVM's installed version.
Updating the system version of Ruby depends on your operating system, and usually lags behind the very latest version of Ruby. I've been using 2.0 for my latest project I launched last month. I doubt big OS vendors like Ubuntu or Apple are providing that version in their latest distribution. It's best that you manage your own Rubies whenever possible.
To install 1.9.3 you can run:
$ rvm install 1.9.3
then later
$ rvm use 1.9.3
You have :
###:path$ ruby -v
.....
###:path$ sudo gem install rails
...you said in your comment that :
$ sudo ruby -v
...gives you
ruby 1.8.7
To resolve this problem you shouldn't use sudo, as it tries to install using root session with 1.8.7 ruby version which is not supported.
To install rails just type the following without sudo:
$ gem install rails
...it should works as you've a supported ruby version (ruby 2.0.0p247)
You can check Install Ruby on Rails ยท Ubuntu Linux instructions (Which I found useful) if you've more troubles.
now,I want to install heroku to study rails deployment.
I execute the following code
sudo gem install heroku
but I get the error
ERROR: Error installing heroku:
rubyzip requires Ruby version >= 1.9.2.
then I execute the code:
ruby -v
I get the result
ruby 1.9.3p448 (2013-06-27 revision 41675) [i686-linux]
so it shows that my ruby version >= 1.9.2.
why I get this error.
You should install the heroku gem directly into the RVM environment and gemset you want to use it in:
gem install heroku
If you do not have RVM this is a linux command to install the heroku Toolbelt!
wget -qO- toolbelt.heroku.com/install-ubuntu.sh | sh
If you do not have a Ruby Version manager I would install one.
Install rvm
1)then rvm use 1.9.3 it will brings the ruby version 1.9.3
2)gem install heroku
I try to install skylinecms but I have a problem with installing the gem.
The gem factory_girl asked me to use version> = 1.9.2 of Ruby
atmoner#atmoner:~/base_ror$ sudo gem install skylinecms
ERROR: Error installing skylinecms:
factory_girl requires Ruby version >= 1.9.2.
ruby -v
atmoner#atmoner:~/base_ror$ ruby -v
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux]
I have tried to change ruby version to 1.9.2
atmoner#atmoner:~/base_ror$ rvm use 1.9.2
Using /home/atmoner/.rvm/gems/ruby-1.9.2-p320
But still same problem
atmoner#atmoner:~/base_ror$ sudo gem install skylinecms
ERROR: Error installing skylinecms:
factory_girl requires Ruby version >= 1.9.2.
what's the source of this problem?
you have an idea?
You shouldn't use sudo with rvm, as it creates a new subshell with a completely new environment. See more about sudo and rvm here: RVM and 'sudo'
Most likely your system ruby version is 1.8.7, and that is what is getting invoked when you run sudo gem install skylinecms. You can verify that with the following commands:
rvm use system
ruby -v
Try installing the skylinecms gem without sudo.
Best to use per-project gemsets as suggested in rvm best practices