Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

method missing 'bundle_install' #25

Closed
pjammer opened this issue Jul 19, 2016 · 6 comments
Closed

method missing 'bundle_install' #25

pjammer opened this issue Jul 19, 2016 · 6 comments
Assignees

Comments

@pjammer
Copy link

pjammer commented Jul 19, 2016

Was that supposed to come from somewhere else when you refactored, or am i missing a dependency?

either way i hardcoded a bundle exec just to get past it. when i have time i'll pull request all this together.

@ajgon
Copy link
Owner

ajgon commented Jul 21, 2016

Hey,

Can you paste me an error here? bundle_install is part of application_ruby and should work out-of-the box...

@pjammer
Copy link
Author

pjammer commented Aug 3, 2016

[2016-08-03T10:44:45+00:00] WARN: Error on deploying /srv/www/myapp/releases/20160803104441: No resource or method named `bundle_install' for `Chef::Provider::Deploy::Timestamped ""'
[2016-08-03T10:44:45+00:00] INFO: Removing failed deploy /srv/www/myapp/releases/20160803104441

================================================================================
Error executing action `deploy` on resource 'deploy[myapp]'
================================================================================

NoMethodError
-------------
No resource or method named `bundle_install' for `Chef::Provider::Deploy::Timestamped ""'

Cookbook Trace:
---------------
/var/chef/runs/179d6690-538f-479e-af05-3743c5611055/local-mode-cache/cache/cookbooks/opsworks_ruby/recipes/deploy.rb:56:in `block (3 levels) in from_file'
/var/chef/runs/179d6690-538f-479e-af05-3743c5611055/local-mode-cache/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:41:in `run_action'

Resource Declaration:
---------------------
# In /var/chef/runs/179d6690-538f-479e-af05-3743c5611055/local-mode-cache/cache/cookbooks/opsworks_ruby/recipes/deploy.rb

23:   deploy application['shortname'] do
24:     deploy_to deploy_dir(application)
25:     user node['deployer']['user'] || 'root'
26:     group www_group
27:     rollback_on_error true
28:     environment application['environment'].merge(framework.out[:deploy_environment])
29: 
30:     keep_releases deploy[:keep_releases]
31:     create_dirs_before_symlink(
32:       (node['defaults']['deploy']['create_dirs_before_symlink'] + Array.wrap(deploy[:create_dirs_before_symlink])).uniq
33:     )
34:     purge_before_symlink(
35:       (node['defaults']['deploy']['purge_before_symlink'] + Array.wrap(deploy[:purge_before_symlink])).uniq
36:     )
37:     symlink_before_migrate deploy[:symlink_before_migrate]
38:     symlinks(node['defaults']['deploy']['symlinks'].merge(deploy[:symlinks] || {}))
39: 
40:     scm.out.each do |scm_key, scm_value|
41:       send(scm_key, scm_value) if respond_to?(scm_key)
42:     end
43: 
44:     [appserver, webserver].each do |server|
45:       server.notifies[:deploy].each do |config|
46:         notifies config[:action],
47:                  config[:resource].respond_to?(:call) ? config[:resource].call(application) : config[:resource],
48:                  config[:timer]
49:       end
50:     end
51: 
52:     migration_command(framework.out[:migration_command])
53:     migrate framework.out[:migrate]
54:     before_migrate do
55:       #execute "cd #{release_path} && RAILS_ENV=production bundle install --without=development test"
56:       bundle_install File.join(release_path, 'Gemfile') do
57:         deployment true
58:         without %w(development test)
59:       end
60: 
61:       fire_hook(:deploy_before_migrate, context: self,
62:                                         items: databases + [scm, framework, appserver, worker, webserver])
63: 
64:       run_callback_from_file(File.join(release_path, 'deploy', 'before_migrate.rb'))
65:     end
66: 
67:     before_symlink do
68:       unless framework.out[:migrate]
69:         # execute "cd #{release_path} && RAILS_ENV=production bundle install --without=development test"
70:         bundle_install File.join(release_path, 'Gemfile') do
71:           deployment true
72:           without %w(development test)
73:         end
74:       end

Sorry for the delay. Sidenote, the change i made to just run the command bundle install (commented out line) worked, and a slight change to running db:setup in one of your commands, made this run smoothly for the last couple of weeks. Now i'm going to tackle environment variables and databags.

@pjammer
Copy link
Author

pjammer commented Aug 3, 2016

Do we have to add this like a require 'application_ruby' or something?

bundle_install is supposed to be in an application block, which you use a helper for and yield, but is it in the application 'blah' do .... end like the readme wants here on application_ruby?

I'm still feeling my way around Chef, but the repo for application_ruby doesn't look like this recipe. There is no explicit /recipes/default or a metadat.rb file either. Different style i guess, as you seem to have it work on your machine.

@ajgon
Copy link
Owner

ajgon commented Aug 5, 2016

application_ruby is problematic, and I have a plan to completely remove it soon. So, for now, feel free to use your workaround, and I'll do my best to post the fix next week.

@ajgon ajgon added this to the 0.6.0 milestone Aug 5, 2016
@ajgon ajgon self-assigned this Aug 5, 2016
@pjammer
Copy link
Author

pjammer commented Aug 8, 2016

Hey for what it's worth, as you know more than I, I found adding just template and other Chef like things to throw up an error too. Yet execute works in deploy.rb no problem. Basically I had to added the template code below where you put the code for creating the unicorn.conf (drivers_appserver_unicorn.rb) file. But i tried to stick template code just in deploy.rb and the same code wouldn't work (yet does in the appserver file.)

Why i bring this up is it because we are missing require or include, as in missing plain old ruby syntax?

Also is this working for you without changes? like in your personal use of opsworks_ruby from this branch it is working fine? Cause it'd be a "me" thing if I'm the only one messed up by it.

@ajgon
Copy link
Owner

ajgon commented Aug 8, 2016

Ok, I nailed the error down. The problem was, that the bundle_install action was part of poise-ruby cookbook, and it's probably missing from your stack. The application_ruby cookbook depends on some extra other cookbooks, which depends on another ones, and basically you've gotta catch them all :) Here is the list:

  • application_ruby
    • application
    • poise
    • poise-ruby
      • poise-languages
        • poise-archive
    • poise-service

Having said that, this whole stack was only necessary for this bundle_install action. I had my moments, but this is definitely not the best usage of resources ;) So the upcoming version 0.6.0 of the gem would have all those dependencies removed. I will probably publish it later this week, so stay tuned!

@ajgon ajgon closed this as completed in 6709568 Aug 8, 2016
dotnofoolin pushed a commit to dotnofoolin/opsworks_ruby that referenced this issue Nov 23, 2021
The `application_ruby` cookbook was basically used only for `bundle_install` action. By removing it
in favor of `execute 'bundle install ...'` we can remove this large, and unnecessary dependence.

Closes ajgon#25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants