My machine has simply capped at ruby version 2.5, ruby -v outputs ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]. I have tried sudo apt update && sudo apt upgrade, and sudo apt-get install ruby-full, but non of which have seemed to work.
from: https://phoenixnap.com/kb/how-to-install-ruby-on-ubuntu-18-04
there are other ways, just visit the link to watch some of them
Example 2: By using rbenv
sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev
sudo apt install rbenv
echo 'export PATH="$HOME/ .rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init –)"' >> ~/.bashrc
rbenv install --list
and from the list select the one you want and install it
ex:
rbenv install rbx-2.7
I installed RVM on my Fedora 19 system a few months ago, and it was working fine. Then I had some other work and when I opened the machine again, it said:
# rvm
bash: rvm: command not found...
I tried to reinstall RVM, and this is what I get:
# rpm -i rvm-devel-1.17-8.fc19.x86_64.rpm
package rvm-devel-1.17-8.fc19.x86_64 is already installed
But I can't find it.
# ps ax | grep rvm
14363 pts/0 S+ 0:00 grep --color=auto rvm
Can anyone help me? What exactly is the problem?
P.S: The package rvm is there on the system.
# rpm -q rvm
rvm-1.17-8.fc19.x86_64
I recommend you to reinstall RVM, maybe it's crashed due to some event.
Use this command to implode it:
rvm implode
Or:
rm -rf ~/.rvm
Then install it by running:
sudo apt-get install curl
curl -L get.rvm.io | bash -s stable --auto
Then you'll need to reload the ~/.bash_profile file which you can do with this small command:
. ~/.bash_profile
Make sure to install other packages needed for Ruby to work:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
sudo apt-get install pkgconfig
Now install the latest Ruby:
rvm install 2.0.0
rvm use 2.0.0
ruby -v
Now you can install Rails:
gem install rails -v 4.0.0
the package rvm-devel-1.17-8.fc19.x86_64 is not rvm as per http://rpm.pbone.net/index.php3/stat/4/idpl/20537074/dir/fedora_19/com/rvm-devel-1.17-8.fc19.x86_64.rpm.html it is:
The rvm-devel package contains libraries and header files for
developing applications that use rvm.
Follow installation instructions http://rvm.io/rvm/install to get RVM installed, make sure to read the outputs as important hints might be printed for you.
to uninstall rvm use anyone of the following:
rvm implode
or
rm -rf ~/.rvm
Just to be sure restart the terminal before you try installing rvm again
I have successfully installed rvm, but when I run the following commands
sudo apt-get update
Or:
rvm install 2.0.0
I have the following errors:
W: Failed to fetch http://ppa.launchpad.net/cheleb/blender-svn/ubuntu/dists/precise/main/source/Sources 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/cheleb/blender-svn/ubuntu/dists/precise/main/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/cheleb/blender-svn/ubuntu/dists/precise/main/binary-i386/Packages 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/ferramroberto/oneiric/ubuntu/dists/precise/main/source/Sources 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/ferramroberto/oneiric/ubuntu/dists/precise/main/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/ferramroberto/oneiric/ubuntu/dists/precise/main/binary-i386/Packages 404 Not Found
How can I fix these errors?
follow below steps
sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p481.tar.gz
tar -xvzf ruby-2.0.0-p481.tar.gz
cd ruby-2.0.0-p481/
./configure --prefix=/usr/local
make
sudo make install
Use rvm to install stable ruby:
curl -sSL https://get.rvm.io | bash -s stable --ruby
or, if you have rvm already, get stable version:
rvm get stable
Install ruby and use the specific version of ruby (remember to use login shell)
/bin/bash --login
rvm install 2.0.0
rvm use 2.0.0
rvm rubygems latest
ruby --version
As found on the official RVM website.
EDIT:
As #prem points out run this at first and follow the above steps if there is a public key error
gpg --keyserver hkp://keys.gnupg.net --recv-keys \ 409B6B1796C275462A1703113804BB82D39DC0E3
Use rbenv to install ruby:
Install necessary dependancies:
sudo apt-get update && sudo apt-get install git-core curl zlib1g-dev \
build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev \
sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev \
python-software-properties libffi-dev
Install rbenv:
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
Install ruby:
rbenv install -v 2.0.0
From the travis-cli installation instructions for Ubuntu, the Brightbox Ruby NG(NextGeneration) ppa:
$ sudo apt-get install python-software-properties
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
$ sudo apt-get install ruby2.1 ruby-switch
$ sudo ruby-switch --set ruby2.1
Although this answer was accepted, I would strongly recommend using rvm rather. I had nothing but trouble trying to install ruby without it. See e.g. this guide:
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
Any easy way to install ruby is with ruby-install. I had compile errors when building ruby from scratch, but ruby-install encountered no such problems.
edit: I've had problems with rvm in the past, and feel I should actively recommend against this. That's just me personally, though. I've had okay luck with rbenv, but always use it in conjunction with ruby-install.
You have some ppa sources enabled that aren't available for your version of Ubuntu. Comment those out in your /etc/apt/sources.list , run sudo apt-get update , and you'll be fine.
Use rbenv
The first step is to install some dependencies for Ruby.
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
Installing with rbenv is a simple two step process. First you install rbenv, and then ruby-build:
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.0.0
rbenv global 2.0.0
ruby -v
The original post on gorails.com
I put #PravinMishra's source into a Gist and now you can simply use this one liner:
wget -O - https://git.io/vvkI4 | bash
NOTE: Don't trust my Gist blindly, download the file and look into it before you run it!
I've Base64 Encoded this Userdata script to be ran on initialization of a EC2 instance, but for some reason, it doesn't install RVM. I think it's do to a user issue, but i'm not sure.
I'm using the 12.10 default Ubuntu AMI.
#!/bin/bash
export LC_ALL=en_US.UTF-8
sudo apt-get --yes update
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
sudo apt-get --yes --fix-missing install mongodb language-pack-en ruby-full build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config tcptrack
\curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
source ~/.profile
rvm autolibs 3
rvm requirements
#source ~/.profile
rvm install 2.0.0-p0
rvm --default use 2.0.0
gem update --system
gem i mechanize peach mongo rails aws-sdk bson_ext httparty
I am configuring a new server for multiple rails 2.x/3.x projects, with multiple ruby versions 1.8.7/1.9.2 using RVM.
I want to know how to set a project to use particular version of ruby and another project to use another version of ruby?
Thanks,
Pravin
Assuming your project directories are:
/var/www/project1
/var/www/project2
Let's move to the multiple rails version management:
Run the below commands:
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 1.8.7
rvm use 1.8.7 --default
ruby -v
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
gem install rails
rails -v
Now change directory to:
$: var/www/project1 rails s
Move to second project:
$: var/www/project2
rvm install 1.9.1
rvm use 1.9.1 --default
gem install rails
and finally start rails:
$: var/www/project2 rails s -p 3003