-
Notifications
You must be signed in to change notification settings - Fork 6
Support loading data at runtime, or by configuring a different location for a preinstalled version #1
Comments
Maybe you want to synchronize with @coding-bunny, who attempts to replace mimemagic with another gem. This could also be a viable approach? |
I honestly see the alternative of using a different gem as a non-starter, since that gem only supports matching on file extension. |
There seems to be a parallel effort over here: https://github.com/Deradon/mimemagic/tree/fetch-mine-data-dynamically It might be useful to combine these efforts. |
The license file here seems to be GPLv2 which is a large part of the problem many have with the newest release of the original gem from my understanding. Is there any intent to find an older version to start this fork from that has a prior license option or will this fork require GPLv2? EDIT: This comment was made before I realized the yank of the older versions occurred due to files that were being used in the older version in a way that likely violated the license those files were released under. Please disregard. |
From my side it is okay to take the newest commit and revert back to MIT. But the tables.rb and freedesktop.org.xml must not be distributed as part of the gem. |
Digging into this further it seems that the XML file isn't the source of truth for this gem, but instead a Ruby class generated from that file, so there are in fact a few steps:
The parallel effort going on appears to just pull down the XML file at build time, rather than having it in source control, but the final gem will still include that file and therefore remain GPL licensed. |
@minad I'm seeing 4 test failures on master currently - are they expected?
|
I can at least comment on this having a history of monkey patching and instability. |
@jellybob You may also consider distributing a GPL-licensed package including freedesktop.xml+tables.rb+LICENSE. Then the gem could pull that at runtime, offloading the generation process somewhere else. These failures are probably due to using a newer database version and encoding changes in ruby. |
I don't want to have too many cooks in the kitchen, but couldn't we add an extconf.rb to the gem? It could download the xml file and generate the rb file when the gem is installed on target systems. No GPL code or files would be distributed with the gem. |
I don't think that really helps anything, as you're still pulling in a GPL dependency. I'm honestly a little bit dubious that pulling in the Freedesktop XML at runtime does much for strict license compliance as well - I'm attempting to get in touch with the maintainer of that file to ensure this approach does in fact result in a compliant gem. |
Just to revise that statement, I'm 90% confident that using a pre-existing install of the file is going to be safe, as there's no distribution or attempts to do an end run round GPL licensing involved in that, so I'll push on with that path. I'm less confident that including code that goes and downloads wouldn't be considered as against the spirit of the license. |
WDYT about this:
We could use pre_install_hooks when doing So the gem would not share any derived copies of GPL licenced work. |
How would that work on platforms using this gem that don't have the required XML files installed? |
I just thought about fetch the xml during gem install from https://gitlab.freedesktop.org/xdg/shared-mime-info/-/blob/2.1/data/freedesktop.org.xml.in. UPDATE: More or less doing a |
Given the generation doesn't actually take very long I'm inclined to do this at runtime - the alternative requires a bunch of hackery in a pre install hook, and potentially confusing error messages during the install. People who are concerned about the amount of time it might take to download the source file at runtime can make sure the machine they're running on has the file available before hand. |
At runtime would be a showblocker for any1 where the rails application is running w/o access to the public internet. (e.g. build docker image, which fetches data from public internet, then deploy it internally, where you don't have access) |
That's why there'll be the option to load a pre-existing version of the file via an environment variable. |
Seems like this approach still could trigger the GPL requirement. Here is a freedesktop contributor indicating that they believe the the GPL applies to the db/xml itself. |
Unless you're able to speak on behalf of freedesktop.org discussions of what the GPL does or does not require are just adding noise here. Please keep discussion to the actual implementation of the plan described. |
I linked to a thread where contributors to freedesktop.org are discussing exactly the issues that are also being discussed in this thread. It seemed like relevant information to take into consideration for the "plan described". Just trying to be helpful but I'll not add anymore "noise" 👍🏼 . |
Apologies for the slightly rough tone there. Just to clarify I'm talking to the maintainers at the moment about what would be needed (if its at all possible) to be compliant with both the legal terms of the license, and more generally the spirit of that license. |
There isn't anyone that can do that. Individual contributors hold their own copyright. I'm just but one of a number of contributors to the module where the
Both look good options to me, as long as the files are used as data files, and not use to create code from. Otherwise you should use the |
@hadess thanks for the reply. I believe the proposed solution falls within the usage you've described, so in lieu of anyone being able to definitively speak on this I'm going to go ahead and finish implementing this. |
For anyone following along at home, I think we can also skip over the whole thing of generating a Ruby class, and instead just parse the mime type database directly into constants. The generation of a source file is just an optimisation which doesn't really buy us anything if we're doing it all at runtime anyway. |
Thanks for the pointer @jellybob. I'm one of the people who runs freedesktop.org, but @hadess is correct. fd.o doesn't hold copyright assignments - the copyright belongs to whoever authored the code - so any decisions on copyright and licensing, including enforcement, are at the total discretion of the authors. In this case, @hadess holds substantial copyright on shared-mime-info so was entitled to take the action, and even if I wanted to I can't tell him otherwise. I agree with @hadess that your interpretation of the license is correct - with the caveat that I am not a lawyer. Transforming the GPLed XML definitions into Ruby certainly retains the GPL obligations and implications on that Ruby. Loading and parsing the data at runtime changes that situation in two ways:
Thanks so much for your co-operation and helpful attitude. We really appreciate it, especially given the additional burden it introduces on your users. |
I only have one request: please make sure this doesn't break things where it's possible for those of us who can use GPL2+ code to be able to include the data in the Gem. I'd like to still use the original mimemagic because it's simpler. :) |
Could we still use extconf.rb to download the xml just not generate a rb file? Downloading at runtime seems inefficient and introduces an external dependency to application boot. |
@jellybob I’m afraid we don’t have a canonical location for a post-processed file. To be honest I’m pretty glad we don’t, since we’re not behind a CDN or anything fancy ... there are a lot of Rails installs happening! Perhaps you could serve the post-processed from a GH repo alongside this one? AIUI the only difference is translations. |
Without having looked at that other PR (I'm trying to land one of my own for an unrelated and hopefully more fun thing), my suggestion would be to say something like: Install your operating system's shared-mime-info package, or fetch the XML file from the Debian package:
I would suggest to use |
In fact, if you use double quotes for the path, it runs on Windows verbatim:
So change the above to use double quotes and then the instructions work for every major OS. |
@ziggythehamster this is great, thank you, I've added instructions based on your exploration to the readme. |
Amazing work. Thanks for all your work on this @jellybob and others. I'm sure I speak for all of the community when I say I really appreciate it! 👍 |
As #3 has been merged already I'll copy my comment overhere: When releasing this as a |
Also copying my reply from that thread :) Yes, it will potentially break creating a new Rails project on Windows, but that feels like a better option than quietly imposing GPL 2 licensing on every new Rails project which is the current situation. We're also looking at yanking 0.3.6 because of those licensing implications, so in practice whatever happens here new Rails projects on Windows are going to be broken to some degree. Ultimately I don't think there's any way to avoid some degree of pain for users while still complying with license terms, and I consider abiding by those terms to take precedence for both legal and moral reasons. |
Mimemagic has been moved to its own org, so I'm also redirecting discussion of this to the repo over there, as shown above. Closing this one. |
@jellybob Just to let you know, can't comment yet on issues there.
Not sure if intended or not. |
@Deradon opening this one back up for now - they are indeed locked down temporarily while we get everything moved over and a release out to try and keep the noise down. |
I'd highly suggest to let the rails maintainers know when you release this version and what implications this release has. |
Yup, we will be doing that. |
Closing this issue now as 0.3.7 has been released. |
This has been discussed with both @hadess and @fooishbar, and yes, to the best of knowledge of all of us 0.3.7 is legitimately licensed as MIT since we no longer distribute any GPL licensed data with this gem. |
I indeed have done so :-) but thanks, that’s sufficient for a public answer here. |
@ljharb I'd be really curious to hear the outcome of that if you're happy to share it, either publicly or more privately. |
Same from the fd.o side; my email is daniel@fooishbar.org and Bastien's is pretty easily findable as well. It would be really good to understand what you've gleaned from this. We've worked with SFC before and they've always been extremely sensible. |
@hadess I wanted to ask about installing dependencies: https://github.com/mimemagicrb/mimemagic#dependencies. As far as I understand, installing those on production environment to use in my project forces my project's source code to be licensed under GPL? Basically shifting the licensing issue from |
I heavily doubt that. Look at the linux kernel running via GPLv2 in proprietary environments. IMO there |
@ipepe The license cares about "distribution". You can install whatever GPL'd code you want on the machine and use the tools together. As long as this gem, and your project, are not "distributed" with GPL-licensed code inside them, then it is safe. |
Seems to me the previously bundled version of the Freedesktop had some handling for docx files that is no longer handled with the standalone installer... I had to patch in some mimetypes in init of my rails app to get the same behavior as before. Used the init found here for what it's worth. |
No license lawyering please - unless you're someone able to speak on behalf of freedesktop.org your interpretation of the GPL isn't going to add anything to this conversation
See rails/rails#41750 and mimemagicrb#97 for background.
In order to cause minimal impact on existing users of the mimemagic gem, particularly people using Rails, I'm going to have it load MIME types from a preinstalled version of the Freedesktop MIME types database, rather than bundling one with the gem. This will require having a copy of that either installed with your distribution, or obtained in some other way. The availability of that will be checked at build time.
The text was updated successfully, but these errors were encountered: