简体   繁体   中英

gem "mysql2" instalation errors

I have hard time to configure a dev environement for rails getting some errors

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

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

You need to install mysql first, the log contains

mysql client is missing. You may need to 'apt-get install libmysqlclient-dev' or 'yum install mysql-devel', and try again.

The documentation page of the mysql2 gem contains:

This gem links against MySQL's libmysqlclient library or Connector/C library, and compatible alternatives such as MariaDB. You may need to install a package such as libmysqlclient-dev, mysql-devel, or other appropriate package for your system. See below for system-specific instructions.

By default, the mysql2 gem will try to find a copy of MySQL in this order:
* Option --with-mysql-dir, if provided (see below).
* Option --with-mysql-config, if provided (see below).
* Several typical paths for mysql_config (default for the majority of users).
* The directory /usr/local.

Try to install mysql or the mentioned libs and try again to install the 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:

ExecJS lets you run JavaScript code from Ruby. It automatically picks the best runtime available to evaluate your JavaScript program, then returns the result to you as a Ruby object.

Install one of the javascript runtimes, listed here in the readme , eg nodejs ( https://nodejs.org/en/download/ ), therubyracer, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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