2013-07-12 86 views
103

在Ubuntu的10.04我剛剛安裝rbenv。 安裝命令它不存在。命令rbenv安裝缺少

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 

我在想什麼?

回答

209

install命令未被嵌入到rbenv,它來自ruby-build插件。您可以使用下面的命令來安裝它:

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

在Mac OS X中,可以通過自制軟件安裝:

brew install ruby-build 

Debian(版本> = 7)和Ubuntu(版本> = 12.10)都rbenv和紅寶石建造可以使用apt-get(或​​)安裝:

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

在FreeBSD紅寶石版本是在Ports套件,它可以被安裝既作爲一個二進制包或者從港口建設:

# 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 
+14

不應'紅寶石build'是rbenv的依賴? – Jason

+3

這應該是被接受的答案。 – iurii

+0

感謝作品 –

3

我已經安裝紅寶石構建插件之前安裝並使用紅寶石

$ rbenv install 1.9.3-p327 

幾天後,我試圖1.9.3-P327安裝使用

$ rbenv install 2.0.0-p247 

紅寶石2.0.0-P247,但我接收到的錯誤消息

rbenv: no such command 'install' 

我所要做的就是運行

$ exec $SHELL -l 

,並且解決了這一問題。

+0

對於任何人在將來閱讀 - 我建議使用'source'而不是'exec $ SHELL',除非你知道你在做什麼: http://stackoverflow.com/questions/33048024/exec-shell - 從ssh執行 - 不執行在執行劇本 http://unix.stackexchange.com/questions/91095/what-does-exec-shell-l-do –

7

在Ubuntu只需安裝紅寶石構建:

sudo apt-get install ruby-build 

並添加

eval "$(rbenv init -)" 

到你的〜/ .bashrc中

25

我發現,使用全球目錄rbenv時,它的需要導出RBENV_ROOT變量,否則不會加載插件。

export RBENV_ROOT="/usr/local/rbenv" 
if [ -d "${RBENV_ROOT}" ]; then 
    export PATH="${RBENV_ROOT}/bin:${PATH}" 
fi 
+3

這應該是最好的答案 – surfer190

+1

這是部分我記得 – professormeowingtons

+1

它的工作原理!它也在wiki上提到:https://github.com/sstephenson/rbenv/wiki/Plugins – Lucio

2

任何人在這裏找到自己的方式與OSX這個問題,已經有安裝了通過自制軟件(像我)紅寶石打造,你可以通過剛剛升級紅寶石構建解決這個問題:

brew update 
brew upgrade ruby-build 

這爲我解決了這個問題。

1

做紅寶石打造的獨立安裝時,如果ruby-build可執行文件不在路徑中發現這個問題也發生在Linux操作系統。如果/usr/local下安裝,試例如:

PATH=/usr/local/bin:$PATH /usr/local/bin/rbenv install ... 
11

大家都提到的問題是缺少ruby-build。對於舊版本的操作系統ruby-build可能無法作爲apt包提供。在這種情況下安裝使用original instructions,它應該已經省略了這個字Optional

  • (可選)安裝紅寶石建造,這提供了rbenv安裝 命令,簡化安裝新的Ruby版本的過程。
  • git clone [email protected]:rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build 
    # OR use http 
    git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build