Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue. #1145

Closed
kelvinlucas opened this issue Nov 2, 2020 · 14 comments

Comments

@kelvinlucas
Copy link

kelvinlucas commented Nov 2, 2020

Hello! Im trying to install Ruby on Rails but Im getting this error while creating a project!
Any ideas how to fix it? Im on macOS Catalina

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.

In Gemfile:
  mysql2
         run  bundle binstubs bundler
Could not find gem 'rails (~> 6.0.3, >= 6.0.3.4)' in any of the gem sources
listed in your Gemfile.
         run  bundle exec spring binstub --all
bundler: command not found: spring
Install missing gem executables with `bundle install`
       rails  webpacker:install
Could not find gem 'rails (~> 6.0.3, >= 6.0.3.4)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
@sodabrew
Copy link
Collaborator

sodabrew commented Nov 2, 2020

This error message doesn't indicate any mysql2 install problem. Perhaps there are some other errors that you haven't pasted here?

Rails 6.0.3.4 certainly exists. Perhaps you had a temporary network failure? https://rubygems.org/gems/rails

@kelvinlucas
Copy link
Author

Perhaps you had a temporary network failure? https://rubygems.org/gems/rails

Here its the full log:

rails new forward_project -d mysql
     create  
     create  README.md
     create  Rakefile
     create  .ruby-version
     create  config.ru
     create  .gitignore
     create  Gemfile
        run  git init from "."
Initialized empty Git repository in /Users/osvaldo/Sites/forward_project/.git/
     create  package.json
     create  app
     create  app/assets/config/manifest.js
     create  app/assets/stylesheets/application.css
     create  app/channels/application_cable/channel.rb
     create  app/channels/application_cable/connection.rb
     create  app/controllers/application_controller.rb
     create  app/helpers/application_helper.rb
     create  app/javascript/channels/consumer.js
     create  app/javascript/channels/index.js
     create  app/javascript/packs/application.js
     create  app/jobs/application_job.rb
     create  app/mailers/application_mailer.rb
     create  app/models/application_record.rb
     create  app/views/layouts/application.html.erb
     create  app/views/layouts/mailer.html.erb
     create  app/views/layouts/mailer.text.erb
     create  app/assets/images
     create  app/assets/images/.keep
     create  app/controllers/concerns/.keep
     create  app/models/concerns/.keep
     create  bin
     create  bin/rails
     create  bin/rake
     create  bin/setup
     create  bin/yarn
     create  config
     create  config/routes.rb
     create  config/application.rb
     create  config/environment.rb
     create  config/cable.yml
     create  config/puma.rb
     create  config/spring.rb
     create  config/storage.yml
     create  config/environments
     create  config/environments/development.rb
     create  config/environments/production.rb
     create  config/environments/test.rb
     create  config/initializers
     create  config/initializers/application_controller_renderer.rb
     create  config/initializers/assets.rb
     create  config/initializers/backtrace_silencers.rb
     create  config/initializers/content_security_policy.rb
     create  config/initializers/cookies_serializer.rb
     create  config/initializers/cors.rb
     create  config/initializers/filter_parameter_logging.rb
     create  config/initializers/inflections.rb
     create  config/initializers/mime_types.rb
     create  config/initializers/new_framework_defaults_6_0.rb
     create  config/initializers/wrap_parameters.rb
     create  config/locales
     create  config/locales/en.yml
     create  config/master.key
     append  .gitignore
     create  config/boot.rb
     create  config/database.yml
     create  db
     create  db/seeds.rb
     create  lib
     create  lib/tasks
     create  lib/tasks/.keep
     create  lib/assets
     create  lib/assets/.keep
     create  log
     create  log/.keep
     create  public
     create  public/404.html
     create  public/422.html
     create  public/500.html
     create  public/apple-touch-icon-precomposed.png
     create  public/apple-touch-icon.png
     create  public/favicon.ico
     create  public/robots.txt
     create  tmp
     create  tmp/.keep
     create  tmp/pids
     create  tmp/pids/.keep
     create  tmp/cache
     create  tmp/cache/assets
     create  vendor
     create  vendor/.keep
     create  test/fixtures
     create  test/fixtures/.keep
     create  test/fixtures/files
     create  test/fixtures/files/.keep
     create  test/controllers
     create  test/controllers/.keep
     create  test/mailers
     create  test/mailers/.keep
     create  test/models
     create  test/models/.keep
     create  test/helpers
     create  test/helpers/.keep
     create  test/integration
     create  test/integration/.keep
     create  test/channels/application_cable/connection_test.rb
     create  test/test_helper.rb
     create  test/system
     create  test/system/.keep
     create  test/application_system_test_case.rb
     create  storage
     create  storage/.keep
     create  tmp/storage
     create  tmp/storage/.keep
     remove  config/initializers/cors.rb
     remove  config/initializers/new_framework_defaults_6_0.rb
        run  bundle install
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Fetching rake 13.0.1
Installing rake 13.0.1
Fetching concurrent-ruby 1.1.7
Installing concurrent-ruby 1.1.7
Fetching i18n 1.8.5
Installing i18n 1.8.5
Fetching minitest 5.14.2
Installing minitest 5.14.2
Fetching thread_safe 0.3.6
Installing thread_safe 0.3.6
Fetching tzinfo 1.2.7
Installing tzinfo 1.2.7
Fetching zeitwerk 2.4.1
Installing zeitwerk 2.4.1
Fetching activesupport 6.0.3.4
Installing activesupport 6.0.3.4
Fetching builder 3.2.4
Installing builder 3.2.4
Fetching erubi 1.9.0
Installing erubi 1.9.0
Fetching mini_portile2 2.4.0
Installing mini_portile2 2.4.0
Fetching nokogiri 1.10.10
Installing nokogiri 1.10.10 with native extensions
Fetching rails-dom-testing 2.0.3
Installing rails-dom-testing 2.0.3
Fetching crass 1.0.6
Installing crass 1.0.6
Fetching loofah 2.7.0
Installing loofah 2.7.0
Fetching rails-html-sanitizer 1.3.0
Installing rails-html-sanitizer 1.3.0
Fetching actionview 6.0.3.4
Installing actionview 6.0.3.4
Fetching rack 2.2.3
Installing rack 2.2.3
Fetching rack-test 1.1.0
Installing rack-test 1.1.0
Fetching actionpack 6.0.3.4
Installing actionpack 6.0.3.4
Fetching nio4r 2.5.4
Installing nio4r 2.5.4 with native extensions
Fetching websocket-extensions 0.1.5
Installing websocket-extensions 0.1.5
Fetching websocket-driver 0.7.3
Installing websocket-driver 0.7.3 with native extensions
Fetching actioncable 6.0.3.4
Installing actioncable 6.0.3.4
Fetching globalid 0.4.2
Installing globalid 0.4.2
Fetching activejob 6.0.3.4
Installing activejob 6.0.3.4
Fetching activemodel 6.0.3.4
Installing activemodel 6.0.3.4
Fetching activerecord 6.0.3.4
Installing activerecord 6.0.3.4
Fetching mimemagic 0.3.5
Installing mimemagic 0.3.5
Fetching marcel 0.3.3
Installing marcel 0.3.3
Fetching activestorage 6.0.3.4
Installing activestorage 6.0.3.4
Fetching mini_mime 1.0.2
Installing mini_mime 1.0.2
Fetching mail 2.7.1
Installing mail 2.7.1
Fetching actionmailbox 6.0.3.4
Installing actionmailbox 6.0.3.4
Fetching actionmailer 6.0.3.4
Installing actionmailer 6.0.3.4
Fetching actiontext 6.0.3.4
Installing actiontext 6.0.3.4
Fetching public_suffix 4.0.6
Installing public_suffix 4.0.6
Fetching addressable 2.7.0
Installing addressable 2.7.0
Fetching bindex 0.8.1
Installing bindex 0.8.1 with native extensions
Fetching msgpack 1.3.3
Installing msgpack 1.3.3 with native extensions
Fetching bootsnap 1.5.0
Installing bootsnap 1.5.0 with native extensions
Using bundler 2.1.4
Fetching byebug 11.1.3
Installing byebug 11.1.3 with native extensions
Fetching regexp_parser 1.8.2
Installing regexp_parser 1.8.2
Fetching xpath 3.2.0
Installing xpath 3.2.0
Fetching capybara 3.33.0
Installing capybara 3.33.0
Fetching childprocess 3.0.0
Installing childprocess 3.0.0
Fetching ffi 1.13.1
Installing ffi 1.13.1 with native extensions
Fetching jbuilder 2.10.1
Installing jbuilder 2.10.1
Fetching rb-fsevent 0.10.4
Installing rb-fsevent 0.10.4
Fetching rb-inotify 0.10.1
Installing rb-inotify 0.10.1
Fetching listen 3.2.1
Installing listen 3.2.1
Fetching method_source 1.0.0
Installing method_source 1.0.0
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/osvaldo/Sites/forward_project/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.3/ext/mysql2
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r
./siteconf20201102-77862-1ouklu1.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
-----
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/8.0.22/lib
-----
creating Makefile

