Search code examples
ruby-on-railscapistranobundlercapistrano3rubinius

Why can't bundle find gems in production after `bundle --deployment`?


Here's a summary of my issue: I stood up a new server I install Rubinius and some other stuff as documented here. I deployed. The site was up for several deploys. At some point, I had a problem and started trying random solutions. I ran into a problem with bundler and couldn't get past it. Frustrated, I stood up a whole new server. I am still having the problem. This points to a problem with my code or my capistrano scripts... but I am not having any bundler issues in development, and I went back to capistrano scripts that were working earlier and no joy. So I'm baffled. Any thoughts would be appreciated.

Xena is the second machine. Here's what I get after a deploy:

production@xena:~/lexicon/current$ ruby -v
rubinius 2.4.1 (2.1.0 b332f133 2014-12-04 3.4 JI) [x86_64-linux-gnu]

Capistrano ran this command, but I did it again just to show the results:

production@xena:~/lexicon/current$ /usr/local/bin/chruby-exec rbx-2.4.1 -- bundle install --binstubs /home/production/lexicon/shared/bin --path /home/production/lexicon/shared/bundle --without development test --deployment
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.5.1
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.2.0
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.5
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.5
Using loofah 2.0.1
Using rails-html-sanitizer 1.0.1
Using actionview 4.2.0
Using rack 1.6.0
Using rack-test 0.6.3
Using actionpack 4.2.0
Using globalid 0.3.0
Using activejob 4.2.0
Using mime-types 2.4.3
Using mail 2.6.3
Using actionmailer 4.2.0
Using activemodel 4.2.0
Using arel 6.0.0
Using activerecord 4.2.0
Using bcrypt 3.1.9
Using climate_control 0.0.3
Using cocaine 0.5.5
Using commonjs 0.2.7
Using execjs 2.2.2
Using tilt 1.4.1
Using haml 4.0.6
Using hike 1.2.3
Using thor 0.19.1
Using railties 4.2.0
Using jquery-rails 4.0.3
Using jquery-ui-rails 5.0.3
Using less 2.6.0
Using less-rails 2.6.0
Using libv8 3.16.14.7
Using multi_json 1.10.1
Using mysql2 0.3.17
Using net-ssh 2.7.0
Using paperclip 4.2.1
Using polyamorous 1.1.0
Using psych 2.0.9
Using puma 2.10.2
Using bundler 1.7.11
Using sprockets 2.12.3
Using sprockets-rails 2.2.2
Using rails 4.2.0
  ing ransack 1.6.1
▽sing redcarpet 3.2.2
Using ref 1.0.5
Using rollbar 1.4.0
Using simple_form 3.1.0
Using therubyracer 0.12.1
Using twitter-bootstrap-rails 3.2.1 from https://github.com/seyhunak/twitter-bootstrap-rails.git (at master)
Using uglifier 2.7.0
Using valuable 0.9.9
Using warden 1.2.3
Using will_paginate 3.0.7
Using will_paginate-bootstrap 1.0.1
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into /home/production/lexicon/shared/bundle

and then I try to run rails:

production@xena:~/lexicon/current$ bin/rails c
Could not find i18n-0.7.0 in any of the sources
Run `bundle install` to install missing gems.

Maybe via bundler?:

production@xena:~/lexicon/current$ bundle exec rails c
bundler: command not found: rails
Install missing gem executables with `bundle install`

My bundler config. I know there is some odd issue with rubinius and psych, but this seems ok:

production@xena:~/lexicon/current$ vim .bundle/config
--- !ruby/hash-with-ivars
elements:
  BUNDLE_FROZEN: '1'
  BUNDLE_PATH: "/home/production/lexicon/shared/bundle"
  BUNDLE_BIN: "/home/production/lexicon/shared/bin"
  BUNDLE_WITHOUT: development:test
  BUNDLE_DISABLE_SHARED_GEMS: '1'
