#課題
とある課題で。mysqlのgemをインストールしないといけないのですが、以下のエラーにハマって
解決できません。
パスが関係しているようなのですが、よく理解できないままです...
% gem install mysql2 -v '0.4.6' Fetching: mysql2-0.4.6.gem (100%) Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. current directory: /Users/ts/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.6/ext/mysql2 /Users/ts/.rbenv/versions/2.3.3/bin/ruby -r ./siteconf20200406-97934-n7ifg7.rb extconf.rb checking for rb_absint_size()... yes checking for rb_absint_singlebit_p()... yes checking for ruby/thread.h... yes checking for rb_thread_call_without_gvl() in ruby/thread.h... yes checking for rb_thread_blocking_region()... no checking for rb_wait_for_single_fd()... yes checking for rb_hash_dup()... yes checking for rb_intern3()... yes checking for rb_big_cmp()... yes ----- Using mysql_config at /usr/local/bin/mysql_config ----- checking for mysql.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 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/8.0.19/lib ----- creating Makefile To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/ts/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-19/2.3.0-static/mysql2-0.4.6/mkmf.log current directory: /Users/ts/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.6/ext/mysql2 make "DESTDIR=" clean current directory: /Users/ts/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.6/ext/mysql2 make "DESTDIR=" compiling infile.c compiling client.c client.c:869:10: error: use of undeclared identifier 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'? case MYSQL_SECURE_AUTH: ^~~~~~~~~~~~~~~~~ MYSQL_DEFAULT_AUTH /usr/local/Cellar/mysql/8.0.19/include/mysql/mysql.h:187:3: note: 'MYSQL_DEFAULT_AUTH' declared here MYSQL_DEFAULT_AUTH, ^ client.c:1291:38: error: use of undeclared identifier 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'? return _mysql_client_options(self, MYSQL_SECURE_AUTH, value); ^~~~~~~~~~~~~~~~~ MYSQL_DEFAULT_AUTH /usr/local/Cellar/mysql/8.0.19/include/mysql/mysql.h:187:3: note: 'MYSQL_DEFAULT_AUTH' declared here MYSQL_DEFAULT_AUTH, ^ 2 errors generated. make: *** [client.o] Error 1 make failed, exit code 2 Gem files will remain installed in /Users/ts/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.6 for inspection. Results logged to /Users/ts/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-19/2.3.0-static/mysql2-0.4.6/gem_make.out
#やったこと
pathが関係していると思い、ここを参考にして
.zshenvに
PATH=/usr/local/mysql/bin:$PATH export PATH
を追記しましたがうまくいかず。。。
#もしかしたら
gemのバージョンが関係しているのでしょうか?
gemfileはこんな感じです
gemfil
1source 'https://rubygems.org' 2 3git_source(:github) do |repo_name| 4 repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 5 "https://github.com/#{repo_name}.git" 6end 7 8# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 9gem 'rails', '~> 5.1.1' 10# Use mysql as the database for Active Record 11gem 'mysql2', '>= 0.3.18', '< 0.5' 12# Use Puma as the app server 13gem 'puma', '~> 3.7' 14# Use SCSS for stylesheets 15gem 'sass-rails', '~> 5.0' 16# Use Uglifier as compressor for JavaScript assets 17gem 'uglifier', '>= 1.3.0' 18# See https://github.com/rails/execjs#readme for more supported runtimes 19gem 'therubyracer', platforms: :ruby 20 21# Use CoffeeScript for .coffee assets and views 22gem 'coffee-rails', '~> 4.2' 23# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 24gem 'turbolinks', '~> 5' 25# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 26gem 'jbuilder', '~> 2.5' 27# Use Redis adapter to run Action Cable in production 28# gem 'redis', '~> 3.0' 29# Use ActiveModel has_secure_password 30# gem 'bcrypt', '~> 3.1.7' 31 32# Use Capistrano for deployment 33# gem 'capistrano-rails', group: :development 34 35gem 'config' 36gem 'devise', '~> 4.3' 37gem 'devise-i18n' 38gem 'rails-i18n' 39gem 'ridgepole' 40gem 'bootstrap-sass' 41gem 'jquery-rails' 42gem 'jquery-ui-rails' 43gem 'kaminari' 44gem 'jp_prefecture' 45gem 'paranoia' 46gem 'ransack', github: 'activerecord-hackery/ransack' 47gem 'enum_help' 48gem 'data-confirm-modal' 49gem 'rails-i18n' 50gem 'gmo' 51gem 'mechanize' 52gem 'activerecord-import' 53gem 'aws-sdk-rails' 54 55gem 'whenever', :require => false 56gem 'pry-rails' 57 58# deliver_later 59gem 'delayed_job' 60gem 'delayed_job_active_record' 61 62gem 'daemons' 63 64# for cohort 65gem 'chart-js-rails' 66gem 'gon' 67gem 'slim-rails' 68 69group :development, :test do 70 gem 'rspec-rails', '~> 3.5' 71 gem 'factory_girl_rails' 72 gem 'faker' 73 gem 'json_spec' 74end 75 76group :test do 77 gem 'webmock' 78 gem 'vcr' 79 gem 'database_cleaner' 80 gem 'timecop' 81 gem 'spring-commands-rspec' 82end 83 84group :development do 85 # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 86 gem 'web-console', '>= 3.3.0' 87 gem 'listen', '>= 3.0.5', '< 3.2' 88 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 89 gem 'spring' 90 gem 'spring-watcher-listen', '~> 2.0.0' 91 gem 'letter_opener_web' 92 gem 'better_errors' 93 gem 'binding_of_caller' 94end 95 96# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 97gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 98
かなり古いバージョンです
あなたの回答
tips
プレビュー