railsまわりのgemのインストールで起きがちなエラー対応一覧
主に古いrailsアプリのプロジェクトでbundle install
をしたときに起きがちがエラーをまとめました。
nokogiriのインストールでコケたら
問題
例えば下記のようなエラーが出たとする
$ bundle install ... (中略) ... *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/Users/noel/.rbenv/versions/2.6.6/bin/$(RUBY_BASE_NAME) --help --clean --use-system-libraries --enable-static --disable-static --with-zlib-dir --without-zlib-dir --with-zlib-include --without-zlib-include=${zlib-dir}/include --with-zlib-lib --without-zlib-lib=${zlib-dir}/lib --enable-cross-build --disable-cross-build /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:402:in `block in execute': Failed to complete extract task (RuntimeError) from /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:373:in `chdir' from /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:373:in `execute' from /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:367:in `extract_file' from /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:62:in `block in extract' from /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:60:in `each' from /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:60:in `extract' from /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:151:in `cook' from extconf.rb:365:in `block (2 levels) in process_recipe' from extconf.rb:257:in `block in chdir_for_build' from extconf.rb:256:in `chdir' from extconf.rb:256:in `chdir_for_build' from extconf.rb:364:in `block in process_recipe' from extconf.rb:262:in `tap' from extconf.rb:262:in `process_recipe' from extconf.rb:557:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/nokogiri-1.10.10/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.10 for inspection. Results logged to /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/nokogiri-1.10.10/gem_make.out An error occurred while installing nokogiri (1.10.10), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.10.10'` succeeds before bundling.
対応策
$ brew install libxml2 $ gem install nokogiri -v '1.10.10' -- --use-system-libraries --with-xml2-include=$(brew --prefix libxml2)/include/libxml2
libv8のインストールでコケたら
問題
$ bundle install ... (中略) Installing libv8 3.16.14.19 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/ext/libv8 /Users/noel/.rbenv/versions/2.6.6/bin/ruby -I /Users/noel/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20201005-34047-13d4k0z.rb extconf.rb creating Makefile Applying /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/patches/disable-building-tests.patch Applying /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/patches/disable-werror-on-osx.patch Applying /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/patches/disable-xcode-debugging.patch Applying /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/patches/do-not-imply-vfp3-and-armv7.patch Applying /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/patches/do-not-use-MAP_NORESERVE-on-freebsd.patch Applying /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/patches/do-not-use-vfp2.patch Applying /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/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 12.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/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o clang: warning: include path for libstdc++ 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 error generated. make[1]: *** [/Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/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/noel/.rbenv/versions/2.6.6/lib/ruby/gems/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/noel/.rbenv/versions/2.6.6/lib/ruby/gems/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/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in `each' from /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in `verify_installation!' from /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/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/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19 for inspection. Results logged to /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-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'` succeeds before bundling.
対応策
$ brew install v8@3.15 $ gem install libv8 -v '3.16.14.19' -- --with-system-v8
mysql2のインストールでコケたら
問題
$ bundle install ... (中略) Installing mysql2 0.3.21 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mysql2-0.3.21/ext/mysql2 /Users/noel/.rbenv/versions/2.6.6/bin/ruby -I /Users/noel/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20201005-35924-6ngejt.rb extconf.rb 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 ----- Using mysql_config at /usr/local/bin/mysql_config ----- checking for mysql.h... yes checking for errmsg.h... yes checking for mysqld_error.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/5.7.31/lib ----- creating Makefile current directory: /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mysql2-0.3.21/ext/mysql2 make "DESTDIR=" clean current directory: /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mysql2-0.3.21/ext/mysql2 make "DESTDIR=" compiling client.c client.c:367:33: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32] elapsed_time = end_time - start_time; ~ ~~~~~~~~~^~~~~~~~~~~~ client.c:1152:56: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32] mysql2rb = mysql2_mysql_enc_name_to_rb(charset_name, charset_name_len); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~ 2 warnings generated. compiling infile.c compiling mysql2_ext.c compiling result.c result.c:189:17: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare] for (i = 0; i < (len - 1); i++) { ~ ^ ~~~~~~~ 1 warning 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/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/mysql2-0.3.21 for inspection. Results logged to /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/mysql2-0.3.21/gem_make.out An error occurred while installing mysql2 (0.3.21), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.3.21'` succeeds before bundling.
対応策
$ brew install openssl $ gem install mysql2 -v '0.3.21' -- --with-opt-dir="$(brew --prefix openssl)"
therubyracerのインストールでコケたら
問題
$ bundle install ... (中略) Installing therubyracer 0.12.3 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/therubyracer-0.12.3/ext/v8 /Users/noel/.rbenv/versions/2.6.6/bin/ruby -I /Users/noel/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20201005-37192-wzlo7z.rb extconf.rb checking for -lpthread... yes checking for -lobjc... yes checking for v8.h... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/Users/noel/.rbenv/versions/2.6.6/bin/$(RUBY_BASE_NAME) --with-pthreadlib --without-pthreadlib --with-objclib --without-objclib --enable-debug --disable-debug --with-v8-dir --without-v8-dir --with-v8-include --without-v8-include=${v8-dir}/include --with-v8-lib --without-v8-lib=${v8-dir}/lib /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version (Libv8::Location::System::NotFoundError) of V8 found on your system and *not* the one that is bundled with the libv8 rubygem. However, your system version of v8 could not be located. Please make sure your system version of v8 that is compatible with 3.16.14.19 installed. You may need to use the --with-v8-dir option if it is installed in a non-standard location from /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile' from extconf.rb:32:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/therubyracer-0.12.3/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/therubyracer-0.12.3 for inspection. Results logged to /Users/noel/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/therubyracer-0.12.3/gem_make.out An error occurred while installing therubyracer (0.12.3), and Bundler cannot continue. Make sure that `gem install therubyracer -v '0.12.3'` succeeds before bundling.
対応策
$ brew install v8@3.15 $ gem install therubyracer -v '0.12.3' -- --with-v8-dir=$(brew --prefix v8@3.15)