听起来好像系统在只为登录shell读取的文件中指定了找到已安装的ruby组件所需的环境。在bash手册页上,这说了登录外壳程序和非登录外壳程序之间的区别:
INVOCATION
A login shell is one whose first character of argument zero is a -, or
one started with the --login option.
和
When bash is invoked as an interactive login shell, or as a non-inter‐
active shell with the --login option, it first reads and executes com‐
mands from the file /etc/profile, if that file exists. After reading
that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
in that order, and reads and executes commands from the first one that
exists and is readable.
而
When an interactive shell that is not a login shell is started, bash
reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if
these files exist.
因此,如果ruby环境变量位于/home/rails/.profile
或/etc/profile
例如,它们将被添加到shell环境中
- 通过使用
su -l rails
或su --login rails
或简写方式显式调用登录shellsu - rails
- 当用户
rails
通过SSH登录时
- 通过
bash --login
登录后启动子shell
如果希望无论如何切换到user都设置ruby环境rails
,则可以将相关变量定义移至用户的位置~/.bashrc
。
su
?或su -l
orsu --
?)。用户“ rails”的登录外壳是什么?您是否修改了用户的PATH变量,以及是否修改了哪个文件(~/.profile
或~/.bashrc
或~/.bash_profile
或...?)