首页 文章

rbenv,捆绑者,独角兽问题

提问于
浏览
10

我在我的ruby应用程序环境中使用rbenv和bundler .

我的'捆绑秀':

bundle show
Gems included by the bundle:
  * activemodel (3.2.13)
  * activerecord (3.2.13)
  * activesupport (3.2.13)
  * addressable (2.3.4)
  * arel (3.0.2)
  * bcrypt-ruby (3.0.1)
  * builder (3.0.4)
  * bundler (1.16.2)
  * erubis (2.7.0)
  * eventmachine (1.0.3)
  * faraday (0.8.7)
  * haml (4.0.2)
  * haml-contrib (1.0.0)
  * hashie (1.2.0)
  * hipchat (1.0.1)
  * hiredis (0.4.5)
  * httparty (0.11.0)
  * i18n (0.6.1)
  * json (1.7.7)
  * kgio (2.8.0)
  * maruku (0.6.1)
  * multi_json (1.9.0)
  * multi_xml (0.5.5)
  * multipart-post (1.2.0)
  * oa-core (0.3.2)
  * oa-openid (0.3.2)
  * omniauth (1.0.3)
  * omniauth-google-apps (0.0.2)
  * omniauth-openid (1.0.1)
  * pg (0.15.1)
  * rack (1.6.0.alpha 838865f)
  * rack-contrib (1.2.0 6f33726)
  * rack-flash3 (1.0.3 1f60bb2)
  * rack-openid (1.3.1)
  * rack-protection (1.5.0)
  * raindrops (0.11.0)
  * rake (10.0.4)
  * redis (3.0.4)
  * redis-objects (0.7.0)
  * ruby-openid (2.2.3)
  * ruby-openid-apps-discovery (1.2.0)
  * sass (3.2.9)
  * sinatra (1.4.2)
  * sinatra-activerecord (1.2.2)
  * sinatra-static-assets (1.0.4)
  * sqlite3 (1.3.7)
  * syntax (1.0.0)
  * tilt (1.4.1)
  * tzinfo (0.3.37)
  * unicorn (4.6.2)
  * uuidtools (2.1.4)
  * will_paginate (3.0.4)
  * yajl-ruby (1.1.0)

我的'宝石环境'节目:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.23
  - RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/myapp/myapp/shared/bundle/ruby/1.9.1/gems
  - RUBY EXECUTABLE: /home/myapp/.rbenv/versions/1.9.3-p484/bin/ruby
  - EXECUTABLE DIRECTORY: /home/myapp/myapp/shared/bundle/ruby/1.9.1/gems/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/myapp/myapp/shared/bundle/ruby/1.9.1/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

我的全局和本地ruby版本是相同的:

rbenv version
1.9.3-p484

现在,当我用命令启动我的应用程序时:

bundle exec unicorn -c my_unicorn_config.rb -d

我在错误日志中得到了这个:

I, [2018-05-30T20:03:27.278911 #29102]  INFO -- : listening on addr=0.0.0.0:19001 fd=7
I, [2018-05-30T20:03:27.280553 #29102]  INFO -- : master process ready
I, [2018-05-30T20:03:27.280701 #29104]  INFO -- : Refreshing Gem list
I, [2018-05-30T20:03:27.281393 #29107]  INFO -- : Refreshing Gem list
Exception `LoadError' at /home/myapp/myapp/shared/bundle/ruby/1.9.1/gems/gems/bundler-1.16.2/lib/bundler/runtime.rb:81 - cannot load such file -- haml-contrib
Exception `LoadError' at /home/myapp/myapp/shared/bundle/ruby/1.9.1/gems/gems/bundler-1.16.2/lib/bundler/runtime.rb:95 - cannot load such file -- haml/contrib
Exception `LoadError' at /home/myapp/myapp/shared/bundle/ruby/1.9.1/gems/gems/bundler-1.16.2/lib/bundler/runtime.rb:81 - cannot load such file -- haml-contrib
Exception `LoadError' at /home/myapp/myapp/shared/bundle/ruby/1.9.1/gems/gems/bundler-1.16.2/lib/bundler/runtime.rb:95 - cannot load such file -- haml/contrib
Exception `LoadError' at /home/myapp/myapp/shared/bundle/ruby/1.9.1/gems/gems/bundler-1.16.2/lib/bundler/runtime.rb:81 - cannot load such file -- sinatra-activerecord
Exception `LoadError' at /home/myapp/myapp/shared/bundle/ruby/1.9.1/gems/gems/bundler-1.16.2/lib/bundler/runtime.rb:81 - cannot load such file -- sinatra-activerecord
Exception `NameError' at /home/myapp/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/psych/core_ext.rb:16 - method `to_yaml' not defined in Object
Exception `NameError' at /home/myapp/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/psych/core_ext.rb:16 - method `to_yaml' not defined in Object
Exception `NameError' at /home/myapp/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/psych/core_ext.rb:29 - method `yaml_as' not defined in Module
Exception `NameError' at /home/myapp/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/psych/core_ext.rb:29 - method `yaml_as' not defined in Module
Exception `NameError' at /home/myapp/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/psych/deprecated.rb:79 - undefined method `to_yaml_properties' for class `Object'
Exception `NameError' at /home/myapp/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/psych/deprecated.rb:79 - undefined method `to_yaml_properties' for class `Object'
Exception `LoadError' at /home/myapp/myapp/shared/bundle/ruby/1.9.1/gems/gems/bundler-1.16.2/lib/bundler/runtime.rb:81 - cannot load such file -- activerecord
Exception `LoadError' at /home/myapp/myapp/shared/bundle/ruby/1.9.1/gems/gems/bundler-1.16.2/lib/bundler/runtime.rb:81 - cannot load such file -- activerecord
Exception `LoadError' at /home/myapp/myapp/shared/bundle/ruby/1.9.1/gems/gems/sqlite3-1.3.7/lib/sqlite3.rb:4 - cannot load such file -- sqlite3/1.9/sqlite3_native

为什么bundler / runtime.rb无法加载我的宝石?我还用 export GEM_HOME="${HOME}/myapp/shared/bundle/ruby/1.9.1/gems" 以及 export GEM_PATH="${GEM_HOME}" 定义我的宝石环境变量

编辑:

我的捆绑检查输出确实显示所有deps都满意:

[myapp@myapp appuser]$ bundle check
Your Gemfile lists the gem uuidtools (>= 0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of one of them later.
The Gemfile's dependencies are satisfied

2 回答

  • 0

    它找不到 activerecord ,它找不到 sinatra-activerecord ,它找不到 haml-contrib . 你确定你确实运行过 bundle 吗?

    如果这没有帮助,我的下一步将是升级到ruby 2.1或2.2,这不是那么痛苦 .

  • 0

    你确定你拥有所需的所有宝石吗?

    我试图安装你的版本的ruby 1.9.3-p551(通过rvm) . 当我尝试通过gem安装任何东西时,它显示以下错误消息:

    YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).
    

    我不得不通过以下方式修复它:

    gem install psych -v 2.2.4
    

    您的错误表明您错过了它或某个地方有旧版本:

    - cannot load such file -- sinatra-activerecord Exception `NameError' at /home/myapp/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/psych/core_ext.rb:16
    - method `to_yaml' not defined in Object Exception `NameError' at /home/myapp/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/psych/core_ext.rb:16
    - method `to_yaml' not defined in Object Exception `NameError' at /home/myapp/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/psych/core_ext.rb:29
    - method `yaml_as' not defined in Module Exception `NameError' at /home/myapp/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/psych/core_ext.rb:29
    - method `yaml_as' not defined in Module Exception `NameError' at /home/myapp/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/psych/deprecated.rb:79
    - undefined method `to_yaml_properties' for class `Object' Exception `NameError' at /home/myapp/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/psych/deprecated.rb:79
    - undefined method `to_yaml_properties' for class `Object'
    

    你可以尝试一下,安装 psych 正确的版本,如果它对你有帮助吗?

    Note: psych 已成为1.9.2的MRI红宝石的一部分 . 但是,您可能需要更新的版本,因此宝石 .

相关问题