【问题标题】:error while creating new app rails with mysql db使用 mysql db 创建新应用程序 rails 时出错
【发布时间】:2016-11-20 16:45:44
【问题描述】:

大家好,我是 rails 新手,我安装了所有 ruby​​ rails mysql,一切都做得很好而且很健康,当我尝试创建一个新应用程序“rails new blog”时,一切都做得很好,但是每当我添加'-d mysql' 它卡住并给出一个错误,知道一切都安装好了

Aikers-MBP:~ Aikers$ brew install mysql 警告:mysql-5.7.16 已经安装 Aikers-MBP:~ Aikers$

这里我尝试安装

安装 mysql2 (0.4.5) 时出错,Bundler 无法继续。 在捆绑之前确保gem install mysql2 -v '0.4.5' 成功。 Aikers-MBP:kar Aiker$ rake db create 在您的 Gemfile 中列出的或在此机器上可用的任何 gem 源中找不到 gem 'rails (= 4.2.6)'。 运行 bundle install 以安装缺少的 gem。 Aikers-MBP:kar Aiker$ gem install mysql2 -v '0.4.5' 构建原生扩展。这可能需要一段时间... 错误:安装 mysql2 时出错: 错误:无法构建 gem 原生扩展。

【问题讨论】:

  • 当它给出错误“无法构建 gem 原生扩展”时,它会给出一个很长的错误。请复制粘贴错误,以便我们知道您的系统缺少什么。
  • 是的,这就是整个错误

标签: ruby-on-rails ruby mysql2


【解决方案1】:

您的系统无法找到 OpenSSL 中存在的 lssl 库。要解决此问题,您需要运行:

brew install openssl

在此之后尝试安装mysql2 gem。如果这仍然失败,那么您可能需要通过运行重新安装 Xcode 命令行工具:

xcode-select --install

希望这能解决您的安装问题。 :)

【讨论】:

  • 乐于帮助@Aiker
【解决方案2】:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/Aiker/Desktop/blog/vendor/bundle/gems/mysql2-0.4.5/ext/mysql2
/Users/Aiker/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20161121-68854-12pc3sf.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 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 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.16/lib
-----
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/Aiker/Desktop/blog/vendor/bundle/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.4.5/mkmf.log

current directory: /Users/Aiker/Desktop/blog/vendor/bundle/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR=" clean

current directory: /Users/Aiker/Desktop/blog/vendor/bundle/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
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/Aiker/Desktop/blog/vendor/bundle/gems/mysql2-0.4.5 for inspection.
Results logged to /Users/Aiker/Desktop/blog/vendor/bundle/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.4.5/gem_make.out

An error occurred while installing mysql2 (0.4.5), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.4.5'` succeeds before bundling.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-29
    • 2020-07-28
    • 2014-09-27
    • 2016-01-04
    • 1970-01-01
    • 1970-01-01
    • 2013-01-26
    相关资源
    最近更新 更多