Parece que o ambiente necessário para o sistema encontrar os componentes ruby instalados é especificado em um arquivo que só é lido para os shells de login. A página de manual do bash tem isto a dizer sobre a diferença entre shells de login e shells não-login:
INVOCATION
A login shell is one whose first character of argument zero is a -, or
one started with the --login option.
e
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.
enquanto
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.
Portanto, se as variáveis do ambiente ruby estiverem em /home/rails/.profile ou /etc/profile , por exemplo, elas serão adicionadas ao ambiente de shell
- ao invocar explicitamente um shell de login usando
su -l railsousu --login railsou o atalhosu - rails - quando o usuário
railsefetua login via SSH - iniciando um subshell como
bash --loginapós o login
Se você quiser que o ambiente ruby seja definido, independentemente de como você muda para o usuário rails , você pode mover as definições de variáveis relevantes para o usuário ~/.bashrc .