【问题标题】:rails test, rails server and others not workingrails 测试,rails 服务器和其他不工作
【发布时间】:2017-12-29 10:33:02
【问题描述】:

我一直在关注 railstutorial.org 学习 Rails,现在,我不知道我的错误来自哪里,但是 rails test 没有测试,rails server 也没有启动

C:\Sites\sample_app>rails test
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcrypt.rb:16:in `require': cannot load such file -- bcrypt_ext (LoadError)
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcrypt.rb:16:in `rescue in <top (required)>'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcrypt.rb:12:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in `require'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `each'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `block in require'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `each'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `require'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler.rb:114:in `require'
        from C:/Sites/sample_app/config/application.rb:7:in `<top (required)>'
        from C:/Sites/sample_app/config/environment.rb:2:in `require_relative'
        from C:/Sites/sample_app/config/environment.rb:2:in `<top (required)>'
        from C:/Sites/sample_app/test/test_helper.rb:1:in `require'
        from C:/Sites/sample_app/test/test_helper.rb:1:in `<top (required)>'
        from C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:1:in `require'
        from C:/Sites/sample_app/test/controllers/static_pages_controller_test.rb:1:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/test_unit/runner.rb:50:in `require'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/test_unit/runner.rb:50:in `block in load_tests'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/test_unit/runner.rb:50:in `each'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/test_unit/runner.rb:50:in `load_tests'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/test_unit/runner.rb:39:in `run'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands/test/test_command.rb:38:in `perform'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

这是rails s的错误代码

C:\Sites\sample_app>rails s
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcrypt.rb:16:in `require': cannot load such file -- bcrypt_ext (LoadError)
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcrypt.rb:16:in `rescue in <top (required)>'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x86-mingw32/lib/bcrypt.rb:12:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in `require'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `each'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:76:in `block in require'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `each'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler/runtime.rb:65:in `require'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.16.1/lib/bundler.rb:114:in `require'
        from C:/Sites/sample_app/config/application.rb:7:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:133:in `require'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:133:in `block in perform'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `tap'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `perform'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
        from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

我不知道它来自哪里

如果您想查看任何页面,请告诉我,我会上传它

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-4


    【解决方案1】:

    首先注释掉# gem bcrypt, '3.1.11'并运行bundle install。然后用gem uninstall bcrypt卸载gem。然后重新安装gem install bcrypt --platform=ruby。重要的部分,取消注释gem 'bcrypt', '~&gt; 3.1.11', platforms: [:ruby, :x64_mingw, :mingw]然后捆绑安装。那就是它。注意最后的mingw部分。这应该是关键。

    source

    【讨论】:

    • 但是没有 gem 'bcrypt' 我能保护密码吗?
    • 停止。您不删除宝石,请仔细阅读答案。您卸载 bcrypt 并为您的 win 平台正确安装。
    • 很好,我的服务器现在启动了,但是 rails 测试告诉我其他事情。
    • C:\Sites\sample_app>rails 测试迁移正在等待。要解决此问题,请运行:bin/rails db:migrate RAILS_ENV=test'
    • 为测试环境运行迁移 bin/rails db:migrate RAILS_ENV=test'
    【解决方案2】:

    a) gem 卸载 bcrypt-ruby

    b) 在您的 gemfile 中,添加

    gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'

    c) 捆绑安装

    这适用于 Windows

    祝你好运

    【讨论】:

      猜你喜欢
      • 2016-07-23
      • 1970-01-01
      • 1970-01-01
      • 2015-03-09
      • 1970-01-01
      • 1970-01-01
      • 2015-09-28
      • 1970-01-01
      • 2015-02-24
      相关资源
      最近更新 更多