无法使用Rru上的Grunt任务部署到Heroku

时间:2014-04-27 01:52:42

标签: ruby-on-rails heroku

我在我的应用程序中安装了一个名为half-pipe的东西。我似乎无法让它正常工作。当我将它部署到Heroku时,我收到一个错误。

$ gph heroku master
Fetching repository, done.
Counting objects: 87, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (55/55), done.
Writing objects: 100% (68/68), 16.74 KiB | 0 bytes/s, done.
Total 68 (delta 24), reused 0 (delta 0)

-----> Removing .DS_Store files
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.1.1
-----> Installing dependencies using 1.5.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Fetching gem metadata from https://rubygems.org/.........
       Fetching additional metadata from https://rubygems.org/..
       Fetching git://github.com/d-i/half-pipe.git
       Fetching git://github.com/joefiorini/sass-css-importer.git
       Using minitest (5.3.3)
       Using i18n (0.6.9)
       Using json (1.8.1)
       Using rake (10.3.1)
       Using thread_safe (0.3.3)
       Using builder (3.2.2)
       Using erubis (2.7.0)
       Using rack (1.5.2)
       Using mime-types (1.25.1)
       Using polyglot (0.3.4)
       Using arel (5.0.1.20140414130214)
       Using browser (0.4.1)
       Using addressable (2.3.6)
       Using geocoder (1.2.0)
       Using referer-parser (0.2.1)
       Using request_store (1.0.5)
       Using bcrypt (3.1.7)
       Using coffee-script-source (1.7.0)
       Using execjs (2.0.2)
       Using thor (0.19.1)
       Using daemons (1.1.9)
       Using orm_adapter (0.5.0)
       Using eventmachine (1.0.3)
       Using hike (1.2.3)
       Using bundler (1.5.2)
       Using multi_json (1.9.2)
       Using gravtastic (3.2.6)
       Using tilt (1.4.1)
       Using sass (3.2.19)
       Using mysql2 (0.3.15)
       Using rails_serve_static_assets (0.0.2)
       Using rails_stdout_logging (0.0.3)
       Using tzinfo (1.1.0)
       Using treetop (1.4.15)
       Using rdoc (4.1.1)
       Using rack-test (0.6.2)
       Using warden (1.2.3)
       Using uglifier (2.5.0)
       Using ahoy_matey (0.1.2)
       Using coffee-script (2.2.0)
       Using sprockets (2.11.0)
       Using thin (1.6.2)
       Using activesupport (4.1.0)
       Using rails_12factor (0.0.2)
       Using mail (2.5.4)
       Using sdoc (0.4.0)
       Using actionview (4.1.0)
       Using activemodel (4.1.0)
       Using intercom-rails (0.2.24)
       Using jbuilder (2.0.6)
       Using actionpack (4.1.0)
       Using activerecord (4.1.0)
       Using rails-observers (0.1.2)
       Using actionmailer (4.1.0)
       Using railties (4.1.0)
       Using sprockets-rails (2.1.3)
       Using activeresource (4.0.0)
       Using coffee-rails (4.0.1)
       Using devise (3.2.4)
       Using rails (4.1.0)
       Using jquery-rails (3.1.0)
       Using sass-rails (4.0.3)
       Using turbolinks (2.2.2)
       Using wistia-api (0.2.3)
       Using sass-css-importer (1.0.0.beta.0) from git://github.com/joefiorini/sass-css-importer.git (at load-paths)
       Using half-pipe (0.3.0.beta.2) from git://github.com/d-i/half-pipe.git (at master)
       Your bundle is complete!
       Gems in the groups development and test were not installed.
       It was installed into ./vendor/bundle
       Bundle completed (9.12s)
       Cleaning up the bundler cache.
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       executing: "/tmp/build_14997ed5-86be-4fb4-bc2a-ec8003a546db/node_modules/.bin/grunt build:public"
       rake aborted!
       Errno::ENOENT: No such file or directory - /tmp/build_14997ed5-86be-4fb4-bc2a-ec8003a546db/node_modules/.bin/grunt
       /tmp/build_14997ed5-86be-4fb4-bc2a-ec8003a546db/vendor/bundle/ruby/2.1.0/bundler/gems/half-pipe-8f75b3dcedd0/lib/tasks/assets.rake:16:in `exec'
       /tmp/build_14997ed5-86be-4fb4-bc2a-ec8003a546db/vendor/bundle/ruby/2.1.0/bundler/gems/half-pipe-8f75b3dcedd0/lib/tasks/assets.rake:16:in `block (2 levels) in <top (required)>'
       /tmp/build_14997ed5-86be-4fb4-bc2a-ec8003a546db/vendor/bundle/ruby/2.1.0/bundler/gems/half-pipe-8f75b3dcedd0/lib/tasks/assets.rake:37:in `block (3 levels) in <top (required)>'
       Tasks: TOP => half_pipe:execute_grunt_command
       (See full trace by running task with --trace)
 !
 !     Precompiling assets failed.
 !

 !     Push rejected, failed to compile Ruby app

在我的应用中,node_modules/bin/grunt文件如下:

#!/usr/bin/env node

'use strict';

process.title = 'grunt';
n.
// Especially badass external libs.
var findup = require('findup-sync');
var resolve = require('resolve').sync;

// Internal libs.
var options = require('../lib/cli').options;
var completion = require('../lib/completion');
var info = require('../lib/info');
var path = require('path');


var basedir = process.cwd();
var gruntpath;

// Do stuff based on CLI options.
if ('completion' in options) {
  completion.print(options.completion);
} else if (options.version) {
  info.version();
} else if (options.base && !options.gruntfile) {
  basedir = path.resolve(options.base);
} else if (options.gruntfile) {
  basedir = path.resolve(path.dirname(options.gruntfile));
}

try {
  gruntpath = resolve('grunt', {basedir: basedir});
} catch (ex) {
  gruntpath = findup('lib/grunt.js');
  // No grunt install found!
  if (!gruntpath) {
    if (options.version) { process.exit(); }
    if (options.help) { info.help(); }
    info.fatal('Unable to find local grunt.', 99);
  }
}

// Everything looks good. Require local grunt and run it.
require(gruntpath).cli();

我不确定半管正在做什么。我也对错误的含义感到困惑。如果有人能给我一些关于帮助解决问题的代码的指示,请告诉我。

1 个答案:

答案 0 :(得分:0)

刚才遇到同样的问题。

对我们有用的解决方案是简单地从Gemfile中删除半管道。 基本上半管所做的所有有用的东西都在发电机中。 一旦你完成了发电机并配置了你的Grunt等,你就不再需要半管了。

所以步骤是:

  1. 从Gemfile中删除半管
  2. 捆绑更新
  3. 通过在config / application.rb中添加以下行来禁用资产编译:{{1​​}}
  4. 通过config.assets.enabled = falsegrunt server然后grunt build:public
  5. 测试一切仍然正常
  6. 确保rails s创建的文件已添加到回购站:grunt build:public
  7. 最后正常推送到Heroku
  8. 希望这也适用于其他人。