【问题标题】:There was an error while trying to load the gem 'sass-rails'. (Bundler::GemRequireError)尝试加载 gem 'sass-rails' 时出错。 (Bundler::GemRequireError)
【发布时间】:2016-08-26 01:46:33
【问题描述】:

我在启动 Rails 服务器时遇到错误。

C:\Ruby22-x64\WebAppRails>rails s C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'sass-rails'. (Bundler::GemRequireError)
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
        from C:/Ruby22-x64/WebAppRails/config/application.rb:7:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:78:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:78:in `block in server'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `tap'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `server'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

这是我正在使用的宝石:

C:\Ruby22-x64\WebAppRails>bundle show

捆绑包中包含的宝石:

  • actionmailer (4.2.6)
  • 动作包 (4.2.6)
  • 动作视图 (4.2.6)
  • activejob (4.2.6)
  • 活动模型 (4.2.6)
  • 活动记录 (4.2.6)
  • 主动支持 (4.2.6)
  • 是 (6.0.3)
  • binding_of_caller (0.7.2)
  • 构建器 (3.2.2)
  • 捆绑器 (1.11.2)
  • 再见 (8.2.5)
  • 咖啡轨 (4.1.1)
  • 咖啡脚本 (2.4.1)
  • 咖啡脚本源 (1.10.0)
  • 并发红宝石 (1.0.1)
  • debug_inspector (0.0.2)
  • erubis (2.7.0)
  • execjs (2.6.0)
  • globalid (0.3.6)
  • i18n (0.7.0)
  • jbuilder (2.4.1)
  • jquery-rails (4.1.1)
  • json (1.8.3)
  • 丝瓜络 (2.0.3)
  • 邮件 (2.6.4)
  • mime 类型 (3.0)
  • mime 类型数据 (3.2016.0221)
  • mini_portile2 (2.0.0)
  • minitest (5.8.4)
  • multi_json (1.11.3)
  • nokogiri (1.6.7.2)
  • 机架 (1.6.4)
  • 机架测试 (0.6.3)
  • 导轨 (4.2.6)
  • rails-deprecated_sanitizer (1.0.3)
  • rails-dom-testing (1.0.7)
  • rails-html-sanitizer (1.0.3)
  • 铁路 (4.2.6)
  • 耙子 (11.1.2)
  • rdoc (4.2.2)
  • 萨斯 (3.4.22)
  • sass-rails (5.0.4)
  • sdoc (0.4.1)
  • 链轮 (3.6.0)
  • 链轮导轨 (3.0.4)
  • sqlite3 (1.3.11)
  • 雷神 (0.19.1)
  • thread_safe (0.3.5)
  • 倾斜 (2.0.2)
  • turbolinks (2.5.3)
  • tzinfo (1.2.2)
  • tzinfo-data (1.2016.4)
  • 丑化剂 (3.0.0)
  • 网络控制台 (2.3.0)

gem 版本是 2.4.5.1,ruby 版本是 2.2.4

我需要做什么来解决这个问题?

【问题讨论】:

  • 你能出示你的WebAppRails/config/application.rb文件吗?
  • require File.expand_path('../boot', FILE) require 'rails/all' Bundler.require(*Rails.groups) 模块 Railapp 类 Application
  • 你能显示你的 gemfile 吗?

标签: ruby-on-rails


【解决方案1】:

将以下内容添加到您的 Gemfile:

gem 'sass-rails', '>= 5.0.3'

然后做

bundle update sass-rails

【讨论】:

    【解决方案2】:

    当我为新克隆的 Rails 应用程序安装了正确版本的 Ruby 后,我的问题得到了解决 - 我安装了 2.4.1,但我的应用程序需要 2.3。

    【讨论】:

      猜你喜欢
      • 2016-03-28
      • 2016-05-31
      • 1970-01-01
      • 1970-01-01
      • 2017-05-18
      • 1970-01-01
      • 2016-06-13
      • 1970-01-01
      相关资源
      最近更新 更多