Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 can';t激活bcrypt-ruby(~>;3.0.0),已激活bcrypt-ruby-3.1.1。确保所有依赖项都添加到文件中_Ruby On Rails 4_Bcrypt Ruby - Fatal编程技术网

Ruby on rails 4 can';t激活bcrypt-ruby(~>;3.0.0),已激活bcrypt-ruby-3.1.1。确保所有依赖项都添加到文件中

Ruby on rails 4 can';t激活bcrypt-ruby(~>;3.0.0),已激活bcrypt-ruby-3.1.1。确保所有依赖项都添加到文件中,ruby-on-rails-4,bcrypt-ruby,Ruby On Rails 4,Bcrypt Ruby,我有Rails 4.0.0应用程序。当我运行bundle安装命令时,没有问题。这是我的档案 source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.0.0' gem 'mysql2' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.0.rc2' # Use Ugl

我有Rails 4.0.0应用程序。当我运行bundle安装命令时,没有问题。这是我的档案

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

gem 'mysql2'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0.rc2'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/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', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

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

# Use debugger
# gem 'debugger', group: [:development, :test]

gem 'pry'
gem 'devise', git: "https://github.com/plataformatec/devise.git", branch: 'rails4'
gem 'bcrypt-ruby'
gem 'simple_form'
gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"
gem 'simple_form'
gem 'jquery-ui-rails'

group :development, :test do
  gem 'rspec-rails', '~> 2.0'
  gem 'cucumber-rails', :git => "https://github.com/cucumber/cucumber-rails.git", :branch => "master_rails4_test", :require => false
  gem 'database_cleaner'
  gem 'factory_girl'
  gem "factory_girl_rails", "~> 4.0"
  gem "database_cleaner"
  gem "awesome_print"
end
这是我的Gemfile.lock

GIT
  remote: https://github.com/cucumber/cucumber-rails.git
  revision: 5fa9da37ab05213d2f46029ea476e09104ffe281
  branch: master_rails4_test
  specs:
    cucumber-rails (1.3.1)
      capybara (>= 1.1.2)
      cucumber (>= 1.2.0)
      nokogiri (>= 1.5.0)
      rails (>= 3.0.0)

GIT
  remote: https://github.com/plataformatec/devise.git
  revision: 6b5988d756d780903bf8c9ccb3e2b3b724ccebe8
  branch: rails4
  specs:
    devise (2.2.4)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 3.2.6, < 5)
      warden (~> 1.2.1)

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.0.0)
      actionpack (= 4.0.0)
      mail (~> 2.5.3)
    actionpack (4.0.0)
      activesupport (= 4.0.0)
      builder (~> 3.1.0)
      erubis (~> 2.7.0)
      rack (~> 1.5.2)
      rack-test (~> 0.6.2)
    activemodel (4.0.0)
      activesupport (= 4.0.0)
      builder (~> 3.1.0)
    activerecord (4.0.0)
      activemodel (= 4.0.0)
      activerecord-deprecated_finders (~> 1.0.2)
      activesupport (= 4.0.0)
      arel (~> 4.0.0)
    activerecord-deprecated_finders (1.0.3)
    activesupport (4.0.0)
      i18n (~> 0.6, >= 0.6.4)
      minitest (~> 4.2)
      multi_json (~> 1.3)
      thread_safe (~> 0.1)
      tzinfo (~> 0.3.37)
    arel (4.0.0)
    atomic (1.1.10)
    awesome_print (1.1.0)
    bcrypt-ruby (3.1.1)
    builder (3.1.4)
    capybara (2.1.0)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    coderay (1.0.9)
    coffee-rails (4.0.0)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0.beta, < 5.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.3)
    commonjs (0.2.6)
    cucumber (1.3.4)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.3)
      gherkin (~> 2.12.0)
      multi_json (~> 1.7.5)
      multi_test (~> 0.0.1)
    database_cleaner (1.0.1)
    diff-lcs (1.2.4)
    erubis (2.7.0)
    execjs (1.4.0)
      multi_json (~> 1.0)
    factory_girl (4.2.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.2.1)
      factory_girl (~> 4.2.0)
      railties (>= 3.0.0)
    gherkin (2.12.0)
      multi_json (~> 1.3)
    hike (1.2.3)
    i18n (0.6.4)
    jbuilder (1.4.2)
      activesupport (>= 3.0.0)
      multi_json (>= 1.2.0)
    jquery-rails (3.0.4)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (4.0.3)
      jquery-rails
      railties (>= 3.1.0)
    json (1.8.0)
    less (2.3.2)
      commonjs (~> 0.2.6)
    less-rails (2.3.3)
      actionpack (>= 3.1)
      less (~> 2.3.1)
    libv8 (3.11.8.17)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    method_source (0.8.1)
    mime-types (1.23)
    mini_portile (0.5.1)
    minitest (4.7.5)
    multi_json (1.7.7)
    multi_test (0.0.1)
    mysql2 (0.3.13)
    nokogiri (1.6.0)
      mini_portile (~> 0.5.0)
    orm_adapter (0.4.0)
    polyglot (0.3.3)
    pry (0.9.12.2)
      coderay (~> 1.0.5)
      method_source (~> 0.8)
      slop (~> 3.4)
    rack (1.5.2)
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (4.0.0)
      actionmailer (= 4.0.0)
      actionpack (= 4.0.0)
      activerecord (= 4.0.0)
      activesupport (= 4.0.0)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.0.0)
      sprockets-rails (~> 2.0.0)
    railties (4.0.0)
      actionpack (= 4.0.0)
      activesupport (= 4.0.0)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.1.0)
    rdoc (3.12.2)
      json (~> 1.4)
    ref (1.0.5)
    rspec-core (2.14.3)
    rspec-expectations (2.14.0)
      diff-lcs (>= 1.1.3, < 2.0)
    rspec-mocks (2.14.1)
    rspec-rails (2.14.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec-core (~> 2.14.0)
      rspec-expectations (~> 2.14.0)
      rspec-mocks (~> 2.14.0)
    sass (3.2.9)
    sass-rails (4.0.0)
      railties (>= 4.0.0.beta, < 5.0)
      sass (>= 3.1.10)
      sprockets-rails (~> 2.0.0)
    sdoc (0.3.20)
      json (>= 1.1.3)
      rdoc (~> 3.10)
    simple_form (1.4.1)
    slop (3.4.5)
    sprockets (2.10.0)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.0.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (~> 2.8)
    therubyracer (0.11.4)
      libv8 (~> 3.11.8.12)
      ref
    thor (0.18.1)
    thread_safe (0.1.0)
      atomic
    tilt (1.4.1)
    treetop (1.4.14)
      polyglot
      polyglot (>= 0.3.1)
    turbolinks (1.3.0)
      coffee-rails
    twitter-bootstrap-rails (2.2.7)
      actionpack (>= 3.1)
      execjs
      rails (>= 3.1)
      railties (>= 3.1)
    tzinfo (0.3.37)
    uglifier (2.1.2)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)
    warden (1.2.3)
      rack (>= 1.0)
    xpath (2.0.0)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  awesome_print
  bcrypt-ruby
  coffee-rails (~> 4.0.0)
  cucumber-rails!
  database_cleaner
  devise!
  factory_girl
  factory_girl_rails (~> 4.0)
  jbuilder (~> 1.2)
  jquery-rails
  jquery-ui-rails
  less-rails
  mysql2
  pry
  rails (= 4.0.0)
  rspec-rails (~> 2.0)
  sass-rails (~> 4.0.0.rc2)
  sdoc
  simple_form
  therubyracer
  turbolinks
  twitter-bootstrap-rails
  uglifier (>= 1.3.0)

我该如何解决这个问题

Add;gem'bcrypt ruby',“~>3.1.1”到您的gem文件

或者,如果您特别想要3.0.0,请按照Maximus的建议添加:gem'bcrypt ruby','3.0.0'

然后绑定更新bcrypt-ruby


您可能还想尝试删除gemfile.lock并重新运行bundle安装。

删除gemfile.lock并指定gem'bcrypt ruby',3.0.0'。运行
捆绑安装
。实际上,在本地gem文件中,应该卸载bcrypt ruby。

在您的gem文件中,您没有指定版本,因此您安装的是bcrypt ruby的最新版本,即3.1.1,但您需要的是3.0.0到3.0.9之间的任何版本。您可以通过添加版本约束来实现这一点,如下所示:

gem 'bcrypt-ruby', '~> 3.0.0'
版本要求来自ActiveModel的SecurePassword,该密码目前明确依赖于bcrypt ruby(~>3.0.0)。您可以看到对的依赖。执行此代码时,它会查找未安装的版本3.0.0到3.0.9,因此会抛出错误


该依赖项在几天前刚刚更新为“~>3.1.0”,但尚未进入rails activemodel gem。当它出现时,您必须相应地更新您的版本。如果你好奇的话,这里有一个问题。

我也有同样的问题。加

gem'bcrypt ruby',“~>3.0.0”

然后跑
捆绑安装
并重新启动服务器。为我工作

我也有同样的问题,但是当前的方法提供了
gem'bcrypt ruby',“~>3.0.0”
不起作用,所以我实际安装了3.0.0版 将行
gem'bcrypt ruby',3.0.0'
添加到Gemfile,并安装特定的3.0.0版(尽管它应该可以工作到3.0.9版)

gem安装--version='3.0.0'bcrypt ruby


之后,只需验证您的bundle安装,您就可以运行
bundle show bcrypt ruby
,然后您应该有安装此gem的路径,类似于

%ruby\u path%/lib/ruby/gems/2.0.0/gems/bcrypt-ruby-3.0.0

经过这些步骤后,我能够毫无问题地使用bcrypt。。。只是在有人仍然遇到这个问题时发布这个

  • 安装3.0.1和3.1.2 bcrypt版本
  • 转到“\Ruby200\lib\ruby\gems\2.0.0\gems\bcrypt-ruby-3.1.2-x86-mingw32\lib”
  • 复制“2.0”文件夹
  • 粘贴到“Ruby200\lib\ruby\gems\2.0.0\gems\bcrypt-ruby-3.0.1-x86-mingw32\lib”
  • 在gem文件中包含gem“bcrypt ruby”
  • 捆绑安装

  • 使用ActiveModel具有\u安全\u密码

    gem 'bcrypt-ruby', '~> 3.0.0'
    

    有同样的问题。正如jconley所提到的,删除上面一行中的注释解决了我的问题。

    对我来说,只需删除/active_model/secure_password.rb For development test environment中对byscript版本的依赖即可

    我总是确保将其添加到生产环境中,使其在控制台中达到100%的安全性:

    $ gem install bundler
    $ gem install bcrypt
    $ bundle update bcrypt
    
    $ gem install bundler
    $ gem install bcrypt
    $ bundle update bcrypt