質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Q&A

1回答

2032閲覧

rbenvを使ってruby 3.0.0をインストールした場合、mysql2をどういうコマンドで実行すればよいのでしょうか。

Marchan4

総合スコア15

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

0グッド

0クリップ

投稿2021/03/28 07:47

編集2021/03/29 06:36

使用環境はrubyバージョン3.0.0, mysqlバージョン5.7, bundlerバージョン2.2.3です。
使用機器macOS Big Sur バージョン11.2.2です。使用中のテキストエディタはAtomです。

rbenvを使ってruby 3.0.0をインストールしたり、Homebrewを使って(brewコマンドを使って)mysql 5.7 をインストールした場合、どのようなコマンドを入力すればよいのでしょうか。

rubyの現在のバージョンは以下の通りです。

$ ruby -v ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin17]

mysqlの現在のバージョンは以下の通りです。

$ mysql --version mysql Ver 14.14 Distrib 5.7.32, for osx10.16 (x86_64) using EditLine wr apper

homebrewの現在のバージョンは以下の通りです。

$ brew -v Homebrew 3.0.5 Homebrew/homebrew-core (git revision f376c69429; last commit 2021-03-15) Homebrew/homebrew-cask (git revision 83abe76d01; last commit 2021-03-15)

###自分で試したこと

$ bundle install Fetching gem metadata from https://rubygems.org/. Using bundler 2.2.3 Following files may not be writable, so sudo is needed: /Users/ユーザ名/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/build_info/mysql2-0.5 .3.info Fetching mysql2 0.5.3 Your user account isn't allowed to install to the system RubyGems. You can cancel this installation and run: bundle config set --local path 'vendor/bundle' bundle install to install the gems into ./vendor/bundle/, or you can enter your password and install the bundled gems to RubyGems using sudo. Password: Installing mysql2 0.5.3 with native extensions Bundle complete! 1 Gemfile dependency, 2 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed.
$ brew install openssl@1.1 Error: openssl@1.1 1.1.1j is already installed. To upgrade to 1.1.1k, run: brew upgrade openssl@1.1
$ brew upgrade openssl@1.1 ==> Upgrading 1 outdated package: openssl@1.1 1.1.1j -> 1.1.1k ==> Upgrading openssl@1.1 1.1.1j -> 1.1.1k ==> Downloading https://homebrew.bintray.com/bottles/openssl%401.1-1.1.1k.big_sur.bot ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/17d94c51ddfa8364baed5f3a75 ######################################################################## 100.0% ==> Pouring openssl@1.1-1.1.1k.big_sur.bottle.tar.gz ==> Regenerating CA certificate bundle from keychain, this may take a while... ==> Caveats A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /usr/local/etc/openssl@1.1/certs and run /usr/local/opt/openssl@1.1/bin/c_rehash openssl@1.1 is keg-only, which means it was not symlinked into /usr/local, because macOS provides LibreSSL. If you need to have openssl@1.1 first in your PATH, run: echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> /Users/ユーザ名/.b ash_profile For compilers to find openssl@1.1 you may need to set: export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib" export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include" For pkg-config to find openssl@1.1 you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig" ==> Summary ???? /usr/local/Cellar/openssl@1.1/1.1.1k: 8,071 files, 18.5MB Removing: /usr/local/Cellar/openssl@1.1/1.1.1j... (8,071 files, 18.5MB) Removing: /Users/ユーザ名/Library/Caches/Homebrew/openssl@1.1--1.1.1j.big_sur.bot tle.tar.gz... (5.4MB)
$ brew install openssl@1.1 Warning: openssl@1.1 1.1.1k is already installed and up-to-date. To reinstall 1.1.1k, run: brew reinstall openssl@1.1
$ brew reinstall openssl@1.1 ==> Downloading https://homebrew.bintray.com/bottles/openssl%401.1-1.1.1k.big_sur.bot Already downloaded: /Users/ユーザ名/Library/Caches/Homebrew/downloads/fae83f76186 7e592ca8209f4cf851a681825ea9a2b5af870b9237aa35ca1ef0f--openssl@1.1-1.1.1k.big_sur.bot tle.tar.gz ==> Reinstalling openssl@1.1 ==> Pouring openssl@1.1-1.1.1k.big_sur.bottle.tar.gz ==> Regenerating CA certificate bundle from keychain, this may take a while... ==> Caveats A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /usr/local/etc/openssl@1.1/certs and run /usr/local/opt/openssl@1.1/bin/c_rehash openssl@1.1 is keg-only, which means it was not symlinked into /usr/local, because macOS provides LibreSSL. If you need to have openssl@1.1 first in your PATH, run: echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> /Users/ユーザ名/.b ash_profile For compilers to find openssl@1.1 you may need to set: export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib" export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include" For pkg-config to find openssl@1.1 you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig" ==> Summary ???? /usr/local/Cellar/openssl@1.1/1.1.1k: 8,071 files, 18.5MB
$ gem install mysql2 -- --with-cppflags=-I/usr/l ocal/opt/openssl@1.1/include --with-ldflags=-L/usr/local/opt/openssl@1.1/lib Building native extensions with: '--with-cppflags=-I/usr/local/opt/openssl@1.1/includ e --with-ldflags=-L/usr/local/opt/openssl@1.1/lib' This could take a while... ERROR: While executing gem ... (Errno::EACCES) Permission denied @ rb_sysopen - /Users/ユーザ名/.rbenv/versions/3.0.0/lib/ru by/gems/3.0.0/build_info/mysql2-0.5.3.info
$ brew info openssl@1.1 openssl@1.1: stable 1.1.1k (bottled) [keg-only] Cryptography and SSL/TLS Toolkit https://openssl.org/ /usr/local/Cellar/openssl@1.1/1.1.1k (8,071 files, 18.5MB) Poured from bottle on 2021-03-29 at 14:37:20 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openssl@1.1.rb License: OpenSSL ==> Caveats A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in /usr/local/etc/openssl@1.1/certs and run /usr/local/opt/openssl@1.1/bin/c_rehash openssl@1.1 is keg-only, which means it was not symlinked into /usr/local, because macOS provides LibreSSL. If you need to have openssl@1.1 first in your PATH, run: echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> /Users/ユーザ名/.b ash_profile For compilers to find openssl@1.1 you may need to set: export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib" export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include" For pkg-config to find openssl@1.1 you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig" ==> Analytics install: 841,099 (30 days), 2,355,026 (90 days), 8,918,368 (365 days) install-on-request: 73,357 (30 days), 317,809 (90 days), 1,268,061 (365 days) build-error: 0 (30 days)
$ bundle config --local build.mysql2 "--with-cpp flags=-I/usr/local/opt/openssl@1.1/include --with-ldflags=-L/usr/local/opt/openssl@1. 1/lib" You are replacing the current local value of build.mysql2, which is currently "--with -ldflags=-L/usr/local/opt/openssl@1.1/lib --with-cppflags=-I/usr/local/opt/openssl@1. 1/include"
$ bundle install Fetching gem metadata from https://rubygems.org/. Using bundler 2.2.3 Following files may not be writable, so sudo is needed: /Users/ユーザ名/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/build_info/mysql2-0.5 .3.info Fetching mysql2 0.5.3 Your user account isn't allowed to install to the system RubyGems. You can cancel this installation and run: bundle config set --local path 'vendor/bundle' bundle install to install the gems into ./vendor/bundle/, or you can enter your password and install the bundled gems to RubyGems using sudo. Password: Your user account isn't allowed to install to the system RubyGems. You can cancel this installation and run: bundle config set --local path 'vendor/bundle' bundle install to install the gems into ./vendor/bundle/, or you can enter your password and install the bundled gems to RubyGems using sudo. Password: Installing mysql2 0.5.3 with native extensions Bundle complete! 1 Gemfile dependency, 2 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed.
$ bundle install Using bundler 2.2.3 Using mysql2 0.5.3 Following files may not be writable, so sudo is needed: /Users/ユーザ名/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/build_info/mysql2-0.5 .3.info Bundle complete! 1 Gemfile dependency, 2 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed.

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

問題はこれですね。

ld: library not found for -lssl

とりあえずこんな感じで行けるのでは。

$ brew install openssl@1.1 $ gem install mysql2 -- --with-cppflags=-I/usr/local/opt/openssl@1.1/include --with-ldflags=-L/usr/local/opt/openssl@1.1/lib

参考: MacでRailsにgem mysql2をインストールする時のトラブルシューティング - Qiita

投稿2021/03/28 09:40

hoshi-takanori

総合スコア7895

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問