puppetlabs/puppet · error · Puppet::Error

Package %{name} was not present after trying to install it

Error message

Package %{name} was not present after trying to install it

What it means

The urpmi (Mandriva/Mandrake) provider runs 'urpmi --auto <name>' (appending -<version> when pinned; epochs are not handled) and then verifies via query; if the package still is not installed it raises Puppet::Error 'Package ... was not present after trying to install it'. urpmi can exit without error while installing nothing when no configured medium provides the package.

Source

Thrown at lib/puppet/provider/package/urpmi.rb:28

  def install
    should = @resource.should(:ensure)
    debug "Ensuring => #{should}"
    wanted = @resource[:name]

    # XXX: We don't actually deal with epochs here.
    case should
    when true, false, Symbol
      # pass
    else
      # Add the package version
      wanted += "-#{should}"
    end

    urpmi "--auto", wanted

    unless query
      raise Puppet::Error, _("Package %{name} was not present after trying to install it") % { name: name }
    end
  end

  # What's the latest package version available?
  def latest
    output = urpmq "-S", @resource[:name]

    if output =~ /^#{Regexp.escape @resource[:name]}\s+:\s+.*\(\s+(\S+)\s+\)/
      Regexp.last_match(1)
    else
      # urpmi didn't find updates, pretend the current
      # version is the latest
      @resource[:ensure]
    end
  end

  def update
    # Install in urpmi can be used for update, too

View on GitHub (pinned to e227c27540)

Solutions

  1. Run 'urpmi --auto <name>' manually and read why nothing was installed
  2. Refresh media with 'urpmi.update -a' and repair dead mirror entries in /etc/urpmi/urpmi.cfg
  3. Confirm resolvability with 'urpmq <name>' and drop the version pin (epochs unsupported by this provider)
  4. On EOL Mandriva, host the rpm locally and manage it with provider rpm plus a source path

Example fix

// before
package { 'apache-mod_php':
  ensure   => '5.3.5-0.1mdv2010.2',
  provider => urpmi,
}
// after - pin dropped to what the medium actually provides
package { 'apache-mod_php':
  ensure   => installed,
  provider => urpmi,
}
Defensive patterns

Strategy: retry

Validate before calling

# Ruby: confirm urpmq can resolve the package before install
def urpmi_resolves?(name)
  out = Puppet::Util::Execution.execute(['urpmq', '-S', name], failonfail: false).to_s
  out !~ /no package/i && !out.strip.empty?
end

Try / catch

retries ||= 0
begin
  provider.install
rescue Puppet::Error => e
  raise unless e.message =~ /was not present after trying to install/ && (retries += 1) == 1
  Puppet::Util::Execution.execute(['urpmi.update', '-a'], failonfail: false)
  retry
end

Prevention

When it happens

Trigger: ensure => installed or pinned with provider => urpmi on Mandriva/Mandrake where the package (or the composed name-version string) is not in any medium, or media lists are stale because 'urpmi.update -a' was never run.

Common situations: Mandriva 2008-2010 era hosts with dead FTP mirrors in /etc/urpmi/urpmi.cfg; pinned versions with epoch prefixes that break the appended '-version'; media sync never scheduled.

Related errors


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/e07d9f24455cea8d. Report an issue: GitHub.