【问题标题】:LoadError in Devise::RegistrationsController#create设计中的 LoadError::RegistrationsController#create
【发布时间】:2017-04-17 23:38:00
【问题描述】:

我正在使用 devise 的 gem,但在 Devise::RegistrationsController#create 中出现错误 LoadError 无法加载此类文件 -- bcrypt_ext .. 我尝试对此问题进行一些研究,并尝试按照给出的说明进行操作(https://stackoverflow.com/questions/35422463/loaderror-in-deviseregistrationscontrollercreate-cannot-load-such-file-bc)

但还是有这个问题。有什么建议吗?

注意:我使用的指南是 video guide,我在 Windows 7 上使用 ruby​​ on rails

宝石文件

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end
# error in devise
gem 'bcrypt-ruby', '~> 3.1', '>= 3.1.5'
# Bundle for authentication
gem 'devise', '~> 4.2', '>= 4.2.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.0.rc1'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', github: "rails/sass-rails"

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# 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', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

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]
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '~> 2.13.0'
  gem 'selenium-webdriver'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

【问题讨论】:

  • 取消注释# gem 'bcrypt', '~&gt; 3.1.7' 并运行bundle install
  • 我检查了我的 gem,它现在被列出 bcrypt (3.1.11 ruby​​ x86-mingw32) bcrypt-ruby (3.1.5 x86-mingw32) 我也重新启动了 serverf
  • Wups,现在我无法运行 rails 服务器,因为它给了我这个错误“C:/RailsInstaller/Ruby2.3.​​0/lib/ruby/gems/2.3.0/gems/activesupport-5.1. 0.rc1/lib/active_support/dependencies.rb:292:in `require': cannot load such file -- bcrypt_ext (LoadError) "
  • @Angel 这可能会有所帮助stackoverflow.com/questions/33588735/…

标签: ruby-on-rails windows devise


【解决方案1】:

我也遇到了同样的错误,我的问题已经解决了,请尝试solution 3

问题是编译的 windows gem。最好删掉,只包含纯ruby版本。

解决方案一:

您可以将 bcrypt_ext.so 从 \lib\2.1 复制到 \lib 与 bcrypt.rb 相同的文件夹

解决方案二:

您可以使用 gem install bcrypt --platform=ruby,即使我无法从始终使用编译版本的 rails 中选择它

解决方案三:

git 克隆https://github.com/codahale/bcrypt-ruby.git

cd bcrypt-ruby

gem 构建 bcrypt.gemspec

gem 安装 gem 编译器

gem 编译 bcrypt-3.1.10.gem

gem install bcrypt-3.1.10-x64-mingw32.gem --local

【讨论】:

  • 在 Windows 7 64bit 上我有 bcrypt-3.1.11.gembcrypt-3.1.11-x86-mingw32.gem 我在您的解决方案三中使用过,对我有用。谢谢!
【解决方案2】:

请做一件事,它会解决你的问题

删除版本,然后把它写在你的 Gemfile 中

gem 'bcrypt-ruby'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-07
    • 2017-02-25
    • 2012-09-24
    • 1970-01-01
    • 2014-10-17
    • 1970-01-01
    • 2023-03-21
    • 2014-01-19
    相关资源
    最近更新 更多