-
Notifications
You must be signed in to change notification settings - Fork 339
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
Figure out what to do when different versions of json
and json_pure
are loaded
#650
Comments
Normally I'd say the common parts should be in a separate gem json_base that both json and json_pure depend upon (with a strict version). If they tried to activate different versions it would be an error earlier in library management, and even better it would not silently appear to load ok and then break. However it would mean another gem in stdlib. The only other alternative is shipping the common parts namespaced too. |
Since this is an unsupported use-case, can they both define a version constant somewhere independent from each other? begin
require "json/pure/from_gem/version"
require "json/ext/version"
if JSON::Ext::VERSION != JSON::Pure::FromGem::VERSION
raise "Some descriptive error"
end
rescue LoadError
end This leaves people with older versions out of luck but maybe its acceptable? OTOH, loading different versions probably has just worked for a long time. |
Yet another such issue #652
Yeah, this is kinda the obvious / easy thing to do. But I wonder if it's really what should be done. I also wonder if the solution isn't simply to deprecate and remove After all, now that |
When I have some time, I'd like to go over look more into https://rubygems.org/gems/json_pure/reverse_dependencies, because at first sight I don't see a lot of legitimate use. So I think we could just push a |
Didn't we just have an issue where someone wanted to use json_pure because they deployed on a system without build tools? |
It was resolved by the fact that |
Mmh, but that requires to use the same version of json as in stdlib (which might not be an option if some bug fix or change is wanted) and recent Bundler always reinstalls default gems (json is a default gem): rubygems/rubygems#8180 Maybe we could have some documented env var (or a extconf.rb flag, should also work fine) to allow skipping the C extension when installing the |
Prior to 2.7.3, `JSON::Ext::Parser` would only take kwargs. So if json_pure 2.7.4 is loaded with `json <= 2.7.2` (or stdlib) it blows up. Ref: ruby/json#650 Fix: ruby/json#651 ruby/json@4d9dc98817
Prior to 2.7.3, `JSON::Ext::Parser` would only take kwargs. So if json_pure 2.7.4 is loaded with `json <= 2.7.2` (or stdlib) it blows up. Ref: ruby/json#650 Fix: ruby/json#651 ruby/json@4d9dc98817
Prior to 2.7.3, `JSON::Ext::Parser` would only take kwargs. So if json_pure 2.7.4 is loaded with `json <= 2.7.2` (or stdlib) it blows up. Ref: ruby/json#650 Fix: ruby/json#651 ruby/json@4d9dc98817
That would seem like the better solution, I need to research how this is generally done. |
There is |
One tricky thing if we don't build the extension (and kinda already is an issue with json_pure today) is that we can't just So we'd need to use |
Mmh, good point, maybe we should remember we skipped the extension then e.g. by creating some file under the installed gem directory. And if that file is there, don't attempt to require any extension. |
Seems brittle. I have a hard time trusting assumptions about how/when But I think we might be able to rely on |
It's the other way around, |
Arf, 😢 . I'm a bit out of idea then. |
Quick though: what if the Lines 16 to 17 in 4af700e
|
Right, I think that would work? We'd need to make sure these files are only included in the |
Fix: ruby#650 Ref: ruby#646 `json_pure` currently doesn't work well at all because `json/ext` is a default gem, so if you have code requiring `json/pure` and some other code requiring `json`, you end up with both loaded. If the `json` and `json_pure` versions match, it's not too bad, but if they don't match, you might run into issues with private APIs no longer matching.
Fix: ruby#650 Ref: ruby#646 `json_pure` currently doesn't work well at all because `json/ext` is a default gem, so if you have code requiring `json/pure` and some other code requiring `json`, you end up with both loaded. If the `json` and `json_pure` versions match, it's not too bad, but if they don't match, you might run into issues with private APIs no longer matching.
Fix: ruby#650 Ref: ruby#646 `json_pure` currently doesn't work well at all because `json/ext` is a default gem, so if you have code requiring `json/pure` and some other code requiring `json`, you end up with both loaded. If the `json` and `json_pure` versions match, it's not too bad, but if they don't match, you might run into issues with private APIs no longer matching.
Fix: ruby#650 Ref: ruby#646 `json_pure` currently doesn't work well at all because `json/ext` is a default gem, so if you have code requiring `json/pure` and some other code requiring `json`, you end up with both loaded. If the `json` and `json_pure` versions match, it's not too bad, but if they don't match, you might run into issues with private APIs no longer matching.
Fix: ruby#650 Ref: ruby#646 `json_pure` currently doesn't work well at all because `json/ext` is a default gem, so if you have code requiring `json/pure` and some other code requiring `json`, you end up with both loaded. If the `json` and `json_pure` versions match, it's not too bad, but if they don't match, you might run into issues with private APIs no longer matching.
Fix: ruby#650 Ref: ruby#646 `json_pure` currently doesn't work well at all because `json/ext` is a default gem, so if you have code requiring `json/pure` and some other code requiring `json`, you end up with both loaded. If the `json` and `json_pure` versions match, it's not too bad, but if they don't match, you might run into issues with private APIs no longer matching.
Maybe I'm getting more of the opinion that there shouldn't be any |
Fix: ruby#650 Ref: ruby#646 `json_pure` currently doesn't work well at all because `json/ext` is a default gem, so if you have code requiring `json/pure` and some other code requiring `json`, you end up with both loaded. If the `json` and `json_pure` versions match, it's not too bad, but if they don't match, you might run into issues with private APIs no longer matching.
I don't see the point of Without bundler, it's already installed anyways. So I guess you could use it bundler-less if you need the latest version for some reason? Or you just so happen to just not have |
Yeah, that's why I suggested to publish a final version of it that is just an empty gem that depends on But I'm not 100% sure of the consequences yet, so I think I'll delay this to the 3.0, and for 2.8 I'll do #682 |
Fix: ruby#650 Ref: ruby#646 `json_pure` currently doesn't work well at all because `json/ext` is a default gem, so if you have code requiring `json/pure` and some other code requiring `json`, you end up with both loaded. If the `json` and `json_pure` versions match, it's not too bad, but if they don't match, you might run into issues with private APIs no longer matching.
Fix: ruby#650 Ref: ruby#646 `json_pure` currently doesn't work well at all because `json/ext` is a default gem, so if you have code requiring `json/pure` and some other code requiring `json`, you end up with both loaded. If the `json` and `json_pure` versions match, it's not too bad, but if they don't match, you might run into issues with private APIs no longer matching.
Alright, I released |
Doesn't depending on |
Right... |
Fixed in 2.8.1. |
I wasn't quick enough to comment on the PR, appologies. Easy fix at least |
Ref: #646
There is no version constraints between the two, but they expose the same files in
$LOAD_PATH
, so if two different versions are loaded it can easily cause incompatibilities.We should find a solution for this. Perhaps use
require_relative
? But even then, large parts of the implementation are in the globalJSON
module, so we can't load two namespaced versions of it.The text was updated successfully, but these errors were encountered: