mroonga / homebrew-mroonga

The homebrew formula for Mroonga.
7 stars 13 forks source link

Homebrewでのインストールに失敗します。 #22

Closed fugtat closed 2 years ago

fugtat commented 2 years ago

実行コマンド:

brew tap mroonga/mroonga 
brew install mroonga --with-homebrew-mariadb

Homebrew 3.3.9 MacOS 11.5.2

エラーとなっている? 02.makeが長すぎるので添付ファイルにしています。 独力で原因が解明できませんでした。よろしければご助力ください。

02.make.txt

kou commented 2 years ago

Mroongaのビルドに行く前のRocksDBのビルドでエラーになっていました。 たぶん、brew install --build-from-source mariadbでも再現すると思います。

brew install mroonga --with-homebrew-mysqlならいけるかもしれません。

fugtat commented 2 years ago

アドバイスありがとうございます。 brew install mroonga --with-homebrew-mysqlとしてみると、また別種のエラーが出てしまいましたのでご報告します。ninjaによるビルド中のエラーでしょうか。

Last 15 lines from /Users/kojima/Library/Logs/Homebrew/mroonga/02.ninja:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/optional:158:
/tmp/mroonga-20220106-72777-s7ffh4/mroonga-11.06/version:1:1: error: expected unqualified-id
11.06
^
In file included from /tmp/mroonga-20220106-72777-s7ffh4/mroonga-11.06/ha_mroonga.cpp:24:
In file included from /tmp/mroonga-20220106-72777-s7ffh4/mroonga-11.06/mrn_mysql.h:58:
In file included from /tmp/mysql-20220106-72777-h4sg5s/mysql-8.0.27/sql/sql_class.h:53:
In file included from /tmp/mysql-20220106-72777-h4sg5s/mysql-8.0.27/include/map_helpers.h:26:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/map:489:
/tmp/mroonga-20220106-72777-s7ffh4/mroonga-11.06/version:1:1: error: expected unqualified-id
11.06
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
ninja: build stopped: subcommand failed.

02.ninja.txt

kou commented 2 years ago

これは最新のMroongaだと直してあるやつなので最新のMroongaを使うようにしました。 もう一度brew install mroonga --with-homebrew-mysqlを実行してもらえますか?それでもMroonga 11.06を使っていそうならbrew tap mroonga/mroongaをすると確実に新しくなると思うので同じエラーになったらbrew tap mroonga/mroongaしてからもう一度brew installしてみてください。

あと、MariaDBの方のエラーをよく見てみたらRocksDBのエラーではなく古いBison(システムにインストールされているBison)を使っていることによるエラーだったのでHomebrewでインストールできる新しいBisonを使うようにしました。これで--with-homebrew-mariadbのときの該当のエラーは解消されるはずです。

fugtat commented 2 years ago

ありがとうございます。 MariaDB・MySQLともに、一旦Homebrewごとアンインストールした上で試してみました。

まずMariaDBの方ですが、まだ以下のエラーが出てしまいます。

brew tap mroonga/mroonga 
brew install mroonga --with-homebrew-mariadb
Last 15 lines from /Users/kojima/Library/Logs/Homebrew/mroonga/02.ninja:
In file included from /tmp/mariadb-20220106-15600-1bho9bc/mariadb-10.6.4/sql/log.h:21:
In file included from /tmp/mariadb-20220106-15600-1bho9bc/mariadb-10.6.4/sql/wsrep_mysqld.h:40:
In file included from /tmp/mariadb-20220106-15600-1bho9bc/mariadb-10.6.4/wsrep-lib/include/wsrep/provider.hpp:26:
In file included from /tmp/mariadb-20220106-15600-1bho9bc/mariadb-10.6.4/wsrep-lib/include/wsrep/client_id.hpp:23:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/ostream:140:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include/c++/v1/locale:189:
/tmp/mariadb-20220106-15600-1bho9bc/mariadb-10.6.4/version:1:1: error: expected unqualified-id
MYSQL_VERSION_MAJOR=10
^
/tmp/mariadb-20220106-15600-1bho9bc/mariadb-10.6.4/include/my_config.h:530:29: note: expanded from macro 'MYSQL_VERSION_MAJOR'
#define MYSQL_VERSION_MAJOR 10
                            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
ninja: build stopped: subcommand failed.

02.ninja.txt

次にMySQL、こちらは一応最後まで行きますがやはり失敗しているようです。

brew tap mroonga/mroonga 
brew install mroonga --with-homebrew-mysql
==> cmake .. -G Ninja -DMYSQL_SOURCE_DIR=/private/tmp/mysql-20220106-38706-i9xp3w/mysql-8.0.27 -DMYSQL_CONFIG=/usr/local/Cellar/mysql/8.0.27_1/bin/mysql_config
==> ninja install
Warning: Tried to install empty array to /usr/local/Cellar/mroonga/11.11/share/mroonga
==> mysql -uroot < '/usr/local/Cellar/mroonga/11.11/share/mroonga/install.sql' || true
oo many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
ninja: build stopped: subcommand failed.==> Caveats
To confirm successfuly installed, run the following command
and confirm that 'Mroonga' is in the list:

   mysql> SHOW PLUGINS;
   +---------+--------+----------------+---------------+---------+
   | Name    | Status | Type           | Library       | License |
   +---------+--------+----------------+---------------+---------+
   | ...     | ...    | ...            | ...           | ...     |
   | Mroonga | ACTIVE | STORAGE ENGINE | ha_mroonga.so | GPL     |
   +---------+--------+----------------+---------------+---------+
   XX rows in set (0.00 sec)

