質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Q&A

解決済

1回答

4817閲覧

macOS Catalina 10.15にアップデートしてからrailsコマンドが使えない。bundle installでエラーが出る

kotahayashi

総合スコア15

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

0グッド

2クリップ

投稿2019/10/25 06:35

編集2019/10/25 07:27

前提・実現したいこと

macOS Catalina 10.15にアップデートしてから、railsコマンドが使えないため、これを解決したいです。
bundle install実行中にエラーが発生してしまいます。

発生している問題・エラーメッセージ

railsコマンドを叩くとこのように表示されます。

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

bundle installの実行結果が以下です。

Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. Fetching gem metadata from https://rubygems.org/...... Using rake 12.3.3 (略) Using kaminari 1.1.1 Fetching libv8 3.16.14.19 Installing libv8 3.16.14.19 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/ext/libv8 /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20191025-1127-h3rg3y.rb extconf.rb creating Makefile Applying /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/patches/disable-building-tests.patch Applying /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/patches/disable-werror-on-osx.patch Applying /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/patches/disable-xcode-debugging.patch Applying /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/patches/do-not-imply-vfp3-and-armv7.patch Applying /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/patches/do-not-use-MAP_NORESERVE-on-freebsd.patch Applying /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/patches/do-not-use-vfp2.patch Applying /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/patches/fPIC-for-static.patch Compiling v8 for x64 Using python 2.7.16 Using compiler: c++ (clang version 11.0.0) Unable to find a compiler officially supported by v8. It is recommended to use GCC v4.4 or higher Beginning compilation. This will take some time. Building v8 with env CXX=c++ LINK=c++ /usr/bin/make x64.release ARFLAGS.target=crs werror=no GYP_GENERATORS=make \ build/gyp/gyp --generator-output="out" build/all.gyp \ -Ibuild/standalone.gypi --depth=. \ -Dv8_target_arch=x64 \ -S.x64 -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror='' CXX(target) /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found] In file included from ../src/allocation.cc:33: ../src/utils.h:33:10: fatal error: 'climits' file not found #include <climits> ^~~~~~~~~ 1 warning and 1 error generated. make[1]: *** [/Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o] Error 1 make: *** [x64.release] Error 2 /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound) from /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in `each' from /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in `verify_installation!' from /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:26:in `install!' from extconf.rb:7:in `<main>' extconf failed, exit code 1 Gem files will remain installed in /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/gems/libv8-3.16.14.19 for inspection. Results logged to /Users/ユーザ名/フォルダ名/フォルダ名/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-19/2.6.0/libv8-3.16.14.19/gem_make.out An error occurred while installing libv8 (3.16.14.19), and Bundler cannot continue. Make sure that `gem install libv8 -v '3.16.14.19' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: therubyracer was resolved to 0.12.3, which depends on libv8

指示通りgem install libv8 -v '3.16.14.19' --source 'https://rubygems.org/'を実行した結果がこちらです。

ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

試したこと

https://teratail.com/questions/218281
こちらと、いただいたご回答から、
・~/.zshrcファイルを作り、

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)"

を記述。

・source ~/.zshrcを実行し、which ruby の実行結果が
/usr/bin/rubyから/Users/ユーザ名/.rbenv/shims/ruby
に変わった

・brew install rbenv ruby-buildを実行してからbundle installを実行したが、
実行結果は変わらず、続いてエラーメッセージで指示された
gem install mysql2 -v '0.4.10' --source 'https://rubygems.org/'
を実行した結果が以下のとおりです。

Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. current directory: /Users/ユーザ名/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/mysql2-0.4.10/ext/mysql2 /Users/ユーザ名/.rbenv/versions/2.3.6/bin/ruby -r ./siteconf20191025-5257-9uxwbc.rb extconf.rb checking for rb_absint_size()... yes checking for rb_absint_singlebit_p()... yes checking for ruby/thread.h... yes checking for rb_thread_call_without_gvl() in ruby/thread.h... yes checking for rb_thread_blocking_region()... no checking for rb_wait_for_single_fd()... yes checking for rb_hash_dup()... yes checking for rb_intern3()... yes checking for rb_big_cmp()... yes ----- Using mysql_config at /usr/local/bin/mysql_config ----- checking for mysql.h... yes checking for errmsg.h... yes checking for SSL_MODE_DISABLED in mysql.h... yes checking for SSL_MODE_PREFERRED in mysql.h... yes checking for SSL_MODE_REQUIRED in mysql.h... yes checking for SSL_MODE_VERIFY_CA in mysql.h... yes checking for SSL_MODE_VERIFY_IDENTITY in mysql.h... yes checking for MYSQL.net.vio in mysql.h... yes checking for MYSQL.net.pvio in mysql.h... no checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes ----- Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load ----- ----- Setting libpath to /usr/local/Cellar/mysql/5.7.19/lib ----- creating Makefile To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/ユーザ名/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-17/2.3.0-static/mysql2-0.4.10/mkmf.log current directory: /Users/ユーザ名/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/mysql2-0.4.10/ext/mysql2 make "DESTDIR=" clean current directory: /Users/ユーザ名/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/mysql2-0.4.10/ext/mysql2 make "DESTDIR=" compiling infile.c compiling client.c compiling mysql2_ext.c compiling statement.c compiling result.c result.c:326:40: warning: incompatible pointer types assigning to 'my_bool *' (aka 'char *') from 'bool *' [-Wincompatible-pointer-types] wrapper->result_buffers[i].is_null = &wrapper->is_null[i]; ^ ~~~~~~~~~~~~~~~~~~~~ result.c:328:40: warning: incompatible pointer types assigning to 'my_bool *' (aka 'char *') from 'bool *' [-Wincompatible-pointer-types] wrapper->result_buffers[i].error = &wrapper->error[i]; ^ ~~~~~~~~~~~~~~~~~~ 2 warnings generated. linking shared-object mysql2/mysql2.bundle ld: library not found for -lssl clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [mysql2.bundle] Error 1 make failed, exit code 2 Gem files will remain installed in /Users/ユーザ名/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/mysql2-0.4.10 for inspection. Results logged to /Users/ユーザ名/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-17/2.3.0-static/mysql2-0.4.10/gem_make.out

