我在 Ruby on Rails 中设置 PATH 变量时遇到问题。约束是:我必须使用 Ruby 1.8.7 和 Rails 2.2.2 和 Rubygems 1.3.5。这些是命令的输出:
hemant@hemant-laptop:~$ which gem
/usr/bin/gem
hemant@hemant-laptop:~$ which ruby
/usr/local/bin/ruby
hemant@hemant-laptop:~$ which rails
/var/lib/gems/1.8/bin/rails
hemant@hemant-laptop:~$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.5
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /var/lib/gems/1.8
- /home/hemant/.gem/ruby/1.8
我已将这些行添加到我的.bashrc
文件中:
export PATH=$PATH:/var/lib/gems/1.8/bin
export PATH=$PATH:/usr/bin/gem
当我回显 PATH 变量时:
hemant@hemant-laptop:~$ echo $PATH
usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:bin:/usr/games:/var/lib/gems/1.8/bin:/usr/bin/gem
真正的问题是,当我script/server
在我的 rails app 目录中运行时,它会出错:
./script/../config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:1:in 'require': no such file to load -- rubygems (LoadError)
当我用谷歌搜索它时,我知道这是由于PATH
变量配置的缺陷,但我不明白我应该赋予它什么价值。以上两个export
语句只是命中和试验,但它们并没有解决问题。
有人可以指导我PATH
必须设置什么值以及如何从各种命令的输出中推断出该值。
[编辑]
运行gem list
给出了这个:
actionmailer (2.2.2)
actionpack (2.2.2)
activerecord (2.2.2)
activeresource (2.2.2)
activesupport (2.2.2)
chronic (0.10.2)
diff-lcs (1.2.4)
image_science (1.2.1)
libv8 (3.16.14.3)
mysql (2.9.1)
rack (1.5.2)
rails (2.2.2)
rake (0.8.7)
ref (1.0.5)
rspec (1.2.9)
rspec-core (2.14.6)
rspec-expectations (2.14.0)
rspec-mocks (2.14.4)
rspec-rails (1.2.9)
rubygems-update (2.1.10)
therubyracer (0.12.0)
ZenTest (4.3.0)