To install Mroonga plugin manually, run the following command:
   mysql -uroot < '/usr/local/opt/mroonga/share/mroonga/install.sql'

To uninstall Mroonga plugin, run the following command:
   mysql -uroot < '/usr/local/opt/mroonga/share/mroonga/uninstall.sql'
==> Summary
🍺  /usr/local/Cellar/mroonga/11.11: 8 files, 479.8KB, built in 10 minutes 18 seconds
==> Running `brew cleanup mroonga`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> mroonga
To confirm successfuly installed, run the following command
and confirm that 'Mroonga' is in the list:

   mysql> SHOW PLUGINS;
   +---------+--------+----------------+---------------+---------+
   | Name    | Status | Type           | Library       | License |
   +---------+--------+----------------+---------------+---------+
   | ...     | ...    | ...            | ...           | ...     |
   | Mroonga | ACTIVE | STORAGE ENGINE | ha_mroonga.so | GPL     |
   +---------+--------+----------------+---------------+---------+
   XX rows in set (0.00 sec)

To install Mroonga plugin manually, run the following command:
   mysql -uroot < '/usr/local/opt/mroonga/share/mroonga/install.sql'

To uninstall Mroonga plugin, run the following command:
   mysql -uroot < '/usr/local/opt/mroonga/share/mroonga/uninstall.sql'

なおこの状態で SHOW PULUGINS;すると以下のような状態です(抜粋)。

+-------------------------------+----------+--------------------+---------------+---------+
| Name                          | Status   | Type               | Library       | License |
+-------------------------------+----------+--------------------+---------------+---------+
| Mroonga                       | DELETED  | STORAGE ENGINE     | ha_mroonga.so | GPL     |
+-------------------------------+----------+--------------------+---------------+---------+

SHOW ENGINES;(抜粋)

+---------------+---------+-----------------------------------------------+--------------+------+------------+
| Engine        | Support | Comment                                       | Transactions | XA   | Savepoints |
+---------------+---------+-----------------------------------------------+--------------+------+------------+
| Mroonga       | NO      | CJK-ready fulltext search, column store       | NULL         | NULL | NULL       |
+---------------+---------+-----------------------------------------------+--------------+------+------------+

02.ninja.txt

kou commented 2 years ago

MariaDBの方はMroonga本体での対処が必要なので入れておきました。

手動でインストールし直すとどうなりますか?

mysql -uroot < '/usr/local/opt/mroonga/share/mroonga/uninstall.sql'
mysql -uroot < '/usr/local/opt/mroonga/share/mroonga/install.sql'
fugtat commented 2 years ago

/usr/local/opt/mroonga/ 以下にディレクトリshareが存在していませんでした。

kou commented 2 years ago

これはできますか?

mysql -uroot < '/usr/local/Cellar/mroonga/11.11/share/mroonga/uninstall.sql'
mysql -uroot < '/usr/local/Cellar/mroonga/11.11/share/mroonga/install.sql'
fugtat commented 2 years ago

やはり 11.11 以下に share がありませんでした。

kou commented 2 years ago

うーん、怪しそうなところを変更してみたので、brew uninstallしてから再度brew tap/brew installしてみてもらえますか?

fugtat commented 2 years ago

MySQLの方について、

brew tap mroonga/mroonga 
brew install mroonga --with-homebrew-mariadb

MySQLのpost-install stepで以下のエラーとなりました。

Last 15 lines from /Users/kojima/Library/Logs/Homebrew/mysql/post_install.01.mysqld:
2022-01-06 15:08:01 +0900

/usr/local/Cellar/mysql/8.0.27_1/bin/mysqld
--initialize-insecure
--user=kojima
--basedir=/usr/local/Cellar/mysql/8.0.27_1
--datadir=/usr/local/var/mysql
--tmpdir=/tmp

2022-01-06T06:08:01.800044Z 0 [System] [MY-013169] [Server] /usr/local/Cellar/mysql/8.0.27_1/bin/mysqld (mysqld 8.0.27) initializing of server in progress as process 92122
2022-01-06T06:08:01.801409Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2022-01-06T06:08:01.801415Z 0 [ERROR] [MY-013236] [Server] The designated data directory /usr/local/var/mysql/ is unusable. You can remove all files that the server added to it.
2022-01-06T06:08:01.801479Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-01-06T06:08:01.801621Z 0 [System] [MY-010910] [Server] /usr/local/Cellar/mysql/8.0.27_1/bin/mysqld: Shutdown complete (mysqld 8.0.27)  Homebrew.
Warning: The post-install step did not complete successfully
You can try again using:
  brew postinstall mysql

