4
2

More than 1 year has passed since last update.

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.68.dylibの解決方法

Last updated at Posted at 2021-11-08

環境

macOS Big Sur ver11.6
Rails 6.0.4.1

エラー内容

学習のために、railsで新規アプリを作成しようと際に、

$ rails new (アプリ名)

を実行したところ、以下のエラーが発生しました。

(省略)
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
         run  bundle exec spring binstub --all
* bin/rake: Spring inserted
* bin/rails: Spring inserted
       rails  webpacker:install
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.68.dylib
  Referenced from: /usr/local/opt/node@14/bin/node
  Reason: image not found
sh: line 1: 28331 Abort trap: 6           node -v
sh: nodejs: command not found
Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/

どうやら「node.jsがありません」と表示されているようですが、そんなことあるのかと疑問に思い、言われたとおりに

$ brew install node

こちらのコマンドを実行して、node.jsをインストールしようとしたところ、

Warning: node 17.0.1 is already installed and up-to-date.
To reinstall 17.0.1, run:
  brew reinstall node

「既にあるよ」と言ってます。 ん?どうしてだろうと思って色々と調べてみました。
先ほどのエラー文のここの部分が臭いと思い、ここに絞って調査しました。

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.68.dylib

dyldDyanmic Libraryといい、ここの箇所は「実行時に読み込むライブラリが正しく読み込みできない状態になっている」という意味で、今回問題になっているライブラリはicu4cというものになります。
エラーの直接的な原因は、正直分かりませんでした。
アプリを作成しようとした際に、突如このエラーにハマり、原因がよく分からなかったのですが、調べたところ、brew updateによるライブラリのバージョンアップにより古いバージョンのnodeと新しいバージョンのnodeが相互干渉を引き起こしていた
可能性が考えられました。

解決方法

直接的な原因はよく分からなかったのですが、このエラーの直接の答えはこちらにありました。こちらも参考にしました。

解決方法

$ brew uninstall --ignore-dependencies node icu4c
$ brew install node

これで、再度、'rails new'を実行すると、無事エラーが解消され、正常にアプリを作成することができました。

(省略)
✨  Done in 7.01s.
Webpacker successfully installed 🎉 🍰
4
2
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
4
2