Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

package plugins are included multiple times #274

Closed
jcopenha opened this Issue Oct 7, 2012 · 0 comments

Comments

Projects
None yet
2 participants
Contributor

jcopenha commented Oct 7, 2012

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.

prof-milki pushed a commit to prof-milki/xpm that referenced this issue Dec 18, 2014

- 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"

prof-milki pushed a commit to prof-milki/xpm that referenced this issue Dec 27, 2014

- 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"

jordansissel added a commit that referenced this issue Apr 24, 2015

- 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"

jordansissel added a commit that referenced this issue Jun 20, 2016

- 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment