sverch / newrelic_plugins_chef

MIT License
0 stars 0 forks source link

Bundler issue when not using root user #4

Open sverch opened 7 years ago

sverch commented 7 years ago

Merging in https://github.com/sverch/newrelic_plugins_chef/pull/3 fixed some of the issues with installing this plugin, but unfortunately when the script actually runs it still can't find the dependencies.

I believe this has to do with the fact that bundler uses sudo, but this plugin uses su.

/usr/lib/ruby/vendor_ruby/bundler/spec_set.rb:94:in `block in materialize': Could not find json-1.8.6 in any of the sources (Bundler::GemNotFound)
    from /usr/lib/ruby/vendor_ruby/bundler/spec_set.rb:87:in `map!'
    from /usr/lib/ruby/vendor_ruby/bundler/spec_set.rb:87:in `materialize'
    from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:137:in `specs'
    from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:182:in `specs_for'
    from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:171:in `requested_specs'
    from /usr/lib/ruby/vendor_ruby/bundler/environment.rb:18:in `requested_specs'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:13:in `setup'
    from /usr/lib/ruby/vendor_ruby/bundler.rb:92:in `setup'
    from /usr/lib/ruby/vendor_ruby/bundler/setup.rb:18:in `<top (required)>'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
sverch commented 7 years ago

Also hitting this on vagrant:

  * execute[bundle install] action run

    ================================================================================
    Error executing action `run` on resource 'execute[bundle install]'
    ================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '23'
    ---- Begin output of bundle install --path vendor/bundle ----
    STDOUT: There was an error while trying to write to
    `/home/vagrant/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47/versions`.
    It is likely that you need to grant write permissions for that path.
    STDERR:
    ---- End output of bundle install --path vendor/bundle ----
    Ran bundle install --path vendor/bundle returned 23

    Resource Declaration:
    ---------------------
    # In /home/vagrant/.chef/local-mode-cache/cache/cookbooks/newrelic_plugins/definitions/bundle_install.rb

      8:   execute 'bundle install' do
      9:     cwd params[:path]
     10:     if params[:user] == 'root'
     11:       command 'bundle install'
     12:     else
     13:       command 'bundle install --path vendor/bundle'
     14:     end
     15:     user params[:user]

    Compiled Resource:
    ------------------
    # Declared in /home/vagrant/.chef/local-mode-cache/cache/cookbooks/newrelic_plugins/definitions/bundle_install.rb:8:in `block in from_file'

    execute("bundle install") do
      params {:path=>"/opt/newrelic/newrelic_aws_cloudwatch_plugin", :user=>"vagrant", :name=>nil}
      action [:run]
      default_guard_interpreter :execute
      command "bundle install --path vendor/bundle"
      backup 5
      cwd "/opt/newrelic/newrelic_aws_cloudwatch_plugin"
      returns 0
      user "vagrant"
      declared_type :execute
      cookbook_name "newrelic_plugins"
      recipe_name "aws_cloudwatch"
      domain nil
      only_if { #code block }
    end

    System Info:
    ------------
    chef_version=13.1.31
    platform=ubuntu
    platform_version=14.04
    ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
    program_name=chef-client worker: ppid=16392;start=19:44:47;
    executable=/opt/chef/bin/chef-client
sverch commented 7 years ago

The first output was because of the fact that chefdk by default uses the bundler that came with it rather than the system bundler. See https://github.com/chef/chef-dk/issues/16. The second issue is just a permissions issue that probably has to do with setting the path correctly. I'm using bundler 1.14.6 so I shouldn't be affected by https://github.com/bundler/bundler/issues/4521.