LoginSignup
0
1

More than 3 years have passed since last update.

mysql2のbundle installエラー解消

Last updated at Posted at 2020-10-12
  • macOS Catalina
  • zsh

rubyのプロジェクトの環境構築にて

1. mysqlないよ

% bundle install

怒られる

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

2. mysql2こける(ライブラリないよ)

言われたとおりに

% gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'

怒られる

ld: library not found for -lssl

対処

https://qiita.com/fukuda_fu/items/463a39406ce713396403

/usr/local/opt/opensslにopenssl入ってるか確認。

わたしの場合は、homebrewでopenssl@1.1をインストール済で、.zshrcにはパス通してたんだけど、

.zshrc
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"

どうやらmysql2が使いたいのはこちらの(最新の)パスのほうではなくて下記のパスのほうだそうなので、ローカルパスを通す。

% export LDFLAGS="-L/usr/local/opt/openssl/lib"
% export CPPFLAGS="-I/usr/local/opt/openssl/include"

ローカルオプションを設定

% bundle config --local build.mysql2 "--with-cppflags=-I/usr/local/opt/openssl/include"
% bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib"

2. Pumaでこける

再度

bundle install

怒られる

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

言われたとおりに

% gem install puma -v '4.3.1' --source 'https://rubygems.org/'

怒られる

puma_http11.c:203:22: error: implicitly declaring library function 'isspace' with type 'int (int)' [-Werror,-Wimplicit-function-declaration]
  while (vlen > 0 && isspace(value[vlen - 1])) vlen--;
                     ^
puma_http11.c:203:22: note: include the header <ctype.h> or explicitly provide a declaration for 'isspace'
1 error generated.
make: *** [puma_http11.o] Error 1

make failed, exit code 2

対処

https://github.com/puma/puma/issues/2304

インストールオプションつける

% gem install puma:4.3.1 -- --with-cflags="-Wno-error=implicit-function-declaration"

成功

Successfully installed puma-4.3.1
Parsing documentation for puma-4.3.1
Installing ri documentation for puma-4.3.1
Done installing documentation for puma after 0 seconds
1 gem installed

ようやく

次こそ・・

% bundle install
Bundle complete! 24 Gemfile dependencies, 90 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

ホっ🍵
(最近環境構築しすぎて、このへんの解消に僧侶モードはいってきました)
https://qiita.com/mksm_wrk/items/69f6c2fc396dc0abf954

さあ仕事しよ。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1