我使用设备gem创建了一个应用程序,而不是运行bundle instal。
比我尝试运行此命令后
rails generate devise:install
但我收到错误
Could not find bcrypt-3.1.11 in any of the sources
Run `bundle install` to install missing gem...
我做了bundle install
我试过这个gem install bcrypt
来安装这个gem
我尝试bundle update
而不是运行
bundle exec rails generate devise:install
但我仍然得到同样的错误。
的Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# 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'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
gem 'devise'
答案 0 :(得分:3)
取消注释Gemfile
的这一行:
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
再次运行bundle install
。
答案 1 :(得分:3)
从spring
删除所有Gemfile
。
gem "spring"
gem "spring-commands-rspec"
运行bundle install
不知道为什么我尝试用spring做另一个应用程序。 :(
答案 2 :(得分:1)
运行{{1}}
我刚遇到同样的问题。我做了@Uday kumar das建议的,它完美无缺!
答案 3 :(得分:1)
我花了几个小时才完成这个工作,但请随意分享。这里的根本问题是Ruby本身带有bcrypt
版本3.1.5,它有更新的更新错误。
但是,当您安装或卸载bcrypt
时,它会首先要求bcrypt-ruby
,因此您所做的一切都不会通过,所以该怎么做?
通过运行以下两个命令卸载bcrypt
和bcrypt-ruby
:
gem uninstall bcrypt and gem uninstall bcrypt-ruby
使用以下命令重新安装:
gem install bcrypt --platform=ruby
在你的Gemfile中写:
gem 'bcrypt','~>3.1.11'
现在,当我写这些行时,最新版本是3.1.11
但是无论版本如何更新,只需从他们的宝石页面添加它。运行bundle install,它应该可以正常工作。
答案 4 :(得分:1)
我遇到了同样的问题。我通过将项目克隆到另一个文件夹并在新克隆的项目中运行bundle install
来解决问题。然后我能够再次运行rails
命令。希望这会有所帮助。
答案 5 :(得分:0)
将此行添加到您的gemfile中此代码:
gem 'bcrypt'
然后在控制台中运行bundle install
。
答案 6 :(得分:0)
在我的情况下,我卸载了所有版本的bcrypt,使用gem uninstall bcrypt并选择选项3(如果存在),并使用gem uninstall bcrypt-ruby卸载所有版本的bcrypt-ruby gem并选择选项3(如果是然后我使用gem install bcrypt -platform = ruby安装了bcrypt,我添加了这行gem'bcrypt','〜&gt; 3.1.7'在Gemfile中。它运作正常。
答案 7 :(得分:0)
在搜索了很多回复之后,对我来说这是Rails-5.0.2上的解决方案:
spring stop
bundle exec rake rails:update:bin
bundle exec spring binstub --all
答案 8 :(得分:0)
在安装devise 4.6.2之后,我对bcrypt 3.1.12遇到了同样的问题。我不认为这是专门针对地穴或设计的,我相信这是一个弹簧问题,正如其他人指出的那样。
我能够简单地通过停止弹簧并重新运行rails generator来解决此问题
spring stop
rails g devise:install
在进行任何破坏性或侵入性操作之前,请尝试一下。
答案 9 :(得分:0)
gem pristine -a
bundle install
bundle update
为我解决了这个问题
由于先前的尝试,我也将这些行注释掉了,不确定是否有帮助。
# gem 'spring'
# gem 'spring-watcher-listen', '~> 2.0.0'