简体   繁体   English

在gemfile中使用bcrypt不允许我重新启动rails服务器并删除它导致浏览器出现问题(要求我将其添加回来)

[英]Having bcrypt in gemfile is not allowing me to restart rails server and removing it is causing issue in browser (asking me to add it back)

I have seen similar query being asked about issues with bcrypt but none of them discuss about this particular issue that I am facing currently. 我看到类似的查询被问及bcrypt的问题,但没有人讨论我目前面临的这个特殊问题。 The solutions are either restarting rails server or installing bcrypt gem both of which are not helping me. 解决方案是重新启动rails服务器或安装bcrypt gem,这两者都没有帮助我。 I am using Windows 7 我使用的是Windows 7

Here are the problems I am facing, 这是我面临的问题,
1. If I have bcrypt 3.1.7 in my Gemfile, I am not able to start the rails server. 1.如果我的Gemfile中有bcrypt 3.1.7,我无法启动rails服务器。 The command 'rails server' gives me below error 命令'rails server'给出了以下错误

C:\row\RailsInstaller\workspace\app2>rails s
C:/row/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bcrypt-3.1.7-x86-mingw3
    2/lib/bcrypt.rb:16:in `require': cannot load such file -- bcrypt_ext (LoadError)
    from C:/row/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bcrypt-3.1
    .7-x86-mingw32/lib/bcrypt.rb:16:in `rescue in <top (required)>'
    from C:/row/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bcrypt-3.1
    .7-x86-mingw32/lib/bcrypt.rb:12:in `<top (required)>'
    from C:/row/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.
    8.3/lib/bundler/runtime.rb:76:in `require'
    from C:/row/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.
    8.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from C:/row/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.

2. If I remove the bcrypt 3.1.7 in my Gemfile, then I am able to start the server but in browser I am seeing this error 2.如果我删除了我的Gemfile中的bcrypt 3.1.7,那么我能够启动服务器但是在浏览器中我看到了这个错误

LoadError in UsersController#show
cannot load such file -- bcrypt

Gemfile 的Gemfile

source 'https://rubygems.org'

gem 'rails', '4.2.0'
gem 'bootstrap-sass',   '3.2.0.0'
gem 'bcrypt',   '3.1.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do
    gem 'sqlite3'
    gem 'byebug'
    gem 'web-console', '~> 2.0'
    gem 'spring',      '1.1.3'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

group :test do
  gem 'minitest-reporters', '1.0.5'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
end

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
end

