前提・実現したいこと
ローカル環境でRailsのデータベースにMySQLを使いたい
OS:Windows10
Ruby,Railsはインストール済
MySQLは下記サイトを参考にインストール済
→https://www.webdlab.com/local/local-mysql-4/
database.yml
# MySQL. Versions 5.1.10 and up are supported. # # Install the MySQL driver # gem install mysql2 # # Ensure the MySQL gem is defined in your Gemfile # gem 'mysql2' # # And be sure to use new-style password hashing: # https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html # default: &default adapter: mysql2 encoding: utf8 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: host: localhost development: <<: *default database: gathernet_development # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: gathernet_test # As with config/secrets.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is # ever seen by anyone, they now have access to your database. # # Instead, provide the password as a unix environment variable when you boot # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database # for a full rundown on how to provide these environment variables in a # production deployment. # # On Heroku and other platform providers, you may have a full connection URL # available as an environment variable. For example: # # DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" # # You can use this database configuration with: # # production: # url: <%= ENV['DATABASE_URL'] %> # production: <<: *default database: gathernet_production username: gathernet password: <%= ENV['GATHERNET_DATABASE_PASSWORD'] %>
Gemfile
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.6.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.3' # Use mysql as the database for Active Record gem 'mysql2', '>= 0.4.4', '< 0.6.0' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes gem 'duktape' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use ActiveStorage variant # gem 'mini_magick', '~> 4.8' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome gem 'chromedriver-helper' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
発生している問題・エラーメッセージ
rails db:create
...
rails aborted!
LoadError: cannot load such file -- mysql2/2.6/mysql2
...
C:\Users\syuwa\rails\gathernet>rails db:create C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/mysql2-0.4.10-x64-mingw32/lib/mysql2.rb:22: warning: Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead rails aborted! LoadError: cannot load such file -- mysql2/2.6/mysql2 C:/Users/syuwa/rails/gathernet/config/application.rb:7:in `<top (required)>' C:/Users/syuwa/rails/gathernet/Rakefile:4:in `require_relative' C:/Users/syuwa/rails/gathernet/Rakefile:4:in `<top (required)>' bin/rails:4:in `require' bin/rails:4:in `<main>' (See full trace by running task with --trace)
該当のソースコード
試したこと
gem uninstall mysql2
gem install mysql2 --platform=ruby
の実行
C:\Users\syuwa\rails\gathernet>gem uninstall mysql2 Successfully uninstalled mysql2-0.4.10-x64-mingw32 Successfully uninstalled mysql2-0.5.2 C:\Users\syuwa\rails\gathernet>gem install mysql2 --platform=ruby Fetching mysql2-0.5.2.gem Temporarily enhancing PATH for MSYS/MINGW... Installing required msys2 packages: mingw-w64-x86_64-libmariadbclient 警告: mingw-w64-x86_64-libmariadbclient-2.3.5-2 は最新です -- スキップ Building native extensions. This could take a while... Successfully installed mysql2-0.5.2 Parsing documentation for mysql2-0.5.2 Installing ri documentation for mysql2-0.5.2 Done installing documentation for mysql2 after 2 seconds 1 gem installed C:\Users\syuwa\rails\gathernet>rails db:create Could not find mysql2-0.4.10-x64-mingw32 in any of the sources Run `bundle install` to install missing gems.
ローカル開発環境の構築に丸2日くらいかかっているのですが、中々できないのでどなたか助けて頂けると非常に嬉しいです。
補足情報(FW/ツールのバージョンなど)
ruby 2.6.1p33 (2019-01-30 revision 66950) [x64-mingw32]
Rails 5.2.3
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/17 23:21