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

Use require_relative to prevent encoding.rb from being loaded twice #618

Merged
merged 1 commit into from
Dec 31, 2013
Merged

Conversation

shanebonham
Copy link
Contributor

Ever since 2c321b2, I get this warning when loading up a console session:

/usr/local/Cellar/rbenv/0.4.0/versions/1.9.3-p429/lib/ruby/gems/1.9.1/gems/prawn-0.13.1/lib/prawn/encoding.rb:12:
warning: already initialized constant CHARACTERS

From what I can tell, this happens because prawn.rb now uses require_relative to load in the rest of the library. When it loads prawn/font, prawn/font/afm gets required, which in turn requires prawn/encoding. Next, prawn.rb loads prawn/encoding, which should be ignored, because it's already loaded, but what I find is that, for me, locally, require loads encoding.rb from /usr/local/opt/rbenv/{etc}, while require_relative loads it from /usr/local/Cellar/rbenv/{etc}.

These are the same files (I'm using rbenv and homebrew), but it seems like ruby doesn't realize that and tries to load both. This commit switches the require in afm.rb to use require_relative, which resolves the issue for me.

If there is an alternate way to resolve this, perhaps at a config level on just my system, I am all ears!

@practicingruby
Copy link
Member

This is fine, we want to switch to using requre_relative throughout the project now that 1.8 is no longer a concern. Will merge next time I'm working on stuff.

practicingruby added a commit that referenced this pull request Dec 31, 2013
Use require_relative to prevent encoding.rb from being loaded twice
@practicingruby practicingruby merged commit b02b951 into prawnpdf:master Dec 31, 2013
@practicingruby
Copy link
Member

Thanks again Shane, this has been merged into stable and will go out in a 0.13.2 release next Monday.

You've also been given commit access to Prawn! Please see this mailing list post for contribution guidelines.

@practicingruby
Copy link
Member

There were other files that were generating warnings too. Took care of those in 3f36909.

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

Successfully merging this pull request may close these issues.

2 participants