简体   繁体   English

MySQL gem 未安装在 M1 mac 上

[英]MySQL gem is not installing on M1 mac

I am facing issue while installing MySQL gem on M1 mac.我在 M1 mac 上安装 MySQL gem 时遇到问题。 Bundle install fas failing to build mysql gem捆绑安装 fas 无法构建 mysql gem

An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue.

In Gemfile:
  mysql2

Found a solution which suggested to install mysql2 gem using following command找到了建议使用以下命令安装 mysql2 gem 的解决方案

$ arch -x86_64 gem install mysql2 -v 0.5.3 -- --srcdir=/usr/local/mysql/include

This actually solved bundle install issue, but when i tried rails c got this error.这实际上解决了捆绑安装问题,但是当我尝试rails c时出现此错误。

$ rails c
   
/Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- mysql2/mysql2 (LoadError)
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:332:in `block in require'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:299:in `load_dependency'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/activesupport-6.1.3.2/lib/active_support/dependencies.rb:332:in `require'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/mysql2-0.5.3/lib/mysql2.rb:36:in `<main>'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bundler-2.3.8/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bundler-2.3.8/lib/bundler/runtime.rb:55:in `each'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bundler-2.3.8/lib/bundler/runtime.rb:55:in `block in require'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bundler-2.3.8/lib/bundler/runtime.rb:44:in `each'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bundler-2.3.8/lib/bundler/runtime.rb:44:in `require'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/bundler-2.3.8/lib/bundler.rb:176:in `require'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/spring-2.1.1/lib/spring/application.rb:92:in `require'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/spring-2.1.1/lib/spring/application.rb:92:in `preload'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/spring-2.1.1/lib/spring/application.rb:139:in `run'
        from /Users/maneeshb/.rvm/gems/ruby-2.6.9/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>'
        from /Users/maneeshb/.rvm/rubies/ruby-2.6.9/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /Users/maneeshb/.rvm/rubies/ruby-2.6.9/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from -e:1:in `<main>'

Please help me to solve this issue.请帮我解决这个问题。

This solved the issue这解决了这个问题

brew install openssl zstd mysql

LIBRARY_PATH=$(brew --prefix zstd)/lib/:$(brew --prefix openssl)/lib/ gem install mysql2 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM