我正在编写一个ruby应用程序,当我启动程序时它需要一堆宝石。例如:
require "active_record"
require "RedCloth"
require "rchardet"
require "mailfactory"
require "net/smtp"
但是,当我使用sudo gem install rails --version=2.1.1
安装rails并尝试将rails
添加到列表中时,将require "rails"
置于顶部,如下所示:
require "rails"
require "active_record"
require "RedCloth"
require "rchardet"
require "mailfactory"
require "net/smtp"
我的应用程序打破了这一行:/usr/local/lib/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:51:in`gem_original_require':没有这样的文件要加载 - rails(LoadError)
当我执行gem list
Rails时:
emai@myserver:/usr/local/www/sl-exchange$ gem list
*** LOCAL GEMS ***
actionmailer (2.1.1)
actionpack (2.1.1)
activemodel (3.2.13)
activerecord (3.2.13, 2.1.1)
activerecord-odbc-adapter (2.0)
activerecord-sqlserver-adapter (3.2.11)
activeresource (2.1.1)
activesupport (3.2.13, 2.1.1)
arel (3.0.2)
atomic (1.1.10)
builder (3.0.4)
daemons (1.0.10)
i18n (0.6.4, 0.6.1)
mailfactory (1.4.0)
mime-types (1.23)
minitest (4.7.5)
multi_json (1.7.7)
pg (0.15.1)
rack (0.4.0)
rails (2.1.1)
rake (10.1.0)
rchardet (1.3.1)
RedCloth (4.0.4)
rubygems-update (2.0.5)
thread_safe (0.1.0)
tzinfo (0.3.37)
当我检查gem env
时:
emai @vpc-db:/ usr / local / www / sl-exchange $ gem env
emai@vpc-db:/usr/local/www/sl-exchange$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.5
- RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
我转到GEM_PATH /usr/lib/ruby/gems/1.8并执行ls
:
emai@myserver:/usr/local/www/sl-exchange$ cd /usr/lib/ruby/gems/1.8
emai@myserver:/usr/lib/ruby/gems/1.8$ ls
build_info cache doc gems specifications
emai@myserver:/usr/lib/ruby/gems/1.8$ cd gems
emai@myserver:/usr/lib/ruby/gems/1.8/gems$ ls
actionmailer-2.1.1 arel-3.0.2 pg-0.15.1
actionpack-2.1.1 atomic-1.1.10 rack-0.4.0
activemodel-3.2.13 builder-3.0.4 rails-2.1.1
activerecord-2.1.1 daemons-1.0.10 rake-10.1.0
activerecord-3.2.13 i18n-0.6.1 rchardet-1.3.1
activerecord-odbc-adapter-2.0 i18n-0.6.4 RedCloth-4.0.4
activerecord-sqlserver-adapter-3.2.11 mailfactory-1.4.0 rubygems-update-2.0.5
activeresource-2.1.1 mime-types-1.23 thread_safe-0.1.0
activesupport-2.1.1 minitest-4.7.5 tzinfo-0.3.37
activesupport-3.2.13 multi_json-1.7.7
那里有铁轨!有谁知道发生了什么事?