補足情報(FW/ツールのバージョンなど)

OS:macOS Catalina 10.15
ruby -v:ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
rbenv -v:rbenv 1.1.2

初心者で、ご回答に何度も追加質問することもあるかもしれませんが、よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

zshrcの編集方法がわからない(ロックがかかっている)

「ロックがかかっている」とはどういうことですか?
which の結果より、原因はあたっていると思います。

投稿2019/10/25 06:44

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kotahayashi

2019/10/25 06:49

ご回答いただきありがとうございます。 mac全体でzshrcを検索したところ、 Macintosh HD > private > etc 内にテキストエディット書類としてzshrcというファイルが見つかりました。 zshrc_Apple_Terminalというファイルもあります。 こちらのzshrcというファイルですが、 ロックを解除しようとすると 「ファイル“zshrc”のロックを解除するために必要なアクセス権がありません。」、 編集しようとすると 「あなたはファイル“zshrc”の所有者ではなく、そのファイルに書き込む権限がありません。」 と表示されてしまいます。 そもそも編集する対象はこちらのファイルで良いのでしょうか。 よろしくお願いいたします。
退会済みユーザー

退会済みユーザー

2019/10/25 06:52

編集するのは `zshrc` ではなく、`.zshrc` です。 ホームディレクトリにあるはずです。 Finderからだと不可視になっているかもしれません。
kotahayashi

2019/10/25 07:01

hoge@fugaMac ~ % ls Applications Documents Library Music Public go work Desktop Downloads Movies Pictures container learn hoge@fugaMac ~ % pwd /Users/hoge ホームディレクトリはこちらでしょうか?大変初歩的なご質問で恐縮です。
退会済みユーザー

退会済みユーザー

2019/10/25 07:04

そこで間違いないです。 ホームディレクトリに移動するコマンドは、 `cd` です (`cd` とだけ入力して実行する)。
kotahayashi

2019/10/25 07:29

ありがとうございます。 おかげさまでwhich rubyの実行結果は/Users/ユーザ名/.rbenv/shims/rubyに変わりました。 ただ、根本の解決にはまだ至っていません。 質問を編集したのでご覧いただければ幸いです。
退会済みユーザー

退会済みユーザー

2019/10/25 07:32

xcode-select --install を実行して、再度 bundle install したらどうなるでしょうか。
kotahayashi

2019/10/25 07:38

xcode-select --install xcode-select: error: command line tools are already installed, use "Software Update" to install updates Software Update zsh: command not found: Software それぞれこのように返ってきてしまいます。 関係あるかわかりませんが、昨日xcode自体はapple storeからインストールしました。
退会済みユーザー

退会済みユーザー

2019/10/25 07:41

xcodeについては OK です。 以下のコマンドを実行してから bundle install を行ったらどうでしょうか。 なおこのコマンドを実行しても、影響はアプリ内の小さな範囲に収まるので問題ないです。 bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"
kotahayashi

2019/10/25 07:51

You are replacing the current local value of build.mysql2, which is currently nil と返ってきた後bundle installに成功しました! これで通常の開発に戻れます。ご丁寧に回答していただき、ありがとうございました。
退会済みユーザー

退会済みユーザー

2019/10/25 07:54

上記のコマンドを実行する前にmysql2がビルドできなかった理由は、MacにインストールされているMySQLのバージョンが8だからです(詳細は省略します)。 これまで問題がなければ明示的に5を使っていたのでしょう。そして何らかを機にして8が入ったのでしょう。 なお、Mac以外でデフォルトで8を入れている例を知らないので、上記コマンドは今のところほとんど実行する必要はないかと思います。問題があったら実行したらうまくいくかも、ぐらいの考えを頭の片隅に置いておく程度でよいかと思います。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問