ただ今回はディレクトリ share が作られており手動インストールも試せました。 が、エラーが出てしまいました。

mysql -uroot < '/usr/local/Cellar/mroonga/11.11/share/mroonga/uninstall.sql'
mysql -uroot < '/usr/local/Cellar/mroonga/11.11/share/mroonga/install.sql'

ERROR 1126 (HY000) at line 6: Can't open shared library '/usr/local/opt/mariadb/lib/plugin/ha_mroonga.so' (errno: 2, dlopen(/usr/local/opt/mariadb/lib/plugin/ha_mroonga.so, 2): image not found)

ちなみに、今気づいたのですがmysqlに接続すると以下のようなメッセージが出ます。

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 618
Server version: 5.5.5-10.6.4-MariaDB Homebrew

と、MariaDBの表示になっているんですよね。一方mysql --versionを見てみると

mysql  Ver 8.0.27 for macos11.6 on x86_64 (Homebrew)

となります。これについては恐らくこちらで設定等ミスしているのですよね。引き続き調べますが、このせいでご迷惑をおかけしていたら申し訳ありません。

kou commented 2 years ago

たしかにサーバーとしてMariaDBが動いていますね。 mysql --versionはMySQLのクライアントのバージョンでサーバーのバージョンではないのです。

昔HomebrewでインストールしたMariaDBが残っているんだと思います。psで動いているサーバーのプロセスを見つければどこにインストールされているかわかるかもしれません。

kou commented 2 years ago

brew install mroonga --with-homebrew-mariadbとしているのも悪い気がします。 mariadbではなくてmysqlを使ってください。

fugtat commented 2 years ago

ありがとうございます。 brew install mroonga --with-homebrew-mariadbと書いたのは誤記でした。失礼しました。 進展がありましたらご報告します。

fugtat commented 2 years ago

過去のMariaDBが見つからなかったのでMacを初期化してやり直してみました。

brew tap mroonga/mroonga 
brew install mroonga --with-homebrew-mysql

するとエラーなくインストール完了。 INSTALL PLUGIN Mroonga SONAME 'ha_mroonga.so'; で以下のエラーが出ましたが

ERROR 1126 (HY000): Can't open shared library '/usr/local/Cellar/mysql/8.0.27_1/lib/plugin/ha_mroonga.so' (errno: 2 dlopen(/usr/local/Cellar/mysql/8.0.27_1/lib/plugin/ha_mroonga.so, 2): image not found)

(正しいやり方かわかりませんが)/usr/local/Cellar/mroonga/11.11/lib/plugin/ha_mroonga.so/usr/local/Cellar/mysql/8.0.27_1/lib/plugin/以下にコピーしてきたらとりあえずインストールできました。

+---------+---------+-----------------------------------------+--------------+------+------------+
| Engine  | Support | Comment                                 | Transactions | XA   | Savepoints |
+---------+---------+-----------------------------------------+--------------+------+------------+
| Mroonga | YES     | CJK-ready fulltext search, column store | NO           | NO   | NO         |
+---------+---------+-----------------------------------------+--------------+------+------------+
+---------------------------------+----------+--------------------+---------------+---------+
| Name                            | Status   | Type               | Library       | License |
+---------------------------------+----------+--------------------+---------------+---------+
| Mroonga                         | ACTIVE   | STORAGE ENGINE     | ha_mroonga.so | GPL     |
+---------------------------------+----------+--------------------+---------------+---------+

ひとまずご報告でした。

kou commented 2 years ago

あれ、/usr/local/lib/plugin/ha_mroonga.soにシンボリックリンクができていませんか? そこにシンボリックリンクがあれば読み込める想定なんです。

fugtat commented 2 years ago

シンボリックリンクは存在しているように見えます。 lrwxr-xr-x 1 newuser admin 51 1 6 20:08 ha_mroonga.so -> ../../Cellar/mroonga/11.11/lib/plugin/ha_mroonga.so

kou commented 2 years ago

あぁ、以下のような内容の/usr/local/etc/my.cnf.d/plugin_dir.cnfを作ってみてください。

[mysqld]
plugin-dir = /usr/local/lib/plugin

Homebrewにpull requestを送るのがよさそうです。

diff --git a/Formula/mysql.rb b/Formula/mysql.rb
index 0bcabf7f974..c1fe6830fa5 100644
--- a/Formula/mysql.rb
+++ b/Formula/mysql.rb
@@ -132,6 +132,9 @@ class Mysql < Formula
       # Only allow connections from localhost
       bind-address = 127.0.0.1
       mysqlx-bind-address = 127.0.0.1
+      # Use linked plugin directory to add support for third-party plugins
+      # such as Mroonga
+      plugin-dir = #{lib/"plugin"}
     EOS
     etc.install "my.cnf"
   end
fugtat commented 2 years ago

cnfファイルを用意したら意図通りの動きをしてくれました。整理してからpull request試します。 お付き合いいただきありがとうございました。

kou commented 2 years ago

さすがです! ではこれは閉じます!