gpt4 book ai didi

ruby-on-rails - -bash : ruby: command not found

转载 作者:数据小太阳 更新时间:2023-10-29 06:57:32 24 4
gpt4 key购买 nike

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 的其他信息可以在以下位置找到:

关于ruby-on-rails - -bash : ruby: command not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15819800/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com