163

In Ubuntu 10.04 I just installed rbenv. The install command is not present.

rbenv 0.4.0-49-g8b04303
Usage: rbenv <command> [<args>]

Some useful rbenv commands are:
   commands    List all available rbenv commands
   local       Set or show the local application-specific Ruby version
   global      Set or show the global Ruby version
   shell       Set or show the shell-specific Ruby version
   rehash      Rehash rbenv shims (run this after installing executables)
   version     Show the current Ruby version and its origin
   versions    List all Ruby versions available to rbenv
   which       Display the full path to an executable
   whence      List all Ruby versions that contain the given executable

See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/sstephenson/rbenv#readme

What am I missing?

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
McDougall
  • 1,663
  • 2
  • 12
  • 8

10 Answers10

296

The install command is not embedded into rbenv, it comes from the ruby-build plugin. You can install it using the command:

git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

On Mac OS X you can install it through homebrew:

brew install ruby-build

On Debian (version >= 7) and Ubuntu (version >= 12.10) both rbenv and ruby-build can be installed using apt-get (or aptitude):

sudo apt-get update
sudo apt-get install rbenv ruby-build

On FreeBSD ruby-build is available in the Ports Collection, it can be install both as a binary package or build from the port:

# Using pkgng rbenv will be installed
pkg install ruby-build

# Building ruby-build form Ports will install rbenv only if the RBENV option is set
cd /usr/ports/devel/ruby-build
make install
Dave Powers
  • 2,051
  • 2
  • 30
  • 34
toro2k
  • 19,020
  • 7
  • 64
  • 71
25

I found that when using rbenv from a global directory, it's necessary to export the RBENV_ROOT variable, otherwise it won't load the plugins.

export RBENV_ROOT="/usr/local/rbenv"
if [ -d "${RBENV_ROOT}" ]; then
  export PATH="${RBENV_ROOT}/bin:${PATH}"
fi
Koen.
  • 25,449
  • 7
  • 83
  • 78
14

As everyone mentioned problem is missing ruby-build. For older versions of OS ruby-build may not be available as an apt package. In that case install using original instructions, which should've omitted the word Optional in this:

  1. (Optional) Install ruby-build, which provides the rbenv install command that simplifies the process of installing new Ruby versions.
git clone git@github.com:rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
# OR use http
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Kashyap
  • 15,354
  • 13
  • 64
  • 103
10

Simply install ruby-build in ubuntu:

sudo apt-get install ruby-build

And add

eval "$(rbenv init -)"

To your ~/.bashrc

Thomas Grainger
  • 2,271
  • 27
  • 34
6

I had installed the ruby-build plugin before and installed ruby 1.9.3-p327 using

$ rbenv install 1.9.3-p327

A few days later I tried to install ruby 2.0.0-p247 using

$ rbenv install 2.0.0-p247

but I received the error message

rbenv: no such command 'install'

All I had to do was to run

$ exec $SHELL -l

and that fixed the problem.

user2725109
  • 2,286
  • 4
  • 27
  • 46
  • For anyone reading this in the future - I do recommend using `source` instead of `exec $SHELL`, unless you know what you're doing: http://stackoverflow.com/questions/33048024/exec-shell-executes-from-ssh-wont-execute-in-playbook http://unix.stackexchange.com/questions/91095/what-does-exec-shell-l-do – Andreas Storvik Strauman Feb 01 '17 at 16:51
6

Answered on 2021

If you're getting that error, it's very likely you have accidentally skipped one of the installation instructions:

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

Replace .bashrc with whatever shell you're using, for example .zshrc, or just manually access your shell config file and paste this line:

export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"

I strong advise against re-installing/installing Ruby via brew or apt-get just to get around this issue. The whole point of using rbenv is to make your life easier in future when there is ruby version upgrade, or when you're working on different rails projects that require different version of ruby.

Liren Yeo
  • 3,215
  • 2
  • 20
  • 41
5

It looks like ruby-build is not present. Run this command :

git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
3

Anyone finding their way here with this issue on OSX and already having installed ruby-build via homebrew (like me), you may solve this by just upgrading ruby-build:

brew update
brew upgrade ruby-build

This fixed the problem for me.

Mark Fraser
  • 3,160
  • 2
  • 29
  • 48
1

This issue also happens in Linux when doing a stand-alone installation of ruby-build, if the ruby-build executable is not found in the path. If installing under /usr/local, try for example:

PATH=/usr/local/bin:$PATH /usr/local/bin/rbenv install ...
Alvaro
  • 41
  • 2
0

I came to this solution, but looking for a macOS solution that uses MacPorts.
So, here the same command using MacPorts:

➜ ~ sudo port install ruby-build
Password:
--->  Computing dependencies for ruby-build
--->  Fetching archive for ruby-build
--->  Attempting to fetch ruby-build-20210804_0.darwin_19.noarch.tbz2 from https://packages.macports.org/ruby-build
--->  Attempting to fetch ruby-build-20210804_0.darwin_19.noarch.tbz2.rmd160 from https://packages.macports.org/ruby-build
--->  Installing ruby-build @20210804_0
--->  Activating ruby-build @20210804_0
--->  Cleaning ruby-build
--->  Scanning binaries for linking errors
--->  No broken files found.
--->  No broken ports found.

➜ ~ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash

Checking for `rbenv' in PATH: /opt/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /opt/local/bin/rbenv-install (ruby-build 20210804)
Counting installed Ruby versions: none
  There aren't any Ruby versions installed under `/Users/user/.rbenv/versions'.
  You can install Ruby versions like so: rbenv install 3.0.2
Checking RubyGems settings: OK
Auditing installed plugins: OK
➜ ~ rbenv install 3.0.2
Downloading openssl-1.1.1k.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/892a0875b9872acd04a9fde79b1f943075d5ea162415de3047c327df33fbaee5
Installing openssl-1.1.1k...
MultiColourPixel
  • 1,222
  • 10
  • 19
elulcao
  • 470
  • 4
  • 15