ste*_*ver 16
听起来系统查找已安装的 ruby 组件所需的环境是在一个文件中指定的,该文件只能为登录 shell 读取。bash 手册页有关于登录 shell 和非登录 shell 之间的区别的说明:
INVOCATION
A login shell is one whose first character of argument zero is a -, or
one started with the --login option.
Run Code Online (Sandbox Code Playgroud)
和
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.
Run Code Online (Sandbox Code Playgroud)
然而
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.
Run Code Online (Sandbox Code Playgroud)
因此,如果 ruby 环境变量在/home/rails/.profile或/etc/profile例如,它们将被添加到 shell 环境中
su -l rails或su --login rails或速记显式调用登录shellsu - railsrails通过 SSH 登录时bash --login在登录后启动子shell如果无论您如何切换到 user 都希望设置 ruby 环境rails,您可以将相关的变量定义移动到用户的~/.bashrc。
小智 7
我知道这个问题是在 2 年前提出的,但如果有人(像我一样)仍然面临这个问题:@steeldriver 是对的——你在bashrc这 3 个文件之一中遗漏了一些东西。在我的情况下,我只需要将此行添加到我的~/.bashrc:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31650 次 |
| 最近记录: |