ivars:
  :@capacity: 16
  :@max_entries: 12
  :@entries: !ruby/object:Rubinius::Tuple {}
  :@state: &1 !ruby/object:Hash::State
    tail: &5 !ruby/object:Hash::Bucket
      link:
      state: *1
      value: '1'
      previous: &2 !ruby/object:Hash::Bucket
        link:
        state: *1

Well, let's make sure there are some gems there:

production@xena:~/lexicon/current$ ls /home/production/lexicon/shared/bundle/rbx/2.1/bin/
erubis  lessc     puma     rackup  rake       sprockets  tilt
haml    nokogiri  pumactl  rails   redcarpet  thor

that seems right...

production@xena:~/lexicon/current$ ls /home/production/lexicon/shared/bundle/rbx/2.1/gems

actionmailer-4.2.0            net-ssh-2.7.0
actionpack-4.2.0              nokogiri-1.6.5
actionview-4.2.0              paperclip-4.2.1
activejob-4.2.0               polyamorous-1.1.0
activemodel-4.2.0             psych-2.0.9
activerecord-4.2.0            puma-2.10.2
activesupport-4.2.0           rack-1.6.0
arel-6.0.0                    rack-test-0.6.3
bcrypt-3.1.9                  rails-4.2.0
builder-3.2.2                 rails-deprecated_sanitizer-1.0.3
climate_control-0.0.3         rails-dom-testing-1.0.5
cocaine-0.5.5                 rails-html-sanitizer-1.0.1
commonjs-0.2.7                railties-4.2.0
erubis-2.7.0                  rake-10.4.2
execjs-2.2.2                  ransack-1.6.1
globalid-0.3.0                redcarpet-3.2.2
haml-4.0.6                    ref-1.0.5
hike-1.2.3                    rollbar-1.4.0
i18n-0.7.0                    simple_form-3.1.0
jquery-rails-4.0.3            sprockets-2.12.3
jquery-ui-rails-5.0.3         sprockets-rails-2.2.2
json-1.8.2                    therubyracer-0.12.1
less-2.6.0                    thor-0.19.1
less-rails-2.6.0              thread_safe-0.3.4
libv8-3.16.14.7-x86_64-linux  tilt-1.4.1
loofah-2.0.1                  tzinfo-1.2.2
mail-2.6.3                    uglifier-2.7.0
mime-types-2.4.3              valuable-0.9.9
mini_portile-0.6.2            warden-1.2.3
minitest-5.5.1                will_paginate-3.0.7
multi_json-1.10.1             will_paginate-bootstrap-1.0.1
mysql2-0.3.17

Any help in figuring out why bundler can't find the files it just placed would be greatly appreciated.


Solution

  • With help from brixen and yorickpeterse on #rubinius, we discovered that the root cause of this chaos was psych above 2.0.8.

    #with rbx 2.4.1 and psych 2.0.8
    rbx-2.4.1 :003 > YAML.dump({fu: 'bar'})
    => "---\n:fu: bar\n"
    

    but the problem comes when you update versions:

    rbx-2.4.1 :005 > YAML.dump({fu: 'bar'})
    => "--- !ruby/hash-with-ivars\nelements:\n  :fu: bar\nivars:\n  :@entries: !ruby/object:Rubinius::Tuple {}\n  :@capacity: 16\n  :@size: 1\n  :@max_entries: 12\n  :@state: &1 !ruby/object:Hash::State\n    compare_by_identity: false\n    head: &2 !ruby/object:Hash::Bucket\n      key_hash: 2112643688174279348\n      value: bar\n      link: \n      state: *1\n      key: :fu\n    tail: *2\n  :@mask: 15\n"
    

    Capistrano emits YAML when it creates .bundle/config. It seems Capistrano can't read the "creative" version of its config file, so it goes back to default values.

    Once I installed psych 2.0.6 on my production machine and corrected my gemfile, I was able to deploy successfully.

    References