zen*_*ope 64 ruby mysql ruby-on-rails mysql2 ruby-on-rails-4
我试图安装一个使用mysql2gem的开源rails 3.2.21应用程序,但是当我尝试运行bundlecommant时,我收到以下错误:
Fetching: mysql2-0.3.18.gem (100%)
Building native extensions. This could take a while...
p
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/my_username/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20150614-72129-orqsb7.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()... yes
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.6.25/lib
-----
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option '-L/Users/travis/.sm/pkg/active/lib'
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/my_username/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/mysql2-0.3.18 for inspection.
Results logged to /Users/my_username/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/extensions/x86
Run Code Online (Sandbox Code Playgroud)
我尝试mysql通过自制程序卸载我安装的每个版本并重新安装它们,如下所示:
brew uninstall --force mysql && brew install mysql
Run Code Online (Sandbox Code Playgroud)
然后运行:
sudo gem install mysql2
Run Code Online (Sandbox Code Playgroud)
正如在这里提出的一些类似问题的建议,但它仍然导致与上述相同的错误.
请有人可以提供有关如何启动和运行的指导吗?
Ale*_*rdi 145
对于仍然遇到问题的人:
当您通过brew安装openssl时,您应该收到以下消息:
Apple不赞成使用OpenSSL来支持自己的TLS和加密库
一般来说,这对您没有任何影响.如果您构建自己的软件并且需要此公式,则需要添加到构建变量中:
LDFLAGS:-L/usr/local/opt/openssl/lib
CPPFLAGS:-I/usr/local/opt/openssl/include
PKG_CONFIG_PATH:/ usr/local/opt/openssl/lib/pkgconfig
您可以通过运行以下命令来设置这些构建标志(对于本地应用程序):
bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"
Run Code Online (Sandbox Code Playgroud)
这对我有用.
有关更多信息,请参阅bundler的文档.
All*_*len 36
我的解决方案是安装Xcode命令行工具.
我最近通过Mac App Store更新了Xcode,每次我这样做,我都发现我必须重新安装命令行工具.
xcode-select --install
Run Code Online (Sandbox Code Playgroud)
ste*_*nis 23
尝试这个:
gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
Run Code Online (Sandbox Code Playgroud)
(适当更新版本)
Ale*_*kin 16
错误日志说:
ld: library not found for -lssl
Run Code Online (Sandbox Code Playgroud)
所以,你需要安装libssl:
brew install openssl
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你.
Gil*_*Him 15
Based on the solution here
brew install openssl
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
Run Code Online (Sandbox Code Playgroud)
solved the problem.
小智 11
在 MacBook Air M1(macOS) 上,它对我有用。
安装zstd
酿造安装zstd
安装mysql2
gem install mysql2 -v '0.5.3' -- --with-opt-dir=$(brew --prefix openssl) --with-ldflags=-L/opt/homebrew/Cellar/zstd/1.5.0/lib
感谢@mudasobwa指出我正确的方向.事实证明错误是由未链接的openssl文件引起的,因此运行:
brew reinstall openssl && brew link openssl --force
Run Code Online (Sandbox Code Playgroud)
解决了这个问题.我在这里找到了解决方案:OpenSSL,RVM,Brew,冲突错误
Homebrew 更新 (openssl@1.1) 后有一个新的库路径,所以可以使用:
bundle config build.mysql2 --with-opt-dir=$(brew --prefix openssl)
bundle install
Run Code Online (Sandbox Code Playgroud)
它会修复 ld: library not found for -lssl error
这最终在 macOS Monterey 12.3 (M1 Pro) 上对我有用:
gem install mysql2 -- --with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.28_1
Run Code Online (Sandbox Code Playgroud)
请务必阅读安装说明。对我来说值得注意的几点是:
brew install mysql)xcode-select --install)with-mysql-dir为安装 mysql 的位置(使用 进行检查brew info mysql)| 归档时间: |
|
| 查看次数: |
20764 次 |
| 最近记录: |