Błąd podczas próby instalacji aplikacji z mysql2 gem

Próbuję zainstalować aplikację open source rails 3.2.21, która używa mysql2 gem, ale kiedy próbuję uruchomićbundle commant, dostaję następujący błąd:

Fetching: mysql2-0.3.18.gem (100%)
Building native extensions.  This could take a while...
p
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    /Users/my_username/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20150614-72129-orqsb7.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.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/Cellar/mysql/5.6.25/lib
-----
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option '-L/Users/travis/.sm/pkg/active/lib'
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/my_username/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/gems/mysql2-0.3.18 for inspection.
Results logged to /Users/my_username/.rvm/rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/extensions/x86

Próbowałem odinstalować każdą wersję mysql zainstalowałem przez homebrew i ponownie je zainstalować, Tak:

brew uninstall --force mysql && brew install mysql

Następnie uruchomić:

sudo gem install mysql2

Zgodnie z sugestią wielu podobnych pytań zadanych tutaj, ale nadal powoduje ten sam błąd, co powyżej.

Proszę, czy ktoś mógłby zaoferować wskazówki, jak to uruchomić?

Author: Hichem BOUSSETTA, 2015-06-14

11 answers

Dziennik błędów mówi:

ld: library not found for -lssl

Więc musisz zainstalować libssl:

brew install openssl

Jak zaznaczono w komentarzach, może zaistnieć potrzeba wyeksportowania ścieżki do biblioteki.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
 56
Author: Aleksei Matiushkin,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-02-19 06:20:01

Dla każdego, kto nadal doświadcza problemu:

Kiedy instalujesz openssl przez brew, powinieneś otrzymać następujący komunikat:

Apple wycofało użycie OpenSSL na rzecz własnych bibliotek TLS i crypto

Ogólnie nie ma żadnych konsekwencji dla Ciebie. Jeśli zbudujesz swój własne oprogramowanie i wymaga tej formuły, musisz dodać do swojego build variables:

LDFLAGS:- L/usr/local/opt/openssl/lib
CPPFLAGS: -I / usr / local/opt/openssl / include
PKG_CONFIG_PATH: / usr/local/opt/openssl/lib / pkgconfig

Możesz ustawić te flagi budowania (dla aplikacji lokalnej), uruchamiając następujące polecenie:

bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"
To mi pomogło. Więcej informacji można znaleźć w dokumentacji bundlera.
 162
Author: Alessandro Berardi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-09-22 00:31:27

Spróbuj tego:

gem install mysql2 -v '0.5.2' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include

(odpowiednio Zaktualizuj wersję)

 38
Author: stereodenis,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-05-11 15:31:23

Rozwiązaniem dla mnie było zainstalowanie narzędzi wiersza poleceń Xcode.

Niedawno zaktualizowałem Xcode za pośrednictwem Mac App Store i za każdym razem, gdy to robię, odkryłem, że muszę ponownie zainstalować narzędzia wiersza poleceń.

xcode-select --install
 36
Author: Allen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-10-30 10:30:38

Na podstawie rozwiązania Tutaj

brew install openssl

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
Rozwiązałem problem.
 29
Author: Gilg Him,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-06-18 20:15:33

Dzięki @mudasobwa za wskazanie mnie we właściwym kierunku. Okazuje się, że błąd został spowodowany przez nie powiązany plik openssl, więc uruchamia się:

brew reinstall openssl && brew link openssl --force 
Rozwiązałem problem. Znalazłem rozwiązanie tutaj: OpenSSL, RVM, Brew, conflicting error
 10
Author: zenvelope,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 11:55:00
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

Stąd: https://gorails.com/setup/osx/10.14-mojave

 2
Author: k1r8r0wn,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-05-01 21:24:56

Kombinacja komend rozwiązała mnie. Jestem na Mojave.

brew reinstall openssl && brew link openssl --force

A następnie

gem install mysql2 -v '0.4.10' -- \
  --with-ldflags=-L/usr/local/opt/openssl/lib \
  --with-cppflags=-I/usr/local/opt/openssl/include
 2
Author: Haseeb Zulfiqar,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-02-19 06:20:33

Po aktualizacji Homebrew ([email protected]) istnieje nowa ścieżka do libs, więc może używać:

bundle config build.mysql2 --with-opt-dir=$(brew --prefix openssl)
bundle install

Naprawi ld: library not found for -lssl error

 2
Author: Alexey Morozov,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-07-31 13:51:42

Wygląda na to, że brakuje Ci głównych plików potrzebnych do zbudowania mysql2 gem

sudo apt-get install libsqlite3-dev libmysqlclient-dev -y

libsqlite3-dev nie jest obowiązkowe, ale zainstaluj go, ponieważ jest to domyślny rails DB.

 1
Author: Emad Saeed,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2020-04-28 03:54:42

Stwierdziłem, że muszę użyć --with-opt-dir=/usr/local/opt.

W szczególności do mojego pliku ~/.bundle/config dodałem:

BUNDLE_BUILD__MYSQL2: "--with-opt-dir=/usr/local/opt"
 -1
Author: Brian J. Fox,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2019-03-14 00:04:44