当我从github下载rails应用程序时
https://github.com/ari/jobsworth
然后给它bundle install
抛出错误:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
An error occurred while installing mysql2 (0.4.4), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.4'` succeeds before bundling.
我提供sudo gem install mysql2 -v '0.4.4'
后显示如下:
Fetching: mysql2-0.4.4.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.4.0/gems/mysql2-0.4.4/ext/mysql2
/usr/bin/ruby2.4 -r ./siteconf20180212-10708-v1q8lj.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.4.0/gems/mysql2-0.4.4 for inspection.
Results logged to /var/lib/gems/2.4.0/extensions/x86_64-linux/2.4.0/mysql2-0.4.4/gem_make.out
运行bundle install
后,它会抛出相同的错误。
答案 0 :(得分:0)
运行这些命令对我有用。
brew install openssl
bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)"
bundle
您可以参考此链接以获得更多帮助https://github.com/brianmario/mysql2/issues/1005