rbenv, bundler, unicorn issue
Asked Answered
E

2

10

I use rbenv and bundler for my ruby application environment.

My 'bundle show':

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)

My 'gem env' show:

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/

My global and local ruby version is the same:

rbenv version
1.9.3-p484

Now when i start my app with command:

bundle exec unicorn -c my_unicorn_config.rb -d

I get this in my error log:

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

Why bundler/runtime.rb can't load my gems? I also define my gem env vars with export GEM_HOME="${HOME}/myapp/shared/bundle/ruby/1.9.1/gems" as well as export GEM_PATH="${GEM_HOME}"

EDIT:

My bundle check output does show that all deps are satisfied:

    [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
Eterne answered 31/5, 2018 at 13:14 Comment(10)
just in case would like to use a supervisor that couples well with unicorn: immortal.run/post/run.ymlCipolin
#17644397Crosswind
Mine error isn't in 'require' though, see the log "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"Eterne
Is SQLite3 itself installed on your machine? Hint: The sqlite3 gem only the Ruby interface to SQLite3 but not SQLite3 itself?Taffrail
Yeah it is. [root@myapp ~]# rpm -qa | grep sqlite sqlite-devel-3.6.20-1.el6_7.2.x86_64 sqlite-3.6.20-1.el6_7.2.x86_64Eterne
Your issue is definitely lower than haml-contrib e.g. sqlite also why sqlite3 and postgres pg?Crosswind
app uses postgres db backendEterne
Can you post the unicorn configuration?Percussive
Then what is sqlite3 for?Crosswind
I think we need the unicorn configuration so we can reproduce the issue. Exactly as @Percussive has written. Please see stackoverflow.com/help/mcve fo rmore.Mckoy
M
1

Are you sure you have all gems you need?

I have tried to install a your version of ruby the 1.9.3-p551 (via rvm). When I tried to install anything via gem it was showing the following error message:

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

I had to fix it via:

gem install psych -v 2.2.4

Your error suggests you are missing it or have an older version somewhere:

- 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'

Could you try it out, installing psych correct version, if it helps you?

Note: the psych has been part of MRI ruby from 1.9.2. However, you may need a newer version, thus the gem.

Mckoy answered 9/6, 2018 at 11:6 Comment(2)
i'll try to add and report backEterne
@DanilaLadner so what did you find out?Mckoy
E
0

It doesn't find activerecord, it doesn't find sinatra-activerecord, it doesn't find haml-contrib. Are you sure you did run bundle?

If that doesn't help, my next step would be to upgrade to ruby 2.1 or 2.2, it's not that much pain.

Enclasp answered 2/6, 2018 at 15:48 Comment(1)
please see my edit. I can't upgrade unfortunately, also it works fine on another host using 1.9.3Eterne

© 2022 - 2024 — McMap. All rights reserved.