加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – -bash:ruby:命令未找到

发布时间:2020-12-17 04:22:18 所属栏目:百科 来源:网络整理
导读:hyperrjas@serv1:~$rbenv global1.9.3-p392hyperrjas@serv1:~$rbenv local1.9.3-p392hyperrjas@serv1:~$which ruby-build/usr/local/bin/ruby-buildhyperrjas@serv1:~$rbenv versions* 1.9.3-p392 (set by /home/hyperrjas/.ruby-version)hyperrjas@serv1:~$
hyperrjas@serv1:~$rbenv global
1.9.3-p392
hyperrjas@serv1:~$rbenv local
1.9.3-p392
hyperrjas@serv1:~$which ruby-build
/usr/local/bin/ruby-build
hyperrjas@serv1:~$rbenv versions
* 1.9.3-p392 (set by /home/hyperrjas/.ruby-version)
hyperrjas@serv1:~$rbenv version
1.9.3-p392 (set by /home/hyperrjas/.ruby-version)
hyperrjas@serv1:~$rbenv rehash
hyperrjas@serv1:~$ruby -v
-bash: ruby: command not found
hyperrjas@serv1:~$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
hyperrjas@serv1:~$export PATH="$HOME/.rbenv/bin:$PATH"
hyperrjas@serv1:~$ruby -v
-bash: ruby: command not found

我正在使用ubuntu 12.04.

这是我的?/ .profile文件:

# ~/.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 -)"

我用rbenv安装了ruby最后一个版本,当我尝试ruby -v时,我得到-bash:ruby:command not found

解决方法

rbenv在?/ .bash_profile的末尾需要这些:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

使用grep rbenv~ / .bash_profile查看它们是否在那里.

如果没有,请运行:

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

你应该开始运作.

有关详细信息,请参阅the docs中的步骤2和3.

有关.bashrc,.bash_profile和.profile的更多信息,请参阅:

> What’s the difference between .bashrc,.bash_profile,and .environment?
> Difference between .profile and .bash_profile on Snow Leopard
> https://superuser.com/questions/183870/difference-between-bashrc-and-bash-profile
> https://unix.stackexchange.com/questions/40708/what-is-the-difference-between-profile-bashrc-bash-profile-gnomer

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读