I have installed rbenv in my vagrant machine but when I try to list all the available ruby versions rbenv versions then it gives me this output:
system (set by /home/vagrant/.rbenv/version)
Does anyone know what is this?
Are you asking what the output of that command means? I'm looking at the rbenv documentation, and I think it indicates that rbenv only knows of one version of ruby - the version that came installed with your system.
Edit: If that's not the answer you were looking for, can you tell us what you expected to see? Did you have other versions installed on that machine?
Edit 2: If you want to see a list of versions you can install onto your machine, but aren't installed yet, run:
rbenv install --list
Here is more documentation for this command. This will help!
If you have tried both rbenv install --list and ruby-build --definitions and still can't see the latest Ruby versions on the list, then you need to upgrade ruby-build because that is what rbenv uses to "know" the available versions.
For example, assuming you use Mac OS X and installed ruby-build using Homebrew, you can update ruby-build by invoking:
brew upgrade ruby-build
Now, try listing the available versions again, and you should see the latest ones there.
Edit:
The ruby-build wiki lists a couple of ways of updating it, namely the above one using Homebrew and another one where it is installed as a plugin to rbenv:
cd "$(rbenv root)"/plugins/ruby-build && git pull
Rbenv is usually installed with it's companion ruby-build
You can get the versions available to be installed with:
ruby-build --definitions
To get a list of available ruby versions you can install, type the following:
rbenv install -l
To get a list of the ruby versions already installed on your machine, type the following:
rbenv versions
To answer your question as to what the below means:
system (set by /home/vagrant/.rbenv/version)
This is telling you that the system ruby (the default ruby installed on your system) is the only ruby version installed on your vagrant machine. Rbenv is using the default system ruby because it doesn't have any other ruby versions installed yet.
To see all available versions:
rbenv install --list-all
Or
rbenv install --list
To list only stable releases for each Ruby implementation.
If you are on Mac
brew upgrade rbenv ruby-build also works.
Documentation
List rbenv versions that are possible to install
"Only latest stable releases for each Ruby implementation are shown.
With the fewest key strokes (shorter than --list and --list-all)
rbenv install -l
Want to see what is available from rbenv to install?
ruby-build --definitions
Want to narrow that down a bit?
ruby-build --definitions | grep 3.0
To upgrade to the latest rbenv and update ruby-build with newly released Ruby versions, upgrade the Homebrew packages:
brew update && brew upgrade rbenv ruby-build
Also you can always just type rbenv
Which will give you a help menu
rbenv
TLDR the manpage or github repo or just plain forgot?
Take a peek at this site for quick rbenv recollection:
https://devhints.io/rbenv
Also, you may need to brew upgrade if you have installed with brew see here.
Related
I had problems installing ruby with rbenv so I installed it with Homebrew.
The problem is that I still want to manage this ruby version with rbenv.
How can I do that?
Let's say you installed ruby 2.7 (brew does not let you choose patch version): brew install ruby#2.7.
We will call this version 2.7-brew in rbenv but you can call it whatever you like (for example 2.7). Just change all pathes in this answer from 2.7-brew to 2.7 or to another name.
We want rbenv to manage this ruby version:
cd ~/.rbenv/versions
mkdir -p 2.7-brew/bin
We need to link our newly installed ruby version:
replace <Installed Version> with the version brew installed (probably 2.7.7 or a greater patch version)
If you don’t know the version or the installation directory run:
brew info ruby#2.7
Link this ruby version to the directory we have created:
On Mac computers with apple silicon (M1).
ln -s /opt/homebrew/Cellar/ruby#2.7/<Installed Version>/bin/ruby 2.7-brew/bin/ruby
On Mac computers with amd64 architecture (Intell).
ln -s /usr/local/Cellar/ruby#2.7/<Installed Version>/bin/ruby 2.7-brew/bin/ruby
Let rbenv know that we added a new ruby version:
rbenv rehash
Now, rbenv should be able to use this new ruby version.
rbenv install --list-all shows me, among many other things of course,
3.0.0-dev
3.0.0-preview1
3.0.0-preview2
But where is 3.0.0 itself, the actual final release? I'd like to try it out. Not all announced features made it into the previews so I need the real thing.
rbenv install passes thru ruby-build. You need to update (brew upgrade if installed via Homebrew) your ruby-build in order to see the latest versions.
On Ubuntu
Short answer:
# You need to update the available versions via ruby-build
~ git -C ~/.rbenv/plugins/ruby-build pull
~ rbenv install 3.0.0
...
Installed ruby-3.0.0 to ~/.rbenv/versions/3.0.0
Long answer with a beautiful picture🐈: https://richstone.io/where-is-ruby-3-0-0-on-rbenv/
Ubuntu
git -C ~/.rbenv/plugins/ruby-build pull (pulls latest ruby versions)
rbenv install 3.0.0 (or for later versions: 3.x.x)
echo "3.0.0" > .ruby-version OR rbenv local 3.0.0 to ensure ruby 3.0.0 is used.
Mac
brew upgrade
I'm trying to install Ruby version 2.7.2 on my Mac (latest OS with all updates) and did the following
brew update
brew upgrade rbenv ruby-build
and then
rbenv install 2.7.2
ruby-build: definition not found: 2.7.2
See all available versions with `rbenv install --list'.
If the version you need is missing, try upgrading ruby-build:
brew update && brew upgrade ruby-build
So I tried following the instructions above and get this
brew update && brew upgrade ruby-build
Already up-to-date.
Warning: ruby-build 20200926 already installed
You need to install the latest ruby-build
$ brew unlink ruby-build # remove STABLE version
$ brew install --HEAD ruby-build
$ rbenv install -l | grep '2.7.2'
2.7.2
Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all' to show all local versions.
The answer from #andrei-kovrov is correct but, alternatively, you can wait until this PR gets merged:
https://github.com/Homebrew/homebrew-core/pull/62096
Btw, this answer will not age well so, for reference, this is where the formulae are staged before they get released:
https://github.com/Homebrew/homebrew-core/pulls
It might be an issue reading the correct version of ruby based on the path that is specified. If you already have another version of ruby installed the path might not be updated to look for a newer version.
This article has a lot of really great information on how to set up ruby on a mac:
https://stackify.com/install-ruby-on-your-mac-everything-you-need-to-get-going/
I've just installed Mavericks OSX, loosing my previous ruby versions which I used to work in several Redmine based projects. Not to say I'm currently not happy with apple.
Anyway, I'm following #RyanWilcox steps described here to install a ruby version prior 2.0.-
Trouble downgrading Ruby on OS X Mavericks
which looks promising, but sadly I'm stuck installing ruby through macports. When I run
sudo port install ruby
everything seems ok, but then it get stuck in
---> Building gettext
step. I'm not a macports user and have no idea what's happening here nor even where should I start looking. Anyone could point me in the right direction to fix this issue?
Did you install the xcode command line tools? Try xcode-select --install first.
I also suggest you to use Homebrew instead of MacPorts. Here are the steps to install rbenv via Homebrew: https://github.com/sstephenson/rbenv#homebrew-on-mac-os-x
brew install rbenv ruby-build
rbenv init
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile && source ~/.bash_profile
rbenv install 1.8.7-p374 # or any version listed in `rbenv install -l`
rbenv local 1.8.7-p374
Now 1.8.7 is the default Ruby version for your user.
In my case, I had to switch to Xcode5 command-line tools, using xcode-select -s <Xcode5 Developer folder path>, because I had two versions of Xcode (4.6 and 5) on my machine and at the time of building ports I was using Xcode4 command-line tools.
Also, I enabled multi-core build in /opt/local/etc/macports/macports.conf by setting buildmakejobs field to:
buildmakejobs 2
This made the build process much faster, so that there are smaller chances that it would give you false impressions that it got stuck elsewhere.
I have some issues with upgrading my Ruby version with RVM on OS X.
RMV uses MacPorts, causing me to run sudo port selfupdate, which gets a bunch of compiling errors, despite correct Xcode command line tools installed.
I found some installation instructions using Linux apt-get but unfortunately I don't have in it on my Mac.
I want to install Ruby without RVM. How can I do that?
In case Macports does not work for you, try Homebrew:
rvm autolibs homebrew
Please note: Although it is not required, you might want to install Homebrew before using it with autolibs. It keeps Homebrew out of RVM directories.
Using Homebrew, you can either install and manage a single version of Ruby:
brew update
brew install ruby
Or, even better, use rbenv as a flexible alternative to RVM:
brew update
brew install rbenv
brew install ruby-build
rbenv install 2.0.0-p247
rbenv rehash
rbenv then makes it easy to use a specific version of Ruby either globally or per project (which can then be added to source control).
Note that you may want to follow the advice from rbenv's "caveats" (brew info rbenv), particularly the part about adding eval "$(rbenv init -)" to your profile.