質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

2回答

1122閲覧

Railsでbcryptを使いたい

shinzanmono

総合スコア0

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

1クリップ

投稿2021/01/27 13:03

編集2021/01/27 13:43

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]

試したこと

  1. Gemfileを編集
  2. bundle install
  3. rails test
  4. 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

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

なんかgem install bcrypt叩いたらできた。

投稿2021/02/13 19:25

shinzanmono

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

0

コメントアウトしてはいけません。
コメントであったのをコメントでなくした、のですよね。
コメントアウトは コメントにして掃き出す ことをいいます。

で、
wrong architecture だと言ってます。
Macだと
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
これが悪さしているのでは??
「コメントアウト」してみてください

投稿2021/02/06 12:53

winterboum

総合スコア23347

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

shinzanmono

2021/02/06 16:42

コメントアウトの使い方を間違えていました。正しくは「gemfileでbcryptのコメントを外して」ですね... 早速、'tzinfo-data'の行を「コメントアウト」してみたのですが、やはり同じエラーが起きます。エラー文も同じでした。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問