每次我登录服务器时,我都无法运行任何Rails命令,直到运行/bin/bash;请参阅下面的
Last login: Mon Oct 29 16:28:07 2012 from natint3.company.com
user1@company.com [~]# rails -v
/usr/lib64/ruby/site_ruby/1.8/rubygems.rb:926:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:244:in `activate_dep'
from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:236:in `activate'
from /usr/lib64/ruby/site_ruby/1.8/rubygems.rb:1307:in `gem'
from /usr/bin/rails:18
user1@company.com [~]# rvm info
ruby-1.9.3-p194:
system:
uname: "Linux box726.bluehost.com 2.6.32-20120131.55.1.bh6.x86_64 #1 SMP Tue Jan 31 15:43:27 EST 2012 x86_64 x86_64 x86_64 GNU/Linux"
system: "unknown/libc-2.12/x86_64"
bash: "/ramdisk/bin/bash => GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)"
zsh: "/usr/bin/zsh => zsh 4.3.10 (x86_64-redhat-linux-gnu)"
rvm:
version: "rvm 1.16.17 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
updated: "4 hours 10 minutes 5 seconds ago"
ruby:
interpreter: "ruby"
version: "1.9.3p194"
date: "2012-04-20"
platform: "x86_64-linux"
patchlevel: "2012-04-20 revision 35410"
full_version: "ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]"
homes:
gem: "/home3/user1/.rvm/gems/ruby-1.9.3-p194"
ruby: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194"
binaries:
ruby: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194/bin/ruby"
irb: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194/bin/irb"
gem: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194/bin/gem"
rake: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194/bin/rake"
environment:
PATH: "/home3/user1/.rvm/gems/ruby-1.9.3-p194/bin:/home3/user1/.rvm/gems/ruby-1.9.3-p194@global/bin:/home3/user1/.rvm/rubies/ruby-1.9.3-p194/bin:/home3/user1/.rvm/bin:/usr/local/jdk/bin:/home3/user1/perl5/bin:/usr/lib64/qt-3.3/bin:/ramdisk/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin:/home3/user1//ruby/gems/bin:/home3/user1//ruby/gems:/home3/user1/bin"
GEM_HOME: "/home3/user1/.rvm/gems/ruby-1.9.3-p194"
GEM_PATH: "/home3/user1/.rvm/gems/ruby-1.9.3-p194:/home3/user1/.rvm/gems/ruby-1.9.3-p194@global"
MY_RUBY_HOME: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194"
IRBRC: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194/.irbrc"
RUBYOPT: ""
gemset: ""
user1@company.com [~]#
我跑步/bin/bash之后,我的行为有所不同
user1@company.com [~]# /bin/bash
user1@company.com [~]# rails -v
Rails 3.2.8
user1@company.com [~]# rvm info
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
system:
system:
uname: "Linux box726.bluehost.com 2.6.32-20120131.55.1.bh6.x86_64 #1 SMP Tue Jan 31 15:43:27 EST 2012 x86_64 x86_64 x86_64 GNU/Linux"
system: "unknown/libc-2.12/x86_64"
bash: "/ramdisk/bin/bash => GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)"
zsh: "/usr/bin/zsh => zsh 4.3.10 (x86_64-redhat-linux-gnu)"
rvm:
version: "rvm 1.16.17 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
updated: "4 hours 11 minutes 9 seconds ago"
homes:
gem: "/home3/user1//ruby/gems"
ruby: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194"
binaries:
ruby: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194/bin/ruby"
irb: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194/bin/irb"
gem: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194/bin/gem"
rake: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194/bin/rake"
environment:
PATH: "/usr/local/jdk/bin:/home3/user1/.rvm/gems/ruby-1.9.3-p194/bin:/home3/user1/.rvm/gems/ruby-1.9.3-p194@global/bin:/home3/user1/.rvm/rubies/ruby-1.9.3-p194/bin:/home3/user1/.rvm/bin:/home3/user1/perl5/bin:/usr/lib64/qt-3.3/bin:/ramdisk/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin:/home3/user1//ruby/gems/bin:/home3/user1//ruby/gems:/home3/user1/bin"
GEM_HOME: "/home3/user1//ruby/gems"
GEM_PATH: "/home3/user1//ruby/gems:/usr/lib64/ruby/gems/1.8"
MY_RUBY_HOME: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194"
IRBRC: "/home3/user1/.rvm/rubies/ruby-1.9.3-p194/.irbrc"
RUBYOPT: ""
gemset: ""
user1@company.com [~]#
任何人都知道发生了什么,我该如何解决此问题?
谢谢
edit1
这是我的.bashrc和.bash_profile文件内容
user1@company.com [~]# cat ~/.bashrc
# .bashrc
# User specific aliases and functions
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export HPATH=/home3/user1/
export GEM_HOME=$HPATH/ruby/gems
export GEM_PATH=$GEM_HOME:/usr/lib64/ruby/gems/1.8
export GEM_CACHE=$GEM_HOME/cache
export PATH=$PATH:$HPATH/ruby/gems/bin
export PATH=$PATH:$HPATH/ruby/gems
PATH=$PATH:/home3/user1/.rvm/bin # Add RVM to PATH for scripting
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
user1@company.com [~]# cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
user1@company.com [~]#
这对我来说似乎是一个路径问题。当您第一次运行rails
时,它将在本地rvm
复制之前找到全局RubyGems安装。
从命令行运行 /bin/bash
后,您将启动一个交互式壳,该外壳来源(执行)~/.bashrc
。我的猜测是包含使用登录外壳登录时无法运行的RVM初始化。
看一下~/.bash_profile
和~/.bashrc
。这是最新的RVM安装程序生成的内容:
$ cat ~/.bashrc
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
$ cat ~/.bash_login
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export NODE_PATH=/usr/local/lib/node_modules
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
如果这是您所拥有的,那么您将以某种方式通过交互式外壳登录而不是登录外壳(如何?)。您应该能够使用source ~/.bash_profile
(OS X中的.bash_login
)来解决这两个问题。