LoginSignup
212
108

More than 3 years have passed since last update.

RailsのGPL混入問題についてまとめ(mimemagic)

Last updated at Posted at 2021-03-25

概要

RailsのGPL混入問題についてまとめました。間違いがあればご指摘ください。(2021/3/25現在)
https://github.com/rails/rails/issues/41750

ここには3つの問題がある。

  • Railsが依存しているmimemagicのライセンスがMITからGPL2.0になった
    • もともとGPLのものが混入していたのにMITになってしまっていた
  • これにより、Railsのbuildができなくなった
    • Railsが依存しているmimemagic0.3.5が削除されたことが原因
  • Railsの依存モジュールにGPLのものが混入することとなった
    • mimemagicを0.3.6以降にすればbuildはできるが、GPL問題は解決しない

mimemagicのライセンスがMITからGPL2.0になった

mimemagicはMITからGPLに変わった。
mimemagicのissues #97によると、

shared-mime-infoはGPL。
mimemagicの以下のファイルがshared-mime-info依存している。
https://github.com/minad/mimemagic/blob/master/script/freedesktop.org.xml

これまでmimemagicはMITだったが、shared-mime-infoがGPLなので、mimemagicもGPLにすべきであり修正された。
変更内容:https://github.com/minad/mimemagic/commit/c0f7b6b21a192629839db87612794d08f9ff7e88

Railsがbuildできない問題

前述のGPL問題修正により、Railsのbuildができない問題が起きた。
https://github.com/minad/mimemagic/issues/98

bundle installすると以下のエラーが発生する。

Installing dependencies using bundler 2.2.1
Running: bundle install --jobs=4 --retry=4

Your bundle is locked to mimemagic (0.3.5), but that version could not be found
in any of the sources listed in your Gemfile. If you haven't changed sources,
that means the author of mimemagic (0.3.5) has removed it. You'll need to update
your bundle to a version other than mimemagic (0.3.5) that hasn't been removed
in order to install.

Railsが依存しているmiemagicは0.3.5。これがbut that version could not be foundと言われる。削除されたみたい。

Railsの依存モジュールにGPL混入

0.3.6以上にすればbuildはできるようになるみたいだが、0.3.6も0.4.0もGPLなのでライセンス問題は解決されない。

GPLのソフトウェアをサーバサイドで使う場合の著作権表示について

GPLのソフトウェアをサーバサイドで使う場合の著作権表示について

GPLのライブラリをサーバサイドで使う場合、ソースコード公開義務はないという解釈が一般的です。

「サーバサイドで使えばプログラムの頒布じゃないからソースコード公開しなくていいじゃん!」という解釈のもと、ウェブサービスではGPLものが結構使われています。

どういうことかというと、ウェブサービスはプログラムの出力結果の頒布であって、プログラムの頒布ではないのでソースコードの公開義務はないという解釈です。
GCCでコンパイルされたバイナリを頒布してもソース公開義務がないのと同じ解釈です。

という解釈があるようだが、どうなんだろうか。

リンク

mimemagicがMITに戻った(3/26追記)

mimemagicの修正PR:Externalise source data #3

this PR removes it from the gem, and instead requires the user to provide one themselves.
Otherwise an environment variable will need to be set to point it in the right direction.

mimemagicに含まれるshared-mime-infoがGPL2.0だっため、これを取り除いたことによって、MITになった。
しかし、それを自分でインストールしないといけなくなった。

Place the file freedesktop.org.xml in an appropriate location, and then set the environment variable FREEDESKTOP_MIME_TYPES_PATH to that path.

How to fix

shared-mime-infoのインストール

shared-mime-info => MIME typesのデータベース。これがGPL2.0。
http://ftp.riken.jp/Linux/cern/centos/7/updates/x86_64/repoview/shared-mime-info.html

Linux

Linuxならshared-mime-infoはインストールされてるみたい。CentOS7ではインストールされていた。

$ yum list installed | grep shared-mime-info
shared-mime-info.x86_64         1.8-5.el7                 @centos-base

macOS

shared-mime-infoをインストールする。

$ brew install shared-mime-info
$ bundle update mimemagic

もしmimemagicのupgradeだけで動かない人は、nokogiriとmarcelもupgradeするといいかも。
参照:https://github.com/rails/rails/issues/41757#issuecomment-806938727

$ bundle update nokogiri marcel mimemagic

mimemagicを0.3.9にupgrade

$ bundle update mimemagic
$ git diff
diff --git a/Gemfile.lock b/Gemfile.lock
index cef0127..4a0ef93 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -133,7 +133,9 @@ GEM
     marcel (0.3.3)
       mimemagic (~> 0.3.2)
     method_source (1.0.0)
-    mimemagic (0.3.5)
+    mimemagic (0.3.9)
+      nokogiri (~> 1)
+      rake
     mini_mime (1.0.2)
     mini_portile2 (2.4.0)
     minitest (5.14.3)

shared-mime-infoのPATHを環境変数にセット

PATHは以下のあたりにある。参考:possible_paths

  • /usr/local/share/mime/packages/freedesktop.org.xml
  • /opt/homebrew/share/mime/packages/freedesktop.org.xml
  • /usr/share/mime/packages/freedesktop.org.xml

CentOS7では以下にあった。

$ ls -l /usr/share/mime/packages/freedesktop.org.xml
-rw-r--r-- 1 root root 2196823 Apr  1  2020 /usr/share/mime/packages/freedesktop.org.xml

Rails起動時にこれを環境変数 FREEDESKTOP_MIME_TYPES_PATH としてセットする。

$ FREEDESKTOP_MIME_TYPES_PATH=/usr/share/mime/packages/freedesktop.org.xml \
    bundle exec pumactl start

一応これで起動したし、問題はなさそうに見える。

これでよいのかrailsのIssueで聞いてみてる。(3/26 12:00現在)
https://github.com/rails/rails/issues/41757#issuecomment-807898051

Rails 5.2.5, 6.0.3.6, 6.1.3.1はmimemagicに依存しなくなった(3/27追記)

Rails 5.2.5, 6.0.3.6 and 6.1.3.1がリリースされ、これらはmimemagicに依存しなくなったのでアップグレードすればOK。

これらのRailsのversionは、Marcel 1.0.0に依存するようになった。
1.0.0以前は間接的にGPLに依存していたが、Apache License 2.0であるApache TikaのMIME type dataを使うように改造されたので、GPL依存でなくなった。

212
108
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
212
108