Ruby 2.1.1をrvm
経由でインストールして、新しいUbuntu 13.10サーバーをセットアップしました。
問題は、ユーザー「Rails」(RubyおよびRailsをインストールしたユーザー)に切り替えるたびに、UbuntuがRubyを認識する前に/bin/bash --login
を実行する必要があることです。 Railsまたはrvm
がインストールされています。
誰かが知っていることを願っています:
どんな助けも大歓迎です!
システムがインストールされた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
にある場合、それらはシェル環境に追加されます
su -l Rails
またはsu --login Rails
または短縮形su - Rails
を使用してログインシェルを明示的に呼び出すRails
がSSH経由でログインするときbash --login
として起動するユーザーRails
に切り替える方法に関係なくRuby環境を設定する場合は、代わりに関連する変数定義をユーザーの~/.bashrc
に移動できます。
私はこの質問が2年前に尋ねられたことを知っていますが、誰か(私のような)がまだそれに直面している場合:@steeldriverが正しい-あなたはそれらの3つのファイルの1つにあるbashrc
に何かが欠けています。私の場合、この行を私の~/.bashrc
に追加する必要がありました。
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"