简体   繁体   English

gem“mysql2”安装错误

[英]gem "mysql2" instalation errors

I have hard time to configure a dev environement for rails getting some errors我很难为 Rails 配置开发环境,但出现一些错误

I have install ruby & rails with this tutorial https://parsun.com/2017/09/23/how-to-install-ruby-on-rails-on-raspberry-pi-3/ but i have some error when i launch a project我已经使用本教程安装了 ruby​​ 和 rails https://parsun.com/2017/09/23/how-to-install-ruby-on-rails-on-raspberry-pi-3/但是当我有一些错误时启动项目

An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/'` succeeds before bundling.

i have tried to launch :我试图启动:

gem install mysql2

but i get that ... https://pastebin.com/8CxsVzMQ但我明白了...... https://pastebin.com/8CxsVzMQ

You need to install mysql first, the log contains需要先安装mysql,日志包含

mysql client is missing.缺少 mysql 客户端。 You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again.您可能需要“apt-get install libmysqlclient-dev”或“yum install mysql-devel”,然后重试。

The documentation page of the mysql2 gem contains: mysql2 gem文档页面包含:

This gem links against MySQL's libmysqlclient library or Connector/C library, and compatible alternatives such as MariaDB.这个 gem 链接到 MySQL 的 libmysqlclient 库或 Connector/C 库,以及兼容的替代品,如 MariaDB。 You may need to install a package such as libmysqlclient-dev, mysql-devel, or other appropriate package for your system.您可能需要为您的系统安装一个软件包,例如 libmysqlclient-dev、mysql-devel 或其他适当的软件包。 See below for system-specific instructions.有关系统特定的说明,请参见下文。

By default, the mysql2 gem will try to find a copy of MySQL in this order:默认情况下,mysql2 gem 将尝试按以下顺序查找 MySQL 的副本:
* Option --with-mysql-dir, if provided (see below). * 选项 --with-mysql-dir,如果提供(见下文)。
* Option --with-mysql-config, if provided (see below). * 选项 --with-mysql-config,如果提供(见下文)。
* Several typical paths for mysql_config (default for the majority of users). * mysql_config 的几个典型路径(大多数用户的默认路径)。
* The directory /usr/local. * 目录/usr/local。

Try to install mysql or the mentioned libs and try again to install the gem.尝试安装 mysql 或提到的库,然后再次尝试安装 gem。

The messages do not seem to reflect reality, try this instead of the mentioned package:这些消息似乎没有反映现实,试试这个而不是提到的包:

sudo apt-get install default-libmysqlclient-dev

Then, your next error clearly shows what is wrong然后,您的下一个错误清楚地显示出了什么问题

/home/pi/.rvm/gems/ruby-2.6.3/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect': Could not find a JavaScript runtime. See github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

The GH page says: GH 页面说:

ExecJS lets you run JavaScript code from Ruby. ExecJS 允许您从 Ruby 运行 JavaScript 代码。 It automatically picks the best runtime available to evaluate your JavaScript program, then returns the result to you as a Ruby object.它会自动选择可用的最佳运行时来评估您的 JavaScript 程序,然后将结果作为 Ruby 对象返回给您。

Install one of the javascript runtimes, listed here in the readme , eg nodejs ( https://nodejs.org/en/download/ ), therubyracer, etc.安装这里自述文件中列出的 javascript 运行时之一,例如 nodejs ( https://nodejs.org/en/download/ )、therubyracer 等。

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

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