Gemfile.lock Gemfile.lock的

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.0)
      actionview (= 4.2.0)
      activesupport (= 4.2.0)
      rack (~> 1.6.0)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    actionview (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    activejob (4.2.0)
      activesupport (= 4.2.0)
      globalid (>= 0.3.0)
    activemodel (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
    activerecord (4.2.0)
      activemodel (= 4.2.0)
      activesupport (= 4.2.0)
      arel (~> 6.0)
    activesupport (4.2.0)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    ansi (1.5.0)
    arel (6.0.0)
    bcrypt (3.1.7-x86-mingw32)
    binding_of_caller (0.7.2)
      debug_inspector (>= 0.0.1)
    bootstrap-sass (3.2.0.0)
      sass (~> 3.2)
    builder (3.2.2)
    byebug (3.5.1)
      columnize (~> 0.8)
      debugger-linecache (~> 1.2)
      slop (~> 3.6)
    celluloid (0.16.0)
      timers (~> 4.0.0)
    coderay (1.1.0)
    coffee-rails (4.1.0)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.3.0)
      coffee-script-source
      execjs
    coffee-script-source (1.9.1)
    columnize (0.9.0)
    debug_inspector (0.0.2)
    debugger-linecache (1.2.0)
    erubis (2.7.0)
    execjs (2.3.0)
    ffi (1.9.6-x86-mingw32)
    formatador (0.2.5)
    globalid (0.3.3)
      activesupport (>= 4.1.0)
    guard (2.12.4)
      formatador (>= 0.2.4)
      listen (~> 2.7)
      lumberjack (~> 1.0)
      nenv (~> 0.1)
      notiffany (~> 0.0)
      pry (>= 0.9.12)
      shellany (~> 0.0)
      thor (>= 0.18.1)
    guard-minitest (2.3.1)
      guard (~> 2.0)
      minitest (>= 3.0)
    hike (1.2.3)
    hitimes (1.2.2-x86-mingw32)
    i18n (0.7.0)
    jbuilder (2.2.8)
      activesupport (>= 3.0.0, < 5)
      multi_json (~> 1.2)
    jquery-rails (4.0.3)
      rails-dom-testing (~> 1.0)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    json (1.8.2)
    listen (2.8.5)
      celluloid (>= 0.15.2)
      rb-fsevent (>= 0.9.3)
      rb-inotify (>= 0.9)
    loofah (2.0.1)
      nokogiri (>= 1.5.9)
    lumberjack (1.0.9)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    method_source (0.8.2)
    mime-types (2.4.3)
    mini_backtrace (0.1.3)
      minitest (> 1.2.0)
      rails (>= 2.3.3)
    mini_portile (0.6.2)
    minitest (5.5.1)
    minitest-reporters (1.0.5)
      ansi
      builder
      minitest (>= 5.0)
      ruby-progressbar
    multi_json (1.10.1)
    nenv (0.2.0)
    nokogiri (1.6.6.2-x86-mingw32)
      mini_portile (~> 0.6.0)
    notiffany (0.0.6)
      nenv (~> 0.1)
      shellany (~> 0.0)
    pg (0.17.1-x86-mingw32)
    pry (0.10.1-x86-mingw32)
      coderay (~> 1.1.0)
      method_source (~> 0.8.1)
      slop (~> 3.4)
      win32console (~> 1.3)
    rack (1.6.0)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.2.0)
      actionmailer (= 4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      activemodel (= 4.2.0)
      activerecord (= 4.2.0)
      activesupport (= 4.2.0)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.0)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.5)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.1)
      loofah (~> 2.0)
    rails_12factor (0.0.2)
      rails_serve_static_assets
      rails_stdout_logging
    rails_serve_static_assets (0.0.4)
    rails_stdout_logging (0.0.3)
    railties (4.2.0)
      actionpack (= 4.2.0)
      activesupport (= 4.2.0)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.4.2)
    rb-fsevent (0.9.4)
    rb-inotify (0.9.5)
      ffi (>= 0.5.0)
    rdoc (4.2.0)
      json (~> 1.4)
    ruby-progressbar (1.7.1)
    sass (3.4.13)
    sass-rails (5.0.1)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (~> 1.1)
    sdoc (0.4.1)
      json (~> 1.7, >= 1.7.7)
      rdoc (~> 4.0)
    shellany (0.0.1)
    slop (3.6.0)
    spring (1.1.3)
    sprockets (2.12.3)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.2.4)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (>= 2.8, < 4.0)
    sqlite3 (1.3.10-x86-mingw32)
    thor (0.19.1)
    thread_safe (0.3.4)
    tilt (1.4.1)
    timers (4.0.1)
      hitimes
    turbolinks (2.5.3)
      coffee-rails
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    tzinfo-data (1.2015.1)
      tzinfo (>= 1.0.0)
    uglifier (2.7.1)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    web-console (2.0.0)
      activemodel (~> 4.0)
      binding_of_caller (>= 0.7.2)
      railties (~> 4.0)
      sprockets-rails (>= 2.0, < 4.0)
    win32console (1.3.2-x86-mingw32)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  bcrypt (= 3.1.7)
  bootstrap-sass (= 3.2.0.0)
  byebug
  coffee-rails (~> 4.1.0)
  guard-minitest (= 2.3.1)
  jbuilder (~> 2.0)
  jquery-rails
  mini_backtrace (= 0.1.3)
  minitest-reporters (= 1.0.5)
  pg (= 0.17.1)
  rails (= 4.2.0)
  rails_12factor (= 0.0.2)
  sass-rails (~> 5.0)
  sdoc (~> 0.4.0)
  spring (= 1.1.3)
  sqlite3
  turbolinks
  tzinfo-data
  uglifier (>= 1.3.0)
  web-console (~> 2.0)

I am not sure what to do now. 我不知道现在该怎么办。 Can someone help? 有人可以帮忙吗?

Step 1. Update your system's bcrypt to be current; 步骤1.将系统的bcrypt更新为最新; this is independent of Rails. 这与Rails无关。

$ gem install bcrypt -v '3.1.10'

Step 2. Verify bcrypt works by using IRB; 步骤2.使用IRB验证bcrypt的工作原理; this is independent of Rails. 这与Rails无关。

$ irb
> gem 'bcrypt', '3.1.10'
=> true

Step 3. If Step 1 and 2 succeed, then update your Rails Gemfile: 步骤3.如果步骤1和2成功,则更新您的Rails Gemfile:

gem bcrypt, '3.1.10'

Step 4. Bundle your gems so your Rails app gets its own copies of gems: 步骤4.捆绑您的宝石,以便您的Rails应用程序获得自己的宝石副本:

$ bundle install 

Step 5. Start your server by using bundle: 步骤5.使用bundle启动服务器:

$ bundle exec rails server

Do these steps succeed for you? 这些步骤能为您成功吗? If so, great. 如果是这样,很好。

If not, then can you please edit your question to show exactly which step didn't work, and copy/paste the exact error message? 如果没有,那么您可以编辑您的问题以准确显示哪个步骤不起作用,并复制/粘贴确切的错误消息?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM