実現したいこと
ruby on railsのプロジェクトを作成して、bundle installを行いましたが、エラーが発生しまして、検索して試したのですが、解決しませんでした。
前提
アプリは作成されています。
bundle installの作業でエラーが発生しました。
発生している問題・エラーメッセージ
ubuntu:~/environment/test-app (master) $ bundle install Fetching gem metadata from https://rubygems.org/........... Fetching gem metadata from https://rubygems.org/. Resolving dependencies........ Using rake 13.0.6 Using concurrent-ruby 1.2.2 Using i18n 1.14.1 Fetching minitest 5.19.0 Installing minitest 5.19.0 Using tzinfo 2.0.6 Fetching zeitwerk 2.6.10 Installing zeitwerk 2.6.10 Using activesupport 6.1.7.4 Using builder 3.2.4 Using erubi 1.12.0 Using racc 1.7.1 Using nokogiri 1.15.3 (x86_64-linux) Using rails-dom-testing 2.1.1 Using crass 1.0.6 Using loofah 2.21.3 Using rails-html-sanitizer 1.6.0 Using actionview 6.1.7.4 Fetching rack 2.2.8 Installing rack 2.2.8 Using rack-test 2.1.0 Using actionpack 6.1.7.4 Using nio4r 2.5.9 Using websocket-extensions 0.1.5 Using websocket-driver 0.7.6 Using actioncable 6.1.7.4 Using globalid 1.1.0 Using activejob 6.1.7.4 Using activemodel 6.1.7.4 Using activerecord 6.1.7.4 Using marcel 1.0.2 Using mini_mime 1.1.2 Using activestorage 6.1.7.4 Using date 3.3.3 Using timeout 0.4.0 Using net-protocol 0.2.1 Fetching net-imap 0.3.7 Installing net-imap 0.3.7 Using net-pop 0.1.2 Using net-smtp 0.3.3 Using mail 2.8.1 Using actionmailbox 6.1.7.4 Using actionmailer 6.1.7.4 Using actiontext 6.1.7.4 Using bindex 0.8.1 Using msgpack 1.7.2 Using bootsnap 1.16.0 Using bundler 2.2.3 Using byebug 11.1.3 Using ffi 1.15.5 Using jbuilder 2.11.5 Using rb-fsevent 0.11.2 Using rb-inotify 0.10.1 Using listen 3.8.0 Using method_source 1.0.0 Fetching mysql2 0.5.5 Installing mysql2 0.5.5 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/mysql2-0.5.5/ext/mysql2 /home/ubuntu/.rvm/rubies/ruby-3.0.0/bin/ruby -I /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0 -r ./siteconf20230801-3012-ggl9jz.rb extconf.rb checking for rb_absint_size()... yes checking for rb_absint_singlebit_p()... yes checking for rb_gc_mark_movable()... yes checking for rb_wait_for_single_fd()... yes checking for rb_enc_interned_str() in ruby.h... yes *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/home/ubuntu/.rvm/rubies/ruby-3.0.0/bin/$(RUBY_BASE_NAME) --with-openssl-dir --without-openssl-dir --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysql-config --without-mysql-config --with-mysqlclient-dir --without-mysqlclient-dir --with-mysqlclient-include --without-mysqlclient-include=${mysqlclient-dir}/include --with-mysqlclient-lib --without-mysqlclient-lib=${mysqlclient-dir}/lib --with-mysqlclientlib --without-mysqlclientlib /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/mkmf.rb:1050:in `block in find_library': undefined method `split' for nil:NilClass (NoMethodError) from /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/mkmf.rb:1050:in `collect' from /home/ubuntu/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/mkmf.rb:1050:in `find_library' from extconf.rb:131:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /home/ubuntu/.rvm/gems/ruby-3.0.0/extensions/x86_64-linux/3.0.0/mysql2-0.5.5/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /home/ubuntu/.rvm/gems/ruby-3.0.0/gems/mysql2-0.5.5 for inspection. Results logged to /home/ubuntu/.rvm/gems/ruby-3.0.0/extensions/x86_64-linux/3.0.0/mysql2-0.5.5/gem_make.out An error occurred while installing mysql2 (0.5.5), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.5.5' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: mysql2
該当のソースコード
Gemfile
1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '3.0.0' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' 7gem 'rails', '~> 6.1.3', '>= 6.1.3.1' 8# Use mysql as the database for Active Record 9gem 'mysql2', '~> 0.5' 10# Use Puma as the app server 11gem 'puma', '~> 5.0' 12# Use SCSS for stylesheets 13gem 'sass-rails', '>= 6' 14# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker 15gem 'webpacker', '~> 5.0' 16# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 17gem 'turbolinks', '~> 5' 18# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 19gem 'jbuilder', '~> 2.7' 20# Use Redis adapter to run Action Cable in production 21# gem 'redis', '~> 4.0' 22# Use Active Model has_secure_password 23# gem 'bcrypt', '~> 3.1.7' 24 25# Reduces boot times through caching; required in config/boot.rb 26gem 'bootsnap', '>= 1.4.4', require: false 27 28group :development, :test do 29 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 30 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 31end 32 33group :development do 34 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 35 gem 'web-console', '>= 4.1.0' 36 # Display performance information such as SQL time and flame graphs for each request in your browser. 37 # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md 38 gem 'rack-mini-profiler', '~> 2.0' 39 gem 'listen', '~> 3.3' 40 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 41 gem 'spring' 42end 43 44# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 45gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
試したこと
検索などで、色々と試してみたのですが、どれも改善に至りませんでした。
railsのバージョン確認でも、下記の表示が出ました。
ubuntu:~/environment/test-app (master) $ rails -v Could not find gem 'mysql2 (~> 0.5)' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems.
補足情報(FW/ツールのバージョンなど)
ruby: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
回答1件
あなたの回答
tips
プレビュー