railsでhas_secure_passwordを使いたい
rails tutorialを進めていたら、パスワードの部分でエラーが起きました(https://railstutorial.jp/chapters/modeling_users?version=5.1#sec-adding_a_secure_password)
gemfileでbcryptをコメントアウトして、bundle installを実行して、rails testをしようとしたらエラーになりました。
全く、お手上げの状態です。
発生している問題・エラーメッセージ
/Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bcrypt-3.1.16/lib/bcrypt.rb:12:in `require': dlopen(/Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bcrypt-3.1.16/lib/bcrypt_ext.bundle, 9): no suitable image found. Did find: /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bcrypt-3.1.16/lib/bcrypt_ext.bundle: mach-o, but wrong architecture /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bcrypt-3.1.16/lib/bcrypt_ext.bundle: mach-o, but wrong architecture - /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bcrypt-3.1.16/lib/bcrypt_ext.bundle (LoadError) from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bcrypt-3.1.16/lib/bcrypt.rb:12:in `<top (required)>' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:74:in `require' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:74:in `block (2 levels) in require' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:69:in `each' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:69:in `block in require' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:58:in `each' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:58:in `require' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/2.7.0/bundler.rb:174:in `require' from /Users/user/Documents/ruby-on-rails/sample_app/config/application.rb:7:in `<top (required)>' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:92:in `require' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:92:in `preload' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application.rb:139:in `run' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require' from /Users/user/.rbenv/versions/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require' from -e:1:in `<main>'
Gemfile
ruby
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 9# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 10gem 'rails', '~> 5.1.7' 11# Use Puma as the app server 12gem 'puma', '~> 3.7' 13# Use SCSS for stylesheets 14gem 'sass-rails', '~> 5.0' 15# Bootstrap install 16gem 'bootstrap-sass', '~> 3.4', '>= 3.4.1' 17# Use Uglifier as compressor for JavaScript assets 18gem 'uglifier', '>= 1.3.0' 19# See https://github.com/rails/execjs#readme for more supported runtimes 20# gem 'therubyracer', platforms: :ruby 21 22# Use CoffeeScript for .coffee assets and views 23gem 'coffee-rails', '~> 4.2' 24# user input 25gem 'jquery-rails' 26# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 27gem 'turbolinks', '~> 5' 28# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 29gem 'jbuilder', '~> 2.5' 30# Use Redis adapter to run Action Cable in production 31# gem 'redis', '~> 4.0' 32# Use ActiveModel has_secure_password 33gem 'bcrypt', '~> 3.1.7' 34 35# Use Capistrano for deployment 36# gem 'capistrano-rails', group: :development 37 38group :development, :test do 39 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 40 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 41 # Adds support for Capybara system testing and selenium driver 42 gem 'capybara', '>= 2.15' 43 gem 'selenium-webdriver' 44 # Use sqlite3 as the database for Active Record 45 gem 'sqlite3' 46end 47 48group :development do 49 # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 50 gem 'web-console', '>= 3.3.0' 51 gem 'listen', '>= 3.0.5', '< 3.2' 52 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 53 gem 'spring' 54 gem 'spring-watcher-listen', '~> 2.0.0' 55end 56 57group :test do 58 gem 'rails-controller-testing' 59 gem 'minitest' 60 gem 'minitest-reporters' 61 gem 'guard' 62 gem 'guard-minitest' 63end 64 65group :production do 66 gem 'pg' 67end 68 69# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 70gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
試したこと
- Gemfileを編集
- bundle install
- rails test
- error!!!
補足情報(FW/ツールのバージョンなど)
環境:
macOS Big sur(11.1)
Apple M1
Rails 5.1.7
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [arm64-darwin20]0.
追記(2021/01/27)
なんかM1Macじゃ動かないっぽい?
https://github.com/codahale/bcrypt-ruby/issues/239
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/02/14 03:01