web-dev-qa-db-ja.com

bcrypt-Ruby(〜> 3.0.0)をアクティブ化できません。すでにbcrypt-Ruby-3.1.1がアクティブ化されています。すべての依存関係がGemfileに追加されていることを確認してください

Rails 4.0.0アプリです。bundleinstallコマンドを実行しても問題はありません。これが私の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

そしてこれは私の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)

実行するとrake sometask、私はこの問題に直面しました、

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/Ruby-2.0.0-p0@Rails4/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:224:in `block in replace_gem'
/Users/Apple/.rvm/gems/Ruby-2.0.0-p0@Rails4/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/Ruby-2.0.0-p0@Rails4/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in `load'
/Users/Apple/.rvm/gems/Ruby-2.0.0-p0@Rails4/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in `block in load_file'
/Users/Apple/.rvm/gems/Ruby-2.0.0-p0@Rails4/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:615:in `new_constants_in'
/Users/Apple/.rvm/gems/Ruby-2.0.0-p0@Rails4/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:422:in `load_file'
/Users/Apple/.rvm/gems/Ruby-2.0.0-p0@Rails4/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:323:in `require_or_load'
/Users/Apple/.rvm/gems/Ruby-2.0.0-p0@Rails4/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:462:in `load_missing_constant'
/Users/Apple/.rvm/gems/Ruby-2.0.0-p0@Rails4/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)>'

これをどのように修正すればよいですか?

17
ndrx42

Gemfileではバージョンを指定していないため、最新バージョンのbcrypt-Ruby(3.1.1)をインストールしますが、必要なのは3.0.0から3.0.9までの任意のバージョンです。これは、次のようなバージョン制約を追加することで取得できます。

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

バージョン要件は、現在bcrypt-Ruby(〜> 3.0.0)に明示的に依存しているActiveModelのSecurePasswordから取得されます。 github への依存関係を確認できます。このコードを実行すると、インストールされていないバージョン3.0.0から3.0.9が検索されるため、エラーがスローされます。

この依存関係は数日前に「〜> 3.1.0」に更新されましたが、まだRails activemodel gemに組み込まれていません。更新された場合は、次のようにする必要があります。それに応じてバージョンを更新してください。興味がある場合は、 commit を参照してください。

44
jconley
  1. 3.0.1と3.1.2の両方のbcryptバージョンをインストールします
  2. 「\ Ruby200\lib\Ruby\gems\2.0.0\gems\bcrypt-Ruby-3.1.2-x86-mingw32\lib」に移動します
  3. 「2.0」フォルダをコピーします
  4. 「Ruby200\lib\Ruby\gems\2.0.0\gems\bcrypt-Ruby-3.0.1-x86-mingw32\lib」に貼り付けます
  5. gemfileにgem'bcrypt-Ruby 'を含めます
  6. バンドルインストール
3
Marcos F

私も同じ問題を抱えていました。追加

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

次に、bundle installを実行し、サーバーを再起動します。私のために働いた

1
Connor Leech

同じ問題が発生しましたが、現在のアプローチではgem 'bcrypt-Ruby', '~> 3.0.0'が機能しなかったため、実際にバージョン3.0.0をインストールし、Gemfileに行gem 'bcrypt-Ruby', '3.0.0'を追加して、特定のバージョン3.0.0をインストールしました(ただし、機能するはずです)。バージョン3.0.9まで)

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

この後、バンドルのインストールを確認するだけで、bundle show bcrypt-Rubyを実行できます。そうすると、このgemがインストールされたパスが次のようになります。

%Ruby_PATH%/ lib/Ruby/gems/2.0.0/gems/bcrypt-Ruby-3.0.0

これらの手順の後、私は問題なくbcryptを使用することができました...誰かがまだこの問題に遭遇した場合に備えてこれを投稿するだけです。

0
Wiston Coronell

ActiveModelhas_secure_passwordを使用する

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

同じ問題がありました。 jconleyが述べたように、上記の行からコメント#を削除すると、私の問題は解決しました。

0
vsr

私にとっては、開発テスト環境の/active_model/secure_password.rbにあるbycriptのバージョンの依存関係を削除するだけで機能しました。

私は常に100%安全になるように本番環境に追加するようにしました

0
Adrian Badarau

コンソールの場合:

$ gem install bundler
$ gem install bcrypt
$ bundle update bcrypt
0
discipleartem

Gemfile.lockを削除し、gem'bcrypt-Ruby '、' 3.0.0 'を指定します。実行bundle install。実際、ローカルのgemファイルではbcrypt-Rubyをアンインストールする必要があります。

0
ndrx42