-
Notifications
You must be signed in to change notification settings - Fork 204
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
avoid false const warnings (when using bundler) #390
Conversation
Bundler will load YAML and thus Psych, which causes versions.rb to be required, but it also loads the psych.gemspec ... in such case, the reported version constants might not be accurate and also causes warnings due double loading of the same versions.rb
(see previous commit for explanation)
I did not investigate into the problem this is supposed to solve (possibly a problem of bundler?), but parsing a Ruby file using regular expressions instead of simply require‘ing it seems really wrong. Also, the proposed change does not consider the special treatment necessary for the core repository. |
This is interesting. We have this longstanding PR in bundler that seems to be somehow related. How can this problem be reproduced? |
any objections to merge this one? |
I tried a better fix on #433 but I'm still unsure how to reliably reproduce these warnings... 🤔 |
vaguely recall these came while doing day-to-day dev on JRuby and than installing a custom psych. #433 might do - the gist of the changes were to not load any files from the gem while reading the spec and #433 keeps loading version.rb which than would be the source of confusion about the version used (if it gets loaded again as a bundled dependency). agree, should have had a reproducer. |
Ok, I can reliably reproduce it now. Do On master
On my branch
The problem is that when loading the gemspec, I think it's fine to load the version file from the gemspec as #433 do. Most gems out there do it and it works fine. Note that it's only for "development", once a gem is pushed to rubygems.org and installed, the gemspec has the correct version and does not load any external files. The only thing special about |
Thanks for looking into it David, closing in favor of #433 |
Bundler will load YAML and thus Psych, which causes versions.rb to be
required, but than it also loads the psych.gemspec ... (loading .rb twice)
in such case, the reported version constants might not be accurate
and also causes warnings due double loading of the same versions.rb
this is really annoying and the
unless defined?(VERSION)
is not really a good solution(have been confused by the psych version used - depends on LOAD_PATH entries order)