current directory:
/Users/osvaldo/Sites/forward_project/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.3/ext/mysql2
make "DESTDIR=" clean

current directory:
/Users/osvaldo/Sites/forward_project/vendor/bundle/ruby/2.6.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: warning: directory not found for option
'-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/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/osvaldo/Sites/forward_project/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.3
for inspection.
Results logged to
/Users/osvaldo/Sites/forward_project/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-19/2.6.0/mysql2-0.5.3/gem_make.out

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.

In Gemfile:
 mysql2
        run  bundle binstubs bundler
Could not find gem 'rails (~> 6.0.3, >= 6.0.3.4)' in any of the gem sources
listed in your Gemfile.
        run  bundle exec spring binstub --all
bundler: command not found: spring
Install missing gem executables with `bundle install`
      rails  webpacker:install
Could not find gem 'rails (~> 6.0.3, >= 6.0.3.4)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.



@sodabrew
Copy link
Collaborator

sodabrew commented Nov 2, 2020

linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option
'-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/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

See the comments at #795 (comment)

@kelvinlucas
Copy link
Author

kelvinlucas commented Nov 3, 2020

It worked. Thank you so much!!

@salmanx
Copy link

salmanx commented Jan 5, 2022

This will solve the problem. It means you have some dependencies that's not installed in your machine.
sudo apt-get install libmysqlclient-dev

@coopeu
Copy link

coopeu commented Jan 26, 2022

Mysql2 error fixed on DEBIAN 10 Ruby 3.1.0 and Rails 7.0.1 installing this other replacing packages of libmysqlclient-dev

sudo apt-get install libmariadb-dev-compat libmariadb-dev

@Thebluedragon7
Copy link

Thebluedragon7 commented Oct 3, 2022

This will solve the problem. It means you have some dependencies that's not installed in your machine. sudo apt-get install libmysqlclient-dev

what about on a windows [11] machine?

@navid-farjad
Copy link

@Thebluedragon7 how did you solve it?

@Azrodt
Copy link

Azrodt commented Jan 11, 2023

If someone know how we can applicate this command on windows ,that be nice

@Faq
Copy link

Faq commented Jan 11, 2023

@Azrodt this issue is about MAC and is closed. Check there are some opened issues for windows. If such error not reported for win, just open new one with details.

@Tiago321123
Copy link

This will solve the problem. It means you have some dependencies that's not installed in your machine. sudo apt-get install libmysqlclient-dev

This solved for me! Thanks!!

@InsHomePgup
Copy link

I'm install redmine. Use Mariadb. I got this msg 'An error occurred while installing mysql2 (0.5.5), and Bundler cannot continue.'

@InsHomePgup
Copy link

use ' apt install libmariadb-dev ' then bundle install again.

@gurdeep-punchh
Copy link

use ' apt install libmariadb-dev ' then bundle install again.

worked for me thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests