ruby-rdf / linkeddata

A metadistribution of RDF.rb including all parsing/serialization plugins.
http://rubygems.org/gems/linkeddata
The Unlicense
51 stars 9 forks source link

linkeddata 3.2.1 no longer compatible with Rails older than 6.1, 3.2.0 was #16

Open jrochkind opened 2 years ago

jrochkind commented 2 years ago

linkeddata 3.2.1 has a (transitive) dependency on psych 4.x. Via yaml-ld (~> 0.0) the only released version of yaml-ld is 0.0.1, which depends on psych (~> 4.0).

Psych 4.x was released with ruby 3.1, although it can be used with older rubies too.

As far as I can tell,Psych 4.x is not compatible with Rails earlier than 6.1 -- Rails 6.0 and earlier are incompatible with psych 4.x. However, linkeddata 3.2.1 requires psych 4.x, via transitive dependency. Therefore, linkeddata 3.2.1 is incompatible with Rails earlier than 6.1.

linkeddata 3.2.0 did not express an explicit dependency on psych, so was compatible with earlier Rails.

Is this intentional/desirable? Can it be fixed?

It's breaking some of our builds at eg https://github.com/samvera/questioning_authority/pull/374. Bundler ought to be smart enough to resolve linkeddata to 3.2.0 and build a consistent tree.... but apparently isn't (these built-in gems are kind of a mess), and even if it was, it would be a shame to be stuck using old linkeddata.

Appreciate any thoughts from maintainers here. @gkellogg ?

gkellogg commented 2 years ago

I wasn't aware of this issue, as the build on 2.6 doesn't catch the issue. Even adding a runtime dependency on rails 6.0.0 doesn't show a problem installing gems.

I suspect that I can change the yaml-ld requirement to some lower version, but it's not clear to me where the actual dependency is. What would would you like to see for a psych version dependency, and I can check it out and release an update to the yaml-ld and linkeddata gems.

gkellogg commented 2 years ago

With some changes I can make it work on psych '>= 3.3', will that do?

jrochkind commented 2 years ago

This is all extra confusing, because a) psych is such a weird dependency as a "default" gem, and b) it appears to be a bug in bundler in our extra-complex case involving "engine_cart" (which I'm not a fan of), which actually makes the build fail.

psych is a "default" gem.

This means you don't actually have to express it as an explicit dependency at all.. https://stdgems.org/

If you don't express it as an explicit dependency, it's still there, and can be used with a simple require "psych" (without the gem dependency). You'll get whatever version of psych was included with the version of ruby you were using. (Which is some psych 3.x for ruby previous to 3.1, and some psych 4.x for ruby 3.1).

This was the case with linkeddata 3.2.0. So our app would just use whatever version of psych came with the version of ruby being used.

But as soon as psych is listed anywhere in your dependency tree explicitly, now it will use the version of psych necessary to satisfy that dependency.

So one question is if it's necessary to list psych as an explicit dependency at all. I just saw your comment about psych >= 3.3.... it looks like ruby 2.5.9 actually came with psych 3.0.2, so if you need a more recent psych for some reason but still want to work with ruby 2.5 (which is out of support btw, but still), I guess that's the answer to why you had to start listing it explicitly?

Default gems make things really confusing.

Bundler bug

Now, if bundler was working properly, and we had a project that expressed a dependency on both psych, "~> 3.0", AND linkeddata (any version) -- bundler would just install linkeddata 3.2.0, because that's the latest one compatible with our expressed psych dependency.

But for some reason bundler was failing to do that, and instaed saying it couldn't find compatible versions to install. Some kind of a bug in bundler triggered by our weird setup.

Even if bundler worked as expected, I don't know if it would be ideal that you could not use linkeddata 3.2.1 with Rails 6.0, but could use linkeddata 3.2.0.

Rails weirdness

Rails 6.0 doesn't say it requires psych < 4 -- it just breaks in some cases with psych 4. Maybe not in a case you had though. But I ran into this one: https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias. (Rails fixed it in a Rails 6.1 and Rails 7.0 release, but not a Rails 6.0 or 5.2 release, as those are unmaintained I guess).

What versions?

For my own situation I'm in presently, if you allow psych >= 3.3, that will work, yes. And allow me to use the latest linkeddata, even with Rails 5.2-6.0. This is all so confusing it's hard to say if it will cause problems in what situations, but in my exact present situation I believe my tests say, yes, psych >= 3.3 would allow me to use latest version of linkeddata and have everything work.

For future safety, you might want to say psych, ">= 3.3", "< 5"

gkellogg commented 2 years ago

I updated the gem and release version 0.0.2 with psych ">= 3.3"; given that this is such an early release, probably don't need to do more than that right now.

Your builds should work now.

jrochkind commented 2 years ago

Thank you!

While yaml-ld is an early release... it's a dependency of linkeddata which is an old mature gem, that some of our apps have been using for years. I don't actually love that the latest release of linkeddata pulls in a 0.0.1 release of an immature gem, that is now in my codebase, but I guess that's how things go!

gkellogg commented 2 years ago

The linkeddata gem is specifically intended to be a meta-release that requires all the various gems in the eco-system. This undoubtedly includes many not necessary for every application. Consider requiring the specific gems you need directly, which will also significantly reduce your image size, if that's important.

Even though the yaml-ld gem is recent, it's largely a shim for json-ld and does not introduce significant new capabilities beyond being able to parse and serialize YAML.

jrochkind commented 2 years ago

Ah, thanks that's helpful to know! linkeddata is a dependency of a very "legacy" codebase I am trying to help maintain, but don't really understand how it uses the linkeddata gem for what. I am not familiar with the parts of this codebase that actually use linkeddata (I use other parts myself), and mostly only interact with it when trying to deal with dependency conflict issues, as here. Legacy code can be challenging! But good to know that it might be desirable to depend on more specific sub-parts, if I or someone else can figure out what parts are needed!

jrochkind commented 2 years ago

For what it's worth, I began trying to investigate if I could replace use of linkeddata with more specific gems in the questioning_authority gem. When I remove linkeddata from my dependencies and try to run my tests... I get an error suggesting the use of the linkeddata gem!

       RDF::FormatError:
         unknown RDF format: {:file_name=>"/Users/jrochkind/code/questioning_authority/spec/fixtures/lexvo_snippet.rdf.xml"}
         This may be resolved with a require of the 'linkeddata' gem.

Still seeing if I can work through it though, from that particular error I'm guessing maybe I need rdf-rdfxml. But I thought it was noteable that the error message recommends the linkeddata gem!

gkellogg commented 2 years ago

It is a catch all message, basically saying it doesn’t have a format loaded to handle that extension, so it can’t recommend any single one. In this case, try the rdf-rdfxml gem.

depending on what the general purpose of the gem is, others might be json-ld, rdf-turtle, rdf-rdfa, and rdf-microdata.