[RUBY] [Rails s Fehler] md5.bundle und MySQL Installationsfehler

Ziel

Führen Sie Rails s ohne Probleme mit erstellten Apps aus

Aktuell

$ rails s
Kürzung)
/Users/Benutzername/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': dlopen(/Users/Benutzername/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin18/digest/md5.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
Referenced from: /Users/Benutzername/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin18/digest/md5.bundle
Reason: image not found - /Users/Benutzername/.rbenv/versions/2.5.1/lib/ruby/2.5.0/x86_64-darwin18/digest/md5.bundle

Ursache

Hat sich die openssl-Version infolge der Erstellung der Python-Umgebung geändert?

Was ich getan habe

Rubin neu installieren

Ein Fehler ist aufgetreten, weil die von Ruby referenzierte Version von OpenSSL verloren gegangen ist. Anscheinend bleibt keine andere Wahl, als neu zu installieren

$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin18]
$ rbenv uninstall 2.5.1
$ rbenv install 2.5.1
$ruby -v 
# ruby 2.5.1p0 OK, wenn es als ← angezeigt wird

Versuchen Sie die Bundle-Installation

$ bundle install
Traceback (most recent call last):
    2: from /Users/<Nutzername>/.rbenv/versions/2.5.3/bin/bundle:23:in `<main>'
    1: from /Users/<Nutzername>/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/<Nutzername>/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

。。。

Es scheint, dass die Bundle-Version und die globale Version im App-Verzeichnis unterschiedlich sind

Anpassung der Bundler-Version

Überprüfen Sie die gemfile in der App

gemfile.lock


RUBY VERSION
   ruby 2.5.1p57

BUNDLED WITH
   2.0.2

Überprüfen Sie die aktuelle Version

bundler -v
Bundler version 2.0.1

Spiel

$ gem uninstall bundler -v 2.0.1
$ gem install bundler -v 2.0.2

Versuchen Sie die Bundle-Installation

$ bundle install

(Es werden verschiedene Gem-Installationsprotokolle angezeigt.
.
.
.
Installing ...
Fetching mysql2 0.5.2
Installing mysql2 0.5.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/fukudatakumi/tabelog/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/ext/mysql2
/Users/fukudatakumi/.rbenv/versions/2.5.1/bin/ruby -I /Users/fukudatakumi/.rbenv/versions/2.5.1/lib/ruby/site_ruby/2.5.0 -r ./siteconf20190321-35638-onb5bd.rb extconf.rb
--with-opt-lib\=/usr/local/opt/openssl/lib\ --with-opt-include\=-I/usr/local/opt/openssl/include
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
-----
Using mysql_config at /usr/local/opt/[email protected]/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.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 MYSQL.net.vio in mysql.h... yes
checking for MYSQL.net.pvio in mysql.h... no
checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes
checking for SERVER_QUERY_NO_GOOD_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_NO_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_WAS_SLOW in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_ON in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_OFF in mysql.h... yes
checking for my_bool in mysql.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/opt/[email protected]/lib
-----
creating Makefile

current directory: /Users/fukudatakumi/tabelog/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/ext/mysql2
make "DESTDIR=" clean

current directory: /Users/fukudatakumi/tabelog/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2/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: warning: directory not found for option '-L/usr/local/opt/openssl/lib --with-opt-include=-I/usr/local/opt/openssl/include'
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/fukudatakumi/tabelog/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2 for inspection.
Results logged to /Users/fukudatakumi/tabelog/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-18/2.5.0-static/mysql2-0.5.2/gem_make.out

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.

Der Fehler hat sich geändert, aber ... Make sure that gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/' succeeds before bundling. Weil es scheint Möchten Sie MySQL installieren?

MySQL-Installation

Versuchen Sie, den angewiesenen Code einzugeben

$ gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'
Fetching mysql2 0.5.3
Installing mysql2 0.5.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/name/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/ext/mysql2
/Users/name/.rbenv/versions/2.5.3/bin/ruby -r ./siteconf20181128-2670-lgcxlu.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.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 MYSQL.net.vio in mysql.h... yes
checking for MYSQL.net.pvio in mysql.h... no
checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes
checking for SERVER_QUERY_NO_GOOD_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_NO_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_WAS_SLOW in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_ON in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_OFF in mysql.h... yes
checking for my_bool in mysql.h... no
-----
Dont 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/8.0.12/lib
-----
creating Makefile

current directory: /Users/name/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/ext/mysql2
make "DESTDIR=" clean

current directory: /Users/name/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/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/name/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3 for inspection.
Results logged to /Users/name/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0-static/mysql2-0.5.3/gem_make.out

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

In Gemfile:
  mysql2

Anscheinend ld: library not found for -lssl Scheint einen Fehler zu verursachen

https://qiita.com/HrsUed/items/ca2e0aee6a2402571cf6 Bitte beziehen Sie sich auf

terminal


$ brew info openssl
[email protected]: stable 1.1.1g (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/usr/local/Cellar/[email protected]/1.1.1g (8,059 files, 18MB)
  Poured from bottle on 2020-05-20 at 17:52:32
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/[email protected]
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/[email protected]/certs

and run
  /usr/local/opt/[email protected]/bin/c_rehash

[email protected] is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> /Users/user/.bash_profile

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
For pkg-config to find [email protected] you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"

==> Analytics
install: 578,162 (30 days), 1,761,588 (90 days), 7,253,878 (365 days)
install-on-request: 61,776 (30 days), 207,766 (90 days), 910,622 (365 days)
build-error: 0 (30 days)

export LDFLAGS="-L/usr/local/opt/[email protected]/lib" export CPPFLAGS="-I/usr/local/opt/[email protected]/include" Installieren Sie mit dem Wert dieser Option

gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/' -- --with-cppflags=-I/usr/local/opt/[email protected]/include --with-ldflags=-L/usr/local/opt/[email protected]/lib

Versuchen Sie die Bundle-Installation versuchen Sie Schienen s

Ende

Recommended Posts

[Rails s Fehler] md5.bundle und MySQL Installationsfehler
[Rails] Fehler während der Installation des Geräts
Rails Tutorial-Datensatz und Memorandum Nr. 1 "Von der Installation bis zur Bereitstellung von hello_app + Fehlerbehandlung"
Schienen und Formulardaten
Fehler beim Bereitstellen von Rails5 + MySQL auf Heroku mit Docker-Compose
[Rails] So geben Sie Erfolgs- und Fehlermeldungen aus
[In der Teamentwicklung] Fehler beim Wechsel in den Zweig eines anderen Mitglieds und beim Ausführen von Rails s [Rails]
[Rails] Fehlermeldung anzeigen - Unterschied zwischen render und redirect_to, flash-
[Hinweis] Rails-Fehlerliste
Catch Rails Routing-Fehler
Schienen gültig und ungültig?
[Rails] Entwicklung mit MySQL
Beheben Sie Mysql2 :: Error :: ConnectionError
Schienen, RSpec-Installationsverfahren
[Rails] Heroku-Bereitstellungsfehler ActionView :: Template :: Error (Mysql2 :: Error: Tabelle --- existiert nicht):