-找不到bash ruby命令

-找不到bash ruby命令,bash,shell,ssh,Bash,Shell,Ssh,每次登录VPS时,我必须先运行source~/.bashrc,然后才能运行任何rvm、ruby或gem命令 为什么会这样?默认情况下无法使其加载 ssh deployer@xxx ruby -v -bash: ruby: command not found source ~/.bashrc ruby -v ruby 1.9.3p429 (2013-05-15 revision 40747) [i686-linux] 我在部署器下安装了rvm 我有~/.bash\u pofile,它是空的。我还

每次登录VPS时,我必须先运行
source~/.bashrc
,然后才能运行任何
rvm
ruby
gem
命令

为什么会这样?默认情况下无法使其加载

ssh deployer@xxx
ruby -v
-bash: ruby: command not found
source ~/.bashrc
ruby -v
ruby 1.9.3p429 (2013-05-15 revision 40747) [i686-linux]
我在部署器下安装了rvm

我有
~/.bash\u pofile
,它是空的。我还有
~/.profile
,其中包含以下内容:

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
My
~/.bashrc
的顶部有:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
发件人:

当bash作为交互式登录shell调用时,或者作为带有
--login
选项的非交互式shell调用时,它首先读取并执行文件
/etc/profile
中的命令(如果该文件存在)。读取该文件后,它将按顺序查找
~/.bash\u profile
~/.bash\u login
~/.profile
,并从第一个存在且可读的文件读取和执行命令


因此,在您的情况下,(空的)
~/.bash\u配置文件
正在执行,而您的
~/.profile
(因此您的
~/.bashrc
)将被忽略。要解决这个问题,您需要在登录时删除
~/.bash\u配置文件
,或者将
~/.profile
的内容移动到
~/.bash\u配置文件
,如果bash可以在主目录中找到名为
.bash\u profile
的文件,它将执行该文件,甚至不搜索
.profile
文件。因此,您有两种选择,要么删除空的
.bash\u profile
文件,要么将
.profile
的内容复制到
.bash\u profile
将信息从
.bashrc
移动到其他文件中,正如其他人建议的那样,这是一种方法

否则,这段代码将执行相同的操作,而无需移动内容或删除文件。根据设置方式的不同,如果文件中包含用于其他任务(交互式登录除外)的相关信息,则可能不希望删除该文件

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi
尽管通过阅读文档来使用这些文件确实可以减轻一些挫折感