Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem installing after initial install #29

Open
vernak2539 opened this issue Feb 2, 2017 · 7 comments
Open

Problem installing after initial install #29

vernak2539 opened this issue Feb 2, 2017 · 7 comments

Comments

@vernak2539
Copy link

I'm having some trouble getting the pm2 chef install to work. It's been working fine, but seems to have just stopped. I've put the error below and the different attributes I've tried.

Have been able to replicate using test kitchen, and it seems to happen after the original "chef" of the image/box.

Any help would be much appreciated!

Try 1 Attributes

default['pm2']['node_version'] = '6.5.0'

Try 2 Attributes

default['pm2']['node_version'] = '6.5.0'
default['pm2']['npm_version'] = '4.1.1'

Try 3 Attributes

default['pm2']['node_version'] = '6.5.0'
default['pm2']['npm_version'] = '4.1.2'
Recipe: pm2::default
  * javascript_runtime[node] action install
    * poise_languages_static[/opt/nodejs-6.5.0] action install
      * poise_archive[/var/chef/cache/node-v6.5.0-linux-x64.tar.gz] action nothing (skipped due to action :nothing)
      * remote_file[/var/chef/cache/node-v6.5.0-linux-x64.tar.gz] action create (up to date)
      * directory[/opt/nodejs-6.5.0] action create (up to date)
       (up to date)
     (up to date)
  * node_package[pm2] action install

    ================================================================================
    Error executing action `install` on resource 'node_package[pm2]'
    ================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0], but received '1'
    ---- Begin output of ["/opt/nodejs-6.5.0/bin/node", "/opt/nodejs-6.5.0/bin/npm", "outdated", "--json", "--global"] ----
    STDOUT: {
      "npm": {
        "current": "4.1.1",
        "wanted": "4.1.2",
        "latest": "4.1.2",
        "location": "/opt/nodejs-6.5.0/lib/node_modules/npm"
      }
    }
    STDERR:
    ---- End output of ["/opt/nodejs-6.5.0/bin/node", "/opt/nodejs-6.5.0/bin/npm", "outdated", "--json", "--global"] ----
    Ran ["/opt/nodejs-6.5.0/bin/node", "/opt/nodejs-6.5.0/bin/npm", "outdated", "--json", "--global"] returned 1

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/poise-languages/files/halite_gem/poise_languages/command/mixin.rb:207:in `tap'
    /var/chef/cache/cookbooks/poise-languages/files/halite_gem/poise_languages/command/mixin.rb:207:in `language_command_shell_out!'
    /var/chef/cache/cookbooks/poise-languages/files/halite_gem/poise_languages/command/mixin.rb:222:in `block in language_command_mixin'
    /var/chef/cache/cookbooks/poise-javascript/files/halite_gem/poise_javascript/resources/node_package.rb:213:in `npm_shell_out!'
    /var/chef/cache/cookbooks/poise-javascript/files/halite_gem/poise_javascript/resources/node_package.rb:128:in `check_package_versions'
    /var/chef/cache/cookbooks/poise-javascript/files/halite_gem/poise_javascript/resources/node_package.rb:106:in `load_current_resource'
    /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:78:in `run_action'
    /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block (2 levels) in converge'
    /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `each'
    /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block in converge'
    /var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:105:in `converge'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/pm2/recipes/default.rb

     18:   node_package pkg do
     19:     version node['pm2']["#{pkg}_version"] unless node['pm2']["#{pkg}_version"].nil?
     20:   end
     21: end

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/pm2/recipes/default.rb:18:in `block in from_file'

    node_package("pm2") do
      package_name "pm2"
      action [:install]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :node_package
      cookbook_name "pm2"
      recipe_name "default"
      version "latest"
      parent_javascript javascript_runtime[node]
      npm_binary "/opt/nodejs-6.5.0/bin/npm"
      timeout 900
    end

    Platform:
    ---------
    x86_64-linux
@miguelcnf
Copy link
Contributor

Hi @vernak2539,

This is related to poise/poise-javascript#4.

In a nutshell, npm versions > 4.x return 1 on the outdated check command if any outdated module is found, to which the poise-javascript handle as a failure.

If you're doing a clean install, a nasty workaround is to pin your npm version (by setting node['pm2']['npm_version']) to 3.10.10 - but this won't work if you're re-converging a node unless you remove the node npm module installed and correspondent symlink from /usr/sbin/.

Not quite sure how we should handle this from the pm2 cookbook point of view, we could potentially pin the npm version on this cookbook but that won't converge successfully on re-converges.

@miguelcnf
Copy link
Contributor

To clarify, if you pin your npm version to < 4.x on an initial install, any re-converge will succeed.

It is just if you have a node with npm version > 4.x that any re-converge would fail.

@vernak2539
Copy link
Author

Okay, that all makes sense. Thanks for the info! The thing is the box we're using is being "re-converged".

What do you think would be a potential workaround? Remove npm directory before the pm2 install? Open to all suggestions. Will try stuff today to figure it out

@vernak2539
Copy link
Author

Also, I tried to do a "clean install" by removing all references to node and npm, the symlink was a think I wouldn't have caught for a while, so thanks for that. But, I also had to delete the following folder to get it to work /opt/nodejs-X.X.X. Just for other people if they're doing this

@swapnil-jaiswal
Copy link

swapnil-jaiswal commented Apr 19, 2017

Sorry for the late response but i think i solved this issue using a minor code change;
Following code snippet replaces the equivalent block in the default.rb recipe in pm2 cookbook.

Two thing to keep in mind :

  1. .pm2 folder path should be updated as per your application user
  2. This fix will work only if you are starting pm2 in your 1st chef run ( we use it via our deploy recipe)
%w(pm2 npm).each do |pkg|
  unless File.exist?("/home/not-deploy/.pm2")
    node_package pkg do
      version node['pm2']["#{pkg}_version"] unless node['pm2']["#{pkg}_version"].nil?
      #version node['pm2']["#{pkg}_version"] unless File.exist?("/home/not-deploy/.pm2")
      timeout 120
    end
  end
end

@PavelPenkov
Copy link

So as far as I understand this cookbook is essentially unusable? I can't get even the simplest recipe https://gist.github.com/PavelPenkov/f35e595ed48f30eeaa8d4e360dd29a8e to work.

@miguelcnf
Copy link
Contributor

This cookbook is no longer actively maintained, as such I've marked it for adoption on supermarket.

Will gladly transfer ownership to anyone that's able to perform active maintenance tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants