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

Can't ensure latest if package is not instatlled #158

Closed
nibalizer opened this issue Aug 12, 2015 · 6 comments
Closed

Can't ensure latest if package is not instatlled #158

nibalizer opened this issue Aug 12, 2015 · 6 comments
Labels
bug Something isn't working

Comments

@nibalizer
Copy link
Member

Using the nodejs::npm type I have the following experience. When setting ensure => latest on a package that is not installed, I get the following error:

package { 'express':
  ensure   => 'latest',
  provider => 'npm',
}
Error: Could not update: Got nil value for ensure
Error: /Stage[main]/Main/Package[express]/ensure: change from absent to latest failed: Could not update: Got nil value for ensure

Changing to:

package { 'express':
  ensure   => 'present',
  provider => 'npm',
}

I can then successfully install it. Then changing it to latest and running again works.

@nibalizer
Copy link
Member Author

I'm pretty sure the issue is in 'npm outdated -g ' because this doesn't print anything if the package is not installed.

npm view version prints the latest stable version whether the package is installed or not.

@juniorsysadmin juniorsysadmin added the bug Something isn't working label Nov 16, 2015
@waynr
Copy link

waynr commented Nov 18, 2015

I just ran into this also, I opted to pin to a concrete version which seems to work fine.

@joelgarboden
Copy link

According to my research and testing (using Puppet 3.8.2).

Changing the latest definition to

  def latest
    npm('view', resource[:name], "version").strip
  end

And changing update to

 def update
    self.install
 end

Resolves this issue, I tested extensively with the tar npm package. Present, latest, absent, explicit version, downgrades, and upgrades all work.

@igalic
Copy link
Contributor

igalic commented Jan 19, 2016

@joelgarboden would you like to make a patch for that?

@joelgarboden
Copy link

@igalic #199

Looks like tests pass, except for a robocop setting warning for Puppet 4.0, which I believe are unrelated to my changes.

@juniorsysadmin
Copy link
Member

Fixed in #199

joshuaspence pushed a commit to joshuaspence/dotfiles that referenced this issue Feb 15, 2016
The latest commit hash contains a fix for voxpupuli/puppet-nodejs#158.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants