我将slim
gem 安装到我自己的自定义目录中,但 require 'slim' 给了我错误。
安装苗条:
$ cd /var/www
$ mkdir project
$ cd project/
$ gem install slim -i gems/
Fetching: temple-0.4.0.gem (100%)
Fetching: slim-1.2.2.gem (100%)
Successfully installed temple-0.4.0
Successfully installed slim-1.2.2
2 gems installed
Installing ri documentation for temple-0.4.0...
Installing ri documentation for slim-1.2.2...
Installing RDoc documentation for temple-0.4.0...
Installing RDoc documentation for slim-1.2.2...
$ ls gems/
bin/ doc/ specifications/
cache/ gems/
$ ls gems/gems/
slim-1.2.2 temple-0.4.0
$ ls gems/gems/slim-1.2.2/
benchmarks CHANGES lib Rakefile slim.gemspec
bin Gemfile LICENSE README.md test
$ ls gems/gems/slim-1.2.2/lib/
slim slim.rb
Gem 环境(如果你注意到我添加/var/www/project/gems
到 GEM_PATH):
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.9.1
- /home/john/.gem/ruby/1.9.1
- /var/www/project/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gempath" => ["/usr/local/lib/ruby/gems/1.9.1", "/home/john/.gem/ruby/1.9.1", "/var/www/project/gems"]
- REMOTE SOURCES:
- http://rubygems.org/
测试:
$ irb
irb(main):001:0> require 'slim'
LoadError: no such file to load -- slim
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from (irb):1
from /usr/local/bin/irb:12:in `<main>'
知道有什么问题吗?我/var/www/project/gems
在 GEM_PATH 中添加了但require 'slim'
不会加载 gem,为什么会这样?这是 rubygems 的错误吗?
当我写和时同样require 'slim'
的/var/www/project/index.rb
问题ruby index.rb
。