How to update ruby linux

How to change ruby version

Ruby 1.8 and 1.9 are installed in my Ubuntu machine. I’ve just installed Ruby 2.0.0 from ppa:brightbox/ruby-ng-experimental to install a bundle which requires 2.0.0. Now all 1.8, 1.9 and 2.0 are installed though I can’t tell bundle to use 2.0:

$ bundle install $ Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0 
$ rvm 2.0 $ ruby-2.0.0-p451 is not installed. $ To install do: 'rvm install ruby-2.0.0-p451' 
$ rbenv global 2.0.0-p451 $ rbenv: version `2.0.0-p451' not installed 

@МалъСкрылевъ That’t not an option. I already installed Ruby 2.0 from PPA and I want to use that one.

Do you have both rbenv and RVM installed? If so, don’t do that, pick one or the other. Using both will make you crazy. If you installed Ruby v2.0 outside of rbenv or RVM, you’ll have to manually manage it because neither sandbox tool will know about v2.0, nor can they help you switch to it. You should either work within one of them, or delete them all and do it all manually because you’re going to get your system quite confused in no time.

4 Answers 4

There is lots of advise in the comments to your question, some of it is advanced-ish rbenv or rvm usage.

My advice: Decide on how to manage multiple rubies — either use your OS package manager (in your case the apt-get /PPA stuff) OR rvm OR rbenv.

For the OS package manager, there should be a way to call ruby with version explicitely (e.g. /usr/bin/ruby1.9.3 ), or research on and call update-alternative . As bundler comes with a gem, you might get the interpreters confused here.

For rvm, change ruby version with rvm use 2.5.1 (once it is installed).

For rbenv I actually do not know but it should be trivial, too (and people are happy with it; it just happens that I tried rvm first and it worked like a charm, never evaluated rbenv).

I usually install one «system» ruby (apt-get install ruby1.9.3) and use rvm afterwards. You can still switch to the packaged «production» ruby with rvm use system .

Update 2017: Most distros ship with a ruby version installed already, so you probably don’t have to install it manually. Run ruby -v or which ruby to see if a ruby interpreter is already installed.

In your case I would probably deinstall all system rubys ( apt-get purge . ), remove the PPAs, remove your ~/.rvm and rbenv and start from scratch (install packaged stable ruby, then rvm and use rvm (r.g. rvm install 2.3.1 ) from there on).

Читайте также:  Приложения adobe на linux

Источник

How To Update Ruby Version In Ubuntu

Team Tutorials

Ruby is a popular programming language used by many developers around the world. In this blog post, we will walk through the process of updating your Ruby version on an Ubuntu system. This will ensure that you are using the latest and most secure version of Ruby, as well as provide you with access to new features and enhancements. Let’s get started!

Prerequisites

Before we begin, make sure that you have a working installation of Ruby on your Ubuntu system. You can check the current version of Ruby by running the following command in your terminal:

Step 1: Install RVM (Ruby Version Manager)

RVM is a command-line tool that allows you to manage multiple Ruby versions on your system. To install RVM, open a terminal window and run the following command:

curl -sSL https://get.rvm.io | bash -s stable --ruby

This command will download and install RVM along with the latest stable version of Ruby. Once the installation is complete, load RVM into your current shell session using the following command:

Step 2: Update Ruby

Now that RVM is installed, you can update Ruby to the latest version. First, list all the available Ruby versions with the following command:

This will display a list of all the known Ruby versions. Find the latest version and install it using the following command (replace “x.x.x” with the desired version number):

Once the installation is complete, you can set the newly installed version as the default Ruby version for your system using the following command:

Replace “x.x.x” with the version number you previously installed. To confirm that the update was successful, check the Ruby version again in your terminal:

This should now display the updated Ruby version.

Step 3: Update RubyGems and Install Bundler

After updating Ruby, it is a good idea to also update RubyGems, the package manager for Ruby. To do this, run the following command:

Finally, install Bundler, a dependency manager for Ruby projects, by running the following command:

Conclusion

Congratulations! You have successfully updated your Ruby version on your Ubuntu system. With this updated version, you can now enjoy the latest features, improvements, and security updates that Ruby has to offer. Remember to regularly check for updates to keep your system up-to-date and secure.

Disclaimer

This site earns money from ads and affiliate links. If you click on a link to a product we may make a small commission on your purchase. Thanks for supporting us.

Источник

How do I install the latest version of ruby in Ubuntu?

I currently have ruby version 1.8.2 in my machine and I would like to upgrade it to 1.9.2. How am i supposed to do it?

Which version of ubuntu are you running? I am running 11.04 and Ruby 1.9.1 is available in Synaptic package manager.

Читайте также:  Linux принтер нет доступа

8 Answers 8

I use Ubuntu, and I’ve found the easiest way to install newer versions of Ruby is to use rvm.

Basically, it installs different versions of Ruby locally for the user and updates environment variables for Ruby and gems based on which version you decide to use.

jim@schubert:~$ rvm use system Now using system ruby. jim@schubert:~$ ruby -v ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux] jim@schubert:~$ gem -v 1.3.7 jim@schubert:~$ rvm use 1.9.2 Using /home/jim/.rvm/gems/ruby-1.9.2-p180 jim@schubert:~$ ruby -v ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux] jim@schubert:~$ gem -v 1.5.2 jim@schubert:~$ 

I don’t like having RVM on production server, so I usually install ruby from source with an install script like this:

#!/bin/bash tmp_dir="/tmp" version="2.2.3" minor_version="2.2" ruby_version="ruby-$version" echo "*******************" echo "* Installing Ruby *" echo "*******************" sudo apt-get install -y autoconf build-essential libreadline-dev libssl-dev libyaml-dev zlib1g-dev libffi-dev mkdir -p "$tmp_dir" cd "$tmp_dir" wget "http://cache.ruby-lang.org/pub/ruby/$minor_version/$ruby_version.tar.gz" tar -xvzf $ruby_version.tar.gz cd $ruby_version ./configure --disable-install-doc make --jobs `nproc` sudo make install cd .. rm $ruby_version.tar.gz rm -rf $ruby_version echo "*******************" echo "* Ruby installed! *" echo "*******************" 

Источник

How to update ruby on linux (ubuntu)?

I’m newbie on both ruby and linux, so I’m sure this is trivial but I don’t know yet. I currently have ruby 1.8.7 installed and I want to update it to ruby 1.9. How can I do that?

9 Answers 9

sudo apt-get install ruby1.9 

You can find what libraries are available to install by

So I just did apt-cache search ruby | grep 9 to find it.

You’ll probably need to invoke the new Ruby as ruby1.9 , because Ubuntu will probably default to 1.8 if you just type ruby .

There’s really no reason to remove ruby1-8, unless someone else knows better. Execute the commands below to install 1.9 and then link ruby to point to the new version.

sudo apt-get install ruby1-9 rubygems1-9 sudo ln -sf /usr/bin/ruby1-9 /usr/bin/ruby 

Actually, you shouldn’t edit the links yourself, you should you the commands: sudo update-alternatives —config gem and sudo update-alternatives —config ruby. I suggest that this answer be edited!

On Ubuntu 12.04 (Precise Pangolin), I got this working with the following command:

sudo apt-get install ruby1.9.1 sudo apt-get install ruby1.9.3 

Ruby is v2.0 now. Programs like Jekyll (and I am sure many others) require it. I just ran:

sudo apt-get install ruby2.0

@MincongHuang I think Debian’s (and Ubuntu) default Ruby version is now 2.1 (wiki.debian.org/Ruby); with rvm you don’t have to wait for the package managers.

The author of this article claims that it would be best to avoid installing Ruby from the local packet manager, but to use RVM instead.

You can easily switch between different Ruby versions:

If you don’t need multiple versions (e.g. a production machine) then it’s best to avoid RVM and just use ruby-build.

After a year of Ruby I must say RVM was the best choice I could have made. On Christmas 2013 I updated to Ruby 2.1 seamlessly. It is really a well-crafted tool

Читайте также:  Midnight commander linux запустить

Raspbian: tried one other manager before using RVM (mainly because I couldn’t find the source code for RVM and the copyright on the website made it look like the project look dead). The other one failed to compile stuff, so I gave rvm a second try , and it worked a lot better. It also installed some of the missing packages I needed for the compilation. Works like a charm on distros without a decently updated apt repo

Источник

How to install the latest version of Ruby and Ruby on Rails in Ubuntu?

What happens if you do «which ruby», does it show as being installed? Does «ruby -v» show the right version number?

I’m a little confused by your update. If you want to install rails please use RVM — rvm.beginrescueend.com — to install rails and any other gems. It is a package manager and will save you a lot of time.

2 Answers 2

How to get a current Ruby version without messing up your system

Do not mess with your system Ruby, but instead install a current version with either rbenv or RVM. I prefer the first, but both work fine. Note that you can only install one of those at a time.

With such a Ruby version manager, you’ll never have to type sudo again to install (or uninstall) a Gem, and you can keep different versions for different projects. You can safely remove these versions again.

Please make sure to read the README s of those tools, at least once.

Method 1 – rbenv

rbenv is a version manager for Ruby. It allows you to install a Ruby version alongside your original system Ruby, which means you cannot mess up that one, and you can easily upgrade versions.

To install it, use the rbenv-installer . Make sure to restart your shell once it’s installed, and that the rbenv function works.

Then, once rbenv is installed, run rbenv install -l . This gives you a list of available Rubies. Install your chosen one with:

Now choose this one as your default:

As soon as this is done, gem can be used to run:

If the above does not work, you might be missing required packages for building from source. See here for a list of packages that you might want to install. On Ubuntu, these include:

sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev 

Method 2 – RVM

You can also install Ruby over RVM. Here as well, you don’t need to sudo anything, and you’ll be able to get more recent versions of Ruby alongside the system one.

After installation, you can install Rubies with a simple command. First, check rvm list known to get the list of installable versions. Now install your choice:

Then, set it as the default Ruby version for your user:

Now you can install Rails over gem :

Источник

Оцените статью
Adblock
detector