I am using zsh and ruby version 2.3.1.
I would like to upgrade it to 2.5.0. I tried to install rvm and ruby version 2.5.0; they were installed, but it also caused many problems because it wasn't able to find other gems.
I removed rvm, and it was back to the way it used to be.
I was wondering if there's a way to upgrade ruby withour rvm. I don't know how ruby was installed before.
When I type which ruby, I get /Users/myname/.rbenv/shims/ruby
Looks like you are using rbenv to manage ruby versions. You can type the following command to install ruby 2.5.0
rbenv install 2.5.0
After that, change your default ruby version to 2.5.0 by typing
rbenv global 2.5.0
For more information and commands, check out the docs.
Related
I need some assistance with installing rbenv and Ruby 2.6.6. I'm currently using zsh, I want to install Ruby 2.6.6, so I did the following:
brew install rbenv
rbenv install 2.6.6
rbenv global 2.6.6
After I did this, I restarted the terminal and I performed the following statement to check the ruby version:
ruby -v
However, the ruby version states:
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
I've tried restarting my terminal and repeated the same steps. I'm new to programming, just need your assistance in helping me fix my setup issues.
Thank you so much for your help
It looks like this is picking up your system Ruby, not the rbenv installed one. You can confirm that with which ruby, which should not say /usr/bin/ruby but something like /Users/<your account/.rbenv/bin (or similar, I don't use rbenv myself anymore). You need to configure your $PATH to make sure this comes before /usr/bin.
The command rbenv init should have taken care of this. If you didn't run it, do that. You can also perform the necessary steps manually, see the documentation for that.
I installed Ruby many moons ago but never use it. Perhaps I inadvertently broke it as I seem to be having troubles with getting it working with the sass command.
After running the brew install sass/sass/sass I get the following error with sass command:
rbenv: sass: command not found
The `sass' command exists in these Ruby versions:
2.1.10
2.5.0
ruby -v yields:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
which I'm guessing is the stock version of Ruby on a mac.
The rbenv command prints out help so it looks like I have that installed. brew list shows I have the ruby package installed. I upgraded ruby with brew but that didn't help (it reported I upgraded from 2.6.1 to 2.6.2. I don't appear to have rvm installed.
If you're using RVM you shouldn't need to brew install anything, in fact you shouldn't.
See documentation here https://github.com/sass/ruby-sass which is deprecated and will refer you to use https://github.com/sass/sassc-ruby instead.
brew uninstall any ruby and ruby packages and just use rbenv to manage your ruby versions.
Once you set your ruby version with rbenv global 2.6.1 for example or whatever version you want, then just do
gem install sassc
Or in your Gemfile add
gem 'sassc`
and run
bundle install
I"m using Ubuntu and RVM. I've run the command
rvm use 2.1.2
Running
ruby -v
gives me the 2.1.2 version.
When I start rails I get the following error
Your Ruby version is 2.3.1, but your Gemfile specified 2.1.2
But RVM doesn't even have 2.3.1 installed.
You may have apt installed ruby. For example, when I run apt show ruby, on my system, I get this
$ apt show ruby
Package: ruby
Version: 1:2.3.0+1
Priority: optional
Section: interpreters
Source: ruby-defaults
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss#lists.ubuntu.com>
...
Clearly, the ruby version is 2.3.x here. So I suggest you apt remove ruby first. If that doesn't solve the problem, it is possible that there is a problem with your $PATH environment variable.
ruby -v gives you the ruby version installed on your system, not the current ruby version used by RVM.
To see which ruby version is currently used by RVM, use rvm list. Make sure it's using ruby version 2.1.2 by running rvm use ruby-2.1.2
From your question, it seems Rails is using your system ruby instead of RVM ruby.
I am trying to upgrade Ruby because I need to setup a Jekyll template, and I need to latest version to do it. Since I have a Mac running Sierra, I already have Ruby preinstalled as well as the Homebrew installation. When I install it using brew install ruby, it works, but when I check the version, it is still at 2.0.0 instead of 2.3.1 where it should be. Homebrew says I have 2.3.1, but the CLI says I have 2.0.0. I tried to use brew link --override ruby to make it work, but it said everything was working and it got me nowhere.
Use rbenv and plugin ruby-build. It will keep several versions of ruby on the one machine.
After install go to directory with your code, run rbenv install 2.3.1 and create file .ruby-version containing 2.3.1. All scripts running from this directory will use ruby 2.3.1.
Or you will able to set ruby version for all running scripts - rbenv global 2.3.1
My current Ruby version is 2.2.3 and I want to upgrade it to 2.3.0.
I use rbenv using this guide: gorails.com/setup/ubuntu/16.04
How do I upgrade my Ruby version? And when I upgrade, does it affect anything that I need to be aware of?
This answer had been written to address the original question, which did not specify rbenv as a preferred approach. Although the question changed after this answer was written, the answer has been retained to help users that may be using RVM to upgrade/manage their Ruby installations.
See the rbenv answer for details on using rbenv for the same purpose.
Use RVM or another Ruby version manager. This is far superior to installing a new system Ruby in most cases.
If you're upgrading your system Ruby, you have a number of things to keep in mind:
what other dependencies are there on that Ruby version?
are all of the gems going to be available after upgrade?
which applications are using the existing Ruby version and what can/will break after upgrade?
are there any other users using the existing Ruby that need to be aware of (and prepare for) the change?
With a Ruby version manager, you eliminate most of these concerns. You can run multiple Ruby versions on the same machine, which gives you the ability to test backward and forward compatibility. It also lets you experiment with the newer Ruby versions to make sure that they're fully stable for use.
You can install RVM using this method from any bash shell:
\curl -sSL https://get.rvm.io | bash -s stable
or update it to the most recent stable version by using:
rvm get stable
Once RVM is installed (or updated), you can install any Ruby version you choose, by doing the following:
rvm install 2.3.0
or upgrade from one version to another:
rvm upgrade 2.2.3 2.3.0
You can see which Ruby versions are installed by using this:
rvm list
You can also check to see which versions of Ruby that you can install on RVM by using this command:
rvm list known
Switch to a specific installed Ruby version by using the use command:
rvm use 2.3.0
and then switch back to an older version when you need to:
rvm use 2.2.3
Check out the RVM documentation for more features. You'll be surprised at how useful RVM actually is. There's a whole lot more to it than just what's shown here.
To upgrade your Ruby version using rbenv, you can use these steps. Some will only be necessary based on your environment. Plugins are an important aspect of this, if you have any installed.
Update rbenbv
First, you'll want to make sure that your rbenv version is updated. If you have the update plugin installed, you can update rbenv and all installed plugins using a single command:
rbenv update
Using the update plugin is highly recommended. However, if you are not using the update plugin, you can manually update rbenv in this way:
cd ~/.rbenv
git pull
Update plugins
If you have manually updated rbenv, you'll also need to update the plugins manually, as well. Make sure to follow the update instructions for each plugin.
One plugin that's very important to update at this point (if you have it installed) is the ruby-build plugin, which provides build support for Ruby under rbenv. This may improve the experience installing a new Ruby version in the next step.
Install Ruby version
After you have updated rbenv, you can install the new Ruby version:
rbenv install -v 2.3.0
Remove Ruby version
rbenv will allow you to manage and use multiple Ruby versions on a single machine. This is a huge benefit. However, if you no longer want the older Ruby version installed, you can remove it like this:
rbenv uninstall 2.2.3
Note that you can always re-install the Ruby version after uninstalling it, and use rbenv to manage the versions separately. This is good practice when working with multiple projects.