Techvenience

Technology × Convenience - Vue / React / Next / Nuxt / ChatGPTなどのIT技術がもたらす便利さをお伝えします。最近はChatGPTなどのAI技術を使ってブログを書いています。

Mojaveにしたら Could not find nokogiri-1.6.7.1 in any of the sources と怒られた

Mojaveにしたら Could not find nokogiri-1.6.7.1 in any of the sources と怒られた

macOSをMojaveにあげたら以下のエラーが出ました。
(もうCatalina来てるのに今更Mojaveですが)

Could not find nokogiri-1.6.7.1 in any of the sources
Run `bundle install` to install missing gems.

書いてある通り、

$ bundle install

を実行。エラーが出ます。(一部省略)

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

An error occurred while installing nokogiri (1.6.7.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.7.1' --source 'https://rubygems.org/'` succeeds before bundling.


よくわからない。以下のコマンド実行

$ brew info libxml2

Python?関連の依存関係が正しくないと言われる

==> Dependencies
Required: python ✘

Error: Xcode alone is not sufficient on Mojave.
Install the Command Line Tools:
xcode-select --install

指示通り、以下を実行

$ xcode-select --install

ツールをインストール済みの場合、以下のエラーが表示されるかもしれません。
インストールされていない場合は、インストールします。

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

パスが正しくないときのエラーなので確認しましょう。
「xcode-select -p」で現状を把握。

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

上記のように出たらおかしいので、変更します。

sudo xcode-select -switch /Library/Developer/CommandLineTools

もう一度先ほどのコマンドを実施して変更されていたら完了です。

$ xcode-select -p
/Library/Developer/CommandLineTools

ここで上手くいったら再度以下を実行

$ brew info libxml2

成功したら、「bundle install」

$ bundle install
Fetching gem metadata from https://rubygems.org/.............
Using bundler 2.0.2
Using mini_portile2 2.0.0
Fetching nokogiri 1.6.7.1
Installing nokogiri 1.6.7.1 with native extensions
Using rubyzip 1.1.7
Using rubyXL 3.3.15
Bundle complete! 1 Gemfile dependency, 5 gems now installed.
Bundled gems are installed into `./vendor/bundle`

これでエラーが出たときと同様のコマンドを叩いたら上手くいきました。