Rails 4:后卫不是捆绑的一部分。将其添加到Gemfile。 (宝石:: LoadError)

时间:2015-08-25 23:52:56

标签: ruby-on-rails ruby-on-rails-4 minitest guard gemfile

我正在尝试复制使用Gemfile的Michael Hartl的Rails教程中的Advanced testing setup

这是我的source 'https://rubygems.org' gem 'rails', '4.2.2' 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', '1.3.10' gem 'byebug', '6.0.2' gem 'web-console', '2.2.1' gem 'spring', '1.3.6' end group :test do gem 'minitest-reporters', '1.0.20' gem 'mini_backtrace', '0.1.3' gem 'guard-minitest', '2.4.4' end group :production do gem 'pg', '0.18.2' gem 'rails_12factor', '0.0.3' end

bundle install --without production

以下是我运行Fetching gem metadata from https://rubygems.org/............ Fetching version metadata from https://rubygems.org/... Fetching dependency metadata from https://rubygems.org/.. Resolving dependencies..... Using rake 10.4.2 Using i18n 0.7.0 Using json 1.8.3 Using minitest 5.8.0 Using thread_safe 0.3.5 Using tzinfo 1.2.2 Using activesupport 4.2.2 Using builder 3.2.2 Using erubis 2.7.0 Using mini_portile 0.6.2 Using nokogiri 1.6.6.2 Using rails-deprecated_sanitizer 1.0.3 Using rails-dom-testing 1.0.7 Using loofah 2.0.3 Using rails-html-sanitizer 1.0.2 Using actionview 4.2.2 Using rack 1.6.4 Using rack-test 0.6.3 Using actionpack 4.2.2 Using globalid 0.3.6 Using activejob 4.2.2 Using mime-types 2.6.1 Using mail 2.6.3 Using actionmailer 4.2.2 Using activemodel 4.2.2 Using arel 6.0.3 Using activerecord 4.2.2 Using ansi 1.5.0 Using debug_inspector 0.0.2 Using binding_of_caller 0.7.2 Using bundler 1.10.4 Using byebug 6.0.2 Using coffee-script-source 1.9.1.1 Using execjs 2.6.0 Using coffee-script 2.4.1 Using thor 0.19.1 Using railties 4.2.2 Using coffee-rails 4.1.0 Using guard-compat 1.2.1 Using guard-minitest 2.4.4 Using multi_json 1.11.2 Using jbuilder 2.3.1 Using jquery-rails 4.0.4 Using sprockets 3.3.3 Using sprockets-rails 2.3.2 Using rails 4.2.2 Using mini_backtrace 0.1.3 Using ruby-progressbar 1.7.5 Using minitest-reporters 1.0.20 Using rdoc 4.2.0 Using sass 3.4.18 Using tilt 1.4.1 Using sass-rails 5.0.3 Using sdoc 0.4.1 Using spring 1.3.6 Using sqlite3 1.3.10 Using turbolinks 2.5.3 Using uglifier 2.7.1 Using web-console 2.2.1 Bundle updated! Gems in the group production were not installed. 时的结果:

guard-minitest 2.4.4

所以,似乎我确实安装了bundle exec guard init

但是,当我运行/Users/XXX/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.10.4/lib/bundler/rubygems_integration.rb:292:in `block in replace_gem': guard is not part of the bundle. Add it to Gemfile. (Gem::LoadError) from /Users/XXX/.rvm/gems/ruby-2.2.1/bin/guard:22:in `<main>' from /Users/XXX/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval' from /Users/XXX/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>' 时,我收到以下错误:

var express = require('express');
var app = express();
var PDFDocument = require('pdfkit');
var fs = require('fs');

app.set('port', (process.env.PORT || 5000));

app.use(express.static(__dirname + '/public'));

// views is directory for all template files
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');

app.get('/', function(request, response) {
  response.render('pages/index');
});

app.get('/merge', function(request, response) {
    var doc = new PDFDocument();
    var c1 = fs.readFileSync('./pdfs/1.pdf');
    var c2 = fs.readFileSync('./pdfs/2.pdf');
    doc.addContent(c1);
    doc.addPage();
    doc.addContent(c2);
    doc.end();
    doc.pipe(response);
});

app.listen(app.get('port'), function() {
  console.log('Node app is running on port', app.get('port'));
});

知道我做错了什么?

1 个答案:

答案 0 :(得分:2)

正如guard-minitest README的安装部分所述,对于较新版本的gem,还需要guard

我刚刚更新了我的Gemfile,如下所示:

[...]
group :test do
  gem 'minitest-reporters', '1.0.20'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard'
  gem 'guard-minitest',     '2.4.4'
end
[...]

现在一切正常。