2

我正在编写一个 ruby​​ 应用程序,当我启动程序时它需要一堆宝石。前任:

require "active_record"
require "RedCloth"
require "rchardet"
require "mailfactory"
require "net/smtp"

但是,当我安装 railssudo gem install rails --version=2.1.1并尝试通过放在顶部添加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': no such file to load -- rails (LoadError)

当我这样做时,gem listRails 就在那里:

    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

导轨在那里!有谁知道怎么回事??

4

0 回答 0