Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

package plugins are included multiple times #274

Closed
jcopenha opened this Issue · 0 comments

2 participants

@jcopenha

fpm.rb has explicit requires for each package (package/deb, package/rpm, etc) and then in command.rb there is code to enumerate the files in the package directory and load any ruby files found. Because the code in command.rb gives an explicit path to these files all of the plugins end up getting included twice.

This causes the need for the unless defined?(foo) stuff seen in the RPM, DEB classes, etc. And is the result of the following warning:

/Library/Ruby/Gems/1.8/gems/fpm-0.4.20/lib/fpm/package/deb.rb:23: warning: already initialized constant COMPRESSION_TYPES

since COMPRESSION_TYPES is missing the unless defined?(COMPRESSION_TYPES) code.

It also results in all of the command line options being displayed twice.

Since I'm new to Ruby I'm not sure of the best approach to solve this but have come across the following solutions.

  1. Carefully wrap any class initialization in if not defined?(foo) blocks so it only happens once.
  2. Change the code in command.rb to check and see if something similar to what it is about to load is already loaded.
  3. change fpm.rb to use statements like require File.expand_path("fpm/package/python", File.dirname( __FILE__)). This will make sure that it uses an explicit path just like in command.rb and hence Ruby will correctly detect that it is already loaded and not load it again.

I'm happy to submit pull requests for any of the approaches but wanted to solicit advice on the most Ruby-esque approach.

@jordansissel jordansissel closed this issue from a commit
@jordansissel - Fix #274 by requiring relative to the library load path, not the
  explicit full file path.

  This solves these errors:
    "warning: already initialized constant COMPRESSION_TYPES"
0771de9
@prof-milki prof-milki referenced this issue from a commit in prof-milki/xpm
jls - Fix #274 by requiring relative to the library load path, not the
  explicit full file path.

  This solves these errors:
    "warning: already initialized constant COMPRESSION_TYPES"
a2df80c
@prof-milki prof-milki referenced this issue from a commit in prof-milki/xpm
@jordansissel - Fix #274 by requiring relative to the library load path, not the
  explicit full file path.

  This solves these errors:
    "warning: already initialized constant COMPRESSION_TYPES"
ea34ec2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.