The command rbenv install is missing

£可爱£侵袭症+ 提交于 2019-11-29 19:24:36
toro2k

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

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

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

Simply install ruby-build in ubuntu:

sudo apt-get install ruby-build

And add

eval "$(rbenv init -)"

To your ~/.bashrc

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.

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.

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 ...

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!