voxpupuli / puppet-nodejs

Puppet module to install nodejs and global npm packages
https://forge.puppet.com/puppet/nodejs
Apache License 2.0
113 stars 248 forks source link

Using third party repo on Debian (11) does not work correctly #475

Open sid3windr opened 1 year ago

sid3windr commented 1 year ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

  class { '::nodejs':
    repo_url_suffix     => '16.x',
    manage_package_repo => true,
  }

What are you seeing

Starting from a machine which has no node or npm installed at all.

On the first Puppet run when adding the nodejs class to the machine, the nodesource apt repo configuration is added. Node is installed from Debian sources (not the 3rd party repo) along with a zillion node-* support packages. The npm package is pulled in by this, I believe, then removed by the Puppet module at the end of the run.

I run apt-get upgrade to install available updates. This, now using the nodesource apt repo, will remove all packages pulled in earlier and replace them by a single nodejs package in version 16, as requested.

On every Puppet run after this upgrade happened, the module now tries to install the npm package from Debian's repositories, which conflicts with the nodesource nodejs package (which already contains its own npm, it is not a separate package). The Puppet run fails due to this error.

Setting npm_package_ensure to absent makes no difference to this behaviour.

What behaviour did you expect instead

Installation of node v16 (preferrably immediately), but more importantly, non-failing Puppet runs after this has happened.

Output log

Info: Applying configuration version '1687605455'
Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install npm' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libnode72 : Conflicts: nodejs-legacy
 nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages.
cruelsmith commented 1 year ago

Duplicate of #452 See https://github.com/voxpupuli/puppet-nodejs/issues/452#issuecomment-1620245201 for a workaround

sid3windr commented 1 year ago

The outcome is markedly differnet though, in the case of #452 npm and because of that nodejs is removed again but their Puppet run is not broken. This is not the case in my output above - the module in fact tries to install npm when it shouldn't, failing the run.

Setting npm_package_name to false (both through class parameter and hiera) does not fix this situation either - it tries to do exactly the same, and the run still fails.

Info: Applying configuration version '1688501423'
Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install npm' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libnode72 : Conflicts: nodejs-legacy
 nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages.
Error: /Stage[main]/Main/Package[yarn]/ensure: change from 'purged' to 'present' failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install npm' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libnode72 : Conflicts: nodejs-legacy
 nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages. (corrective)
Info: Class[Main]: Unscheduling all events on Class[Main]
Info: Stage[main]: Unscheduling all events on Stage[main]
Notice: Applied catalog in 20.88 seconds