2013-07-19 51 views
16

Tôi có ứng dụng Rails 4.0.0. Khi tôi chạy lệnh cài đặt bó thì không có vấn đề gì. Đây là GemFile của tôi.không thể kích hoạt bcrypt-ruby (~> 3.0.0), đã được kích hoạt bcrypt-ruby-3.1.1. Đảm bảo tất cả các phụ thuộc được thêm vào Gemfile

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 

Và đây là Gemfile.lock tôi

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) 

Khi tôi chạy rake sometask, tôi phải đối mặt với vấn đề này,

You don't have bcrypt-ruby installed in your application. Please add it to your Gemfile and run bundle install 
rake aborted! 
can't activate bcrypt-ruby (~> 3.0.0), already activated bcrypt-ruby-3.1.1. Make sure all dependencies are added to Gemfile. 
/Users/apple/.rvm/gems/[email protected]/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:224:in `block in replace_gem' 
/Users/apple/.rvm/gems/[email protected]/gems/activemodel-4.0.0/lib/active_model/secure_password.rb:47:in `has_secure_password' 
/Users/apple/Projects/YH/multi-domains/app/models/super_admin_user.rb:2:in `<class:SuperAdminUser>' 
/Users/apple/Projects/YH/multi-domains/app/models/super_admin_user.rb:1:in `<top (required)>' 
/Users/apple/.rvm/gems/[email protected]/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in `load' 
/Users/apple/.rvm/gems/[email protected]/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in `block in load_file' 
/Users/apple/.rvm/gems/[email protected]/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:615:in `new_constants_in' 
/Users/apple/.rvm/gems/[email protected]/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:422:in `load_file' 
/Users/apple/.rvm/gems/[email protected]/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:323:in `require_or_load' 
/Users/apple/.rvm/gems/[email protected]/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:462:in `load_missing_constant' 
/Users/apple/.rvm/gems/[email protected]/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:183:in `const_missing' 
/Users/apple/Projects/YH/multi-domains/lib/tasks/generate_new_data.rake:3:in `block in <top (required)>' 

Làm thế nào tôi nên sửa lỗi này?

Trả lời

0

Thêm; gem 'bcrypt-ruby', '~> 3.1.1' vào gemfile của bạn

Hoặc nếu bạn đặc biệt muốn 3.0.0, hãy làm theo lời khuyên của Maximus và thêm: gem 'bcrypt-ruby', '3.0.0'

Sau đó, cập nhật gói bcrypt-ruby.

Bạn cũng có thể muốn thử xóa gemfile.lock và chạy lại gói cài đặt.

0

Xóa Gemfile.lock và chỉ định đá quý 'bcrypt-ruby', '3.0.0'. Chạy bundle install. Trên thực tế, trong tập tin đá quý cục bộ bcrypt-ruby nên được gỡ cài đặt.

44

Trong gemfile, bạn không chỉ định phiên bản, vì vậy bạn đang cài đặt phiên bản mới nhất của bcrypt ruby ​​3.1.1, nhưng những gì bạn cần là bất kỳ phiên bản nào từ 3.0.0 đến 3.0.9. Bạn có thể có được điều này bằng cách thêm một phiên bản hạn chế như vậy:

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

Yêu cầu phiên bản xuất phát từ SecurePassword ActiveModel của mà hiện đang có một sự phụ thuộc rõ ràng về bcrypt-ruby (~> 3.0.0). Bạn có thể thấy sự phụ thuộc vào github. Khi mã này được thực hiện, nó sẽ tìm kiếm một phiên bản 3.0.0 đến 3.0.9 mà không được cài đặt và do đó nó ném một lỗi.

Sự phụ thuộc này chỉ được cập nhật thành '~> 3.1.0' cách đây vài ngày, nhưng chưa thực hiện theo cách của mình vào đá quý activemodel. Khi đó, bạn sẽ phải cập nhật phiên bản của bạn cho phù hợp. Đây là commit nếu bạn tò mò.

1

Tôi gặp vấn đề tương tự. Thêm

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

sau đó chạy bundle install và khởi động lại máy chủ. Làm việc cho tôi

0

tôi đã cùng một vấn đề, nhưng cách tiếp cận hiện nay cung cấp gem 'bcrypt-ruby', '~> 3.0.0' đã không làm việc phiên bản vì vậy tôi thực sự cài đặt 3.0.0 thêm dòng gem 'bcrypt-ruby', '3.0.0' để Gemfile và cài đặt phiên bản cụ thể 3.0.0 (mặc dù nó nên làm việc lên đến phiên bản 3.0.9)

gem install --version='3.0.0' bcrypt-ruby

Sau đó, chỉ cần xác minh bó của bạn cài đặt, bạn có thể chạy bundle show bcrypt-ruby và sau đó bạn nên có đường dẫn nơi đá quý này đã được cài đặt, một cái gì đó giống như

% RUBY_PATH%/lib/ruby/gems/2.0.0/gems/bcrypt-ruby-3.0.0

sau các bước tôi đã có thể sử dụng bcrypt mà không vấn đề ... chỉ cần gửi bài này trong trường hợp ai đó vẫn gặp vấn đề này.

3
  1. Cài đặt cả 3.0.1 và 3.1.2 phiên bản bcrypt
  2. đi đến "\ Ruby200 \ lib \ ruby ​​\ đá quý \ 2.0.0 \ đá quý \ bcrypt-ruby-3.1.2-x86-mingw32 \ lib"
  3. copy '2.0' thư mục
  4. dán vào "Ruby200 \ lib \ ruby ​​\ đá quý \ 2.0.0 \ đá quý \ bcrypt-ruby-3.0.1-x86-mingw32 \ lib"
  5. bao gồm đá quý 'bcrypt-ruby' trong Gemfile của bạn
  6. cài đặt bó
+0

nó hoạt động tuyệt vời. Cảm ơn –

0

Sử dụng ActiveModel has_secure_password

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

Đã cùng một vấn đề. Việc xóa nhận xét # từ dòng trên đã giải quyết được vấn đề của tôi, như jconley đã đề cập.

0

Đối với tôi, nó hoạt động bằng cách xóa phụ thuộc cho phiên bản của bản ghi trong /active_model/secure_password.rb cho môi trường thử nghiệm phát triển.

tôi luôn luôn làm cho chắc chắn để thêm nó vào sản xuất chỉ để an toàn

0

100% Trong giao diện điều khiển:

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