When --package not specified, throws Nil error, comment lies. #241

ghost opened this Issue Jul 27, 2012 · 2 comments


None yet

2 participants


In fpm/command.rb:331 there's this block with the comment saying that --package can be unspecified and package can be nil:

    # Write the output somewhere, package can be nil if no --package is specified,
    # and that's OK.
    rescue FPM::Package::FileAlreadyExists => e
      return 1

That comment is currently a lie:

/usr/local/lib/ruby/gems/1.9.1/gems/fpm-0.4.11/lib/fpm/package.rb:317:in `to_s': undefined method `gsub' for nil:NilClass (NoMethodError)
        from /usr/local/lib/ruby/gems/1.9.1/gems/fpm-0.4.11/lib/fpm/command.rb:334:in `execute'
        from /usr/local/lib/ruby/gems/1.9.1/gems/clamp-0.3.1/lib/clamp/command.rb:64:in `run'
        from /usr/local/lib/ruby/gems/1.9.1/gems/clamp-0.3.1/lib/clamp/command.rb:126:in `run'
        from /usr/local/lib/ruby/gems/1.9.1/gems/fpm-0.4.11/bin/fpm:8:in `<top (required)>'
        from /usr/local/bin/fpm:23:in `load'
        from /usr/local/bin/fpm:23:in `<main>'

When passed a nil fmt to to_s in package.rb its easy to see why the nil exception is thrown, since explicitly passing in nil is not the same thing as omitting the optional argument, so the default value is not applied:

  def to_s(fmt="NAME.TYPE")
    fullversion = version.to_s
    fullversion += "-#{iteration}" if iteration
    puts fmt
    return fmt.gsub("ARCH", architecture.to_s) \
      .gsub("NAME", name.to_s) \
      .gsub("FULLVERSION", fullversion) \
      .gsub("VERSION", version.to_s) \
      .gsub("ITERATION", iteration.to_s) \
      .gsub("EPOCH", epoch.to_s) \
      .gsub("TYPE", type.to_s)
  end # def to_s

This is when trying to do an fpm -s dir -t solaris


Hmm, when software lies! I'll take a look.


Fixed via f3bf4af

@r4um r4um closed this Mar 6, 2013
@prof-milki prof-milki pushed a commit to prof-milki/xpm that referenced this issue Dec 18, 2014
jls Force default package to_s when name given is nil (#241) 4beb165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment