2013-04-04 35 views
7
[email protected]:~$ rbenv global 
1.9.3-p392 
[email protected]:~$ rbenv local 
1.9.3-p392 
[email protected]:~$ which ruby-build 
/usr/local/bin/ruby-build 
[email protected]:~$ rbenv versions 
* 1.9.3-p392 (set by /home/hyperrjas/.ruby-version) 
[email protected]:~$ rbenv version 
1.9.3-p392 (set by /home/hyperrjas/.ruby-version) 
[email protected]:~$ rbenv rehash 
[email protected]:~$ ruby -v 
-bash: ruby: command not found 
[email protected]:~$ env | grep PATH 
PATH=/home/hyperrjas/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games 
NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript 
[email protected]:~$ export PATH="$HOME/.rbenv/bin:$PATH" 
[email protected]:~$ ruby -v 
-bash: ruby: command not found 

Tôi đang làm việc với ubuntu 12.04.-bash: ruby: lệnh không được tìm thấy

Đây là ~/.profile tập tin của tôi:

# ~/.profile: executed by the command interpreter for login shells. 
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login 
# exists. 
# see /usr/share/doc/bash/examples/startup-files for examples. 
# the files are located in the bash-doc package. 

# the default umask is set in /etc/profile; for setting the umask 
# for ssh logins, install and configure the libpam-umask package. 
#umask 022 

# if running bash 
if [ -n "$BASH_VERSION" ]; then 
    # include .bashrc if it exists 
    if [ -f "$HOME/.bashrc" ]; then 
     . "$HOME/.bashrc" 
    fi 
fi 

# set PATH so it includes user's private bin if it exists 
if [ -d "$HOME/bin" ] ; then 
    PATH="$HOME/bin:$PATH" 
fi 
export PATH="$HOME/.rbenv/bin:$PATH" 
eval "$(rbenv init -)" 
eval "$(rbenv init -)" 
eval "$(rbenv init -)" 

Tôi đã cài đặt ruby ​​phiên bản cuối cùng với rbenv và khi tôi cố gắng ruby -v tôi nhận được -bash: ruby: command not found

+0

Tôi nghĩ rằng bạn cần phải chạy một lệnh thêm ruby ​​vào $ PATH của bạn, rất tiếc là tôi không biết lệnh đó là, chúc may mắn! – OneChillDude

+0

FWIW, bạn có thể xem xét việc di chuyển về phía [RVM] (http://rvm.io) –

+0

RVM và rbenv bằng nhau. rbenv là trọng lượng nhẹ hơn, và ít phức tạp hơn, với ít bộ phận chuyển động hơn. RVM có rất nhiều khả năng và rất nhiều thứ khác nữa. –

Trả lời

9

rbenv cần những ở phần cuối của bạn ~/.bash_profile:

export PATH="$HOME/.rbenv/bin:$PATH" 
eval "$(rbenv init -)" 

Sử dụng grep rbenv ~/.bash_profile để xem họ đang ở đó.

Nếu không, hãy chạy:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile 
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile 
exec $SHELL -l 

và bạn nên lên và chạy.

Xem các bước 2 và 3 trong the docs để biết thêm thông tin.

Thông tin thêm về .bashrc, .bash_profile và .profile có thể được tìm thấy trong:

+0

'rbenv init' cho phép shims và tự động hoàn thành. – Stefan

+0

Tôi đã thêm câu hỏi vào tệp '~/.profile' của mình. Cảm ơn bạn – hyperrjas

+0

Tôi không hiểu tại sao trong rbenv doc chỉ định nếu bạn đang chạy ubuntu thì có thể thêm ** Ghi chú Ubuntu **: 'Sửa đổi ~/.profile thay vì ~/.bash_profile.'. Nếu với '~/.profile' không hoạt động tại sao được chỉ định trong doc? – hyperrjas

3

Run env | grep PATH và chắc chắn rằng bạn có $HOME/.rbenv/bin trong PATH của bạn .

Nếu không, hãy thêm số này vào ~/.bash_profile.

export PATH="$HOME/.rbenv/bin:$PATH" 
+0

Cảm ơn bạn tôi đã thử với điều này nhưng tôi nhận được kết quả tương tự. Đây là của tôi 'env | grep PATH' 'PATH =/home/hyperrjas/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/trò chơi NODE_PATH =/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript' Cảm ơn bạn – hyperrjas

+1

Mở một cửa sổ dòng lệnh mới. Thay đổi của bạn sẽ được áp dụng tại lần đăng nhập cửa sổ đầu cuối tiếp theo. –

Các vấn đề liên quan