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

Case insensitive RMagick loading cases multiple require on Mac OS #1205

Closed
kochis opened this issue Aug 31, 2013 · 3 comments
Closed

Case insensitive RMagick loading cases multiple require on Mac OS #1205

kochis opened this issue Aug 31, 2013 · 3 comments

Comments

@kochis
Copy link
Contributor

kochis commented Aug 31, 2013

in carrierwave/processing/rmagick.rb

 module RMagick
      extend ActiveSupport::Concern

      included do
        begin
          require "rmagick"
        rescue LoadError
          require "RMagick"
        rescue LoadError => e
          e.message << " (You may need to install the rmagick gem)"
          raise e
        end
      end

Requiring the lowercase "rmagick" in Mac OS X causes "already initialized" warnings when other libraries require "RMagick".

/Users/kochis/.rvm/gems/ruby-2.0.0-p247@myapp/gems/rmagick-2.13.2/lib/RMagick.rb:44: warning: previous definition of PercentGeometry was here
/Users/kochis/.rvm/gems/ruby-2.0.0-p247@myapp/gems/rmagick-2.13.2/lib/rmagick.rb:45: warning: already initialized constant Magick::AspectGeometry
/Users/kochis/.rvm/gems/ruby-2.0.0-p247@myapp/gems/rmagick-2.13.2/lib/RMagick.rb:45: warning: previous definition of AspectGeometry was here
/Users/kochis/.rvm/gems/ruby-2.0.0-p247@myapp/gems/rmagick-2.13.2/lib/rmagick.rb:46: warning: already initialized constant Magick::LessGeometry
/Users/kochis/.rvm/gems/ruby-2.0.0-p247@myapp/gems/rmagick-2.13.2/lib/RMagick.rb:46: warning: previous definition of LessGeometry was here
...

The file in question being loaded is "RMagick.rb"

In this case, would it make sense to try the "RMagick" require first, and fall back to lowercase? Also, in a case insensitive filesystem, wouldn't it pick up the file either way?

Thanks.

@taavo
Copy link
Member

taavo commented Aug 31, 2013

I'm inclined to agree. @bensie?

For reference: we've been doing this since 5bb0e42, and, yup, rmagick uses a capitalized filename.

@kochis
Copy link
Contributor Author

kochis commented Aug 31, 2013

Just curious, would it make sense to just remove the require for the lowercase name? In a case-insensitive filesystem "RMagick" should still map to "rmagick". And if it were case sensitive, it wouldn't find the rmagick.rb file. Unless there's a case I'm not taking into account.

I have a fix I'm using right now in my fork: fix-rmagic-require-case-sensitivity

@bensie
Copy link
Member

bensie commented Sep 2, 2013

I'm inclined to remove the lowercase loader as well. Can't think of any reason that wouldn't work everywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants