Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmberCLI failed to generate an index.html file. #380

Closed
movstox opened this issue Jan 11, 2016 · 38 comments
Closed

EmberCLI failed to generate an index.html file. #380

movstox opened this issue Jan 11, 2016 · 38 comments

Comments

@movstox
Copy link

movstox commented Jan 11, 2016

hi all, is there a way i can debug this? Getting error on Heroku, locally the app is running just fine (DigitalOcean).

Many thanks.

EmberCli::BuildError in Account#index
Showing /app/vendor/bundle/ruby/2.3.0/gems/ember-cli-rails-0.7.0/app/views/ember_cli/ember/index.html.erb where line #1 raised:

          EmberCLI failed to generate an `index.html` file.
Extracted source (around line #25):


25:        app.check_for_errors!

        raise BuildError.new <<-MSG
          EmberCLI failed to generate an `index.html` file.
        MSG
      end

Rails.root: /app

Trace:

vendor/bundle/ruby/2.3.0/gems/ember-cli-rails-0.7.0/lib/ember_cli/deploy/file.rb:25:in `check_for_error_and_raise!'
vendor/bundle/ruby/2.3.0/gems/ember-cli-rails-0.7.0/lib/ember_cli/deploy/file.rb:14:in `index_html'
vendor/bundle/ruby/2.3.0/gems/ember-cli-rails-0.7.0/lib/ember_cli/app.rb:61:in `index_html'
vendor/bundle/ruby/2.3.0/gems/ember-cli-rails-0.7.0/app/helpers/ember_rails_helper.rb:11:in `render_ember_app'
vendor/bundle/ruby/2.3.0/gems/ember-cli-rails-0.7.0/app/views/ember_cli/ember/index.html.erb:1:in `_vendor_bundle_ruby_______gems_ember_cli_rails_______app_views_ember_cli_ember_index_html_erb__3698659512889612043_70218682884580'
vendor/bundle/ruby/2.3.0/gems/actionview-4.2.0/lib/action_view/template.rb:145:in `block in render'
vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.0/lib/active_support/notifications.rb:166:in `instrument'
vendor/bundle/ruby/2.3.0/gems/actionview-4.2.0/lib/action_view/template.rb:333:in `instrument'
vendor/bundle/ruby/2.3.0/gems/actionview-4.2.0/lib/action_view/template.rb:143:in `render'
@seanpdoyle
Copy link
Contributor

@movstox thanks for opening this issue and bringing it to our attention.

Have you followed along with the Setup Instructions, particularly:

$ cd path/to/frontend
$ ember install ember-cli-rails-addon

If so, what version of the addon are you running?

Have you followed all the steps in the Heroku section?

@movstox
Copy link
Author

movstox commented Jan 11, 2016

@seanpdoyle I'm running "ember-cli-rails-addon": "0.7.0" as well.

I've upgraded from 0.5.8 and when I start rails s on my Digital Ocean dev server it works.

When I deploy to Heroku - it doesn't, is there a way to find out why index.html is not found? i.e. logs...

Here is more info:

rails config

EmberCLI.configure do |c|
  c.app :account, path: Rails.root.join('account').to_s
  c.app :admin, path: Rails.root.join('admin').to_s
end

routes.rb

mount_ember_app :account, to: '/account', controller: 'account', action: 'index', as: :account
mount_ember_app :admin, to: '/admin', controller: 'admin', action: 'index', as: :admin

custom controller

class AccountController < EmberCli::EmberController
  before_filter :authenticate_user!
end

ember-cli-build

/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  var app = new EmberApp(defaults, {
    fingerprint: {
      prepend: '/account/'
    },
    sassOptions: {
        includePaths: ['bower_components/materialize/sass']
    }
    // Add options here
  });

  // Use `app.import` to add additional libraries to the generated
  // output files.
  //
  // If you need to use different assets in different
  // environments, specify an object as the first parameter. That
  // object's keys should be the environment name and the values
  // should be the asset to use in that environment.
  //
  // If the library that you are including contains AMD or ES6
  // modules that you would like to import into your application
  // please specify an object with the list of modules as keys
  // along with the exports of each module as its value.
  return app.toTree();
};

environment.js

/* jshint node: true */
module.exports = function(environment) {
    var ENV = {
        modulePrefix: 'account',
        environment: environment,
        baseURL: '/account/',
        locationType: 'auto',
        EmberENV: {
            FEATURES: {
                // Here you can enable experimental features on an ember canary build
                // e.g. 'with-controller': true
            }
        },

        APP: {
            // Here you can pass flags/options to your application instance
            // when it is created
        },
    };
....

@movstox
Copy link
Author

movstox commented Jan 11, 2016

Also, I had to modify bin/heroku_install (added cd ..):

#!/usr/bin/env sh

set -e

bower="$(pwd)/node_modules/.bin/bower"

for app in "account" "admin"; do
  cd $app &&
    npm install &&
    $bower install
  cd .. # added this line
done

@seanpdoyle
Copy link
Contributor

What is the output of $ heroku buildpacks?

ember-cli-rails depends on the presence of the assets:precompile task. Does your application have that rake task available (try rake -T | grep assets)?

Also, for what it's worth, your changes to bin/heroku_install should be covered in the future by #379

@seanpdoyle
Copy link
Contributor

The error message you're seeing is somewhat vague because, in theory, it should never be reached. That is to say, if your project is properly configured and there are issues with compiling your Ember application, they would be raised elsewhere (for instance, in the call to App#compile that will raise build errors).

This leads me to believe that your application is never invoking the ember:compile task.

@movstox
Copy link
Author

movstox commented Jan 11, 2016

Does this help?

$ heroku buildpacks
1. https://github.com/heroku/heroku-buildpack-nodejs  
2. https://github.com/heroku/heroku-buildpack-ruby  
$ rake -T | grep assets
rake assets:clean[keep]                       # Remove old compiled assets  
rake assets:clobber                           # Remove compiled assets  
rake assets:environment                       # Load asset compile environment  
rake assets:precompile                        # Compile all the assets named in config.assets.precompile

@seanpdoyle
Copy link
Contributor

@movstox yup, looks like you're properly configured there.

What about the output of

$ heroku config | grep SKIP_EMBER 

And what environment are you running in?

$ heroku config | grep ENV

@movstox
Copy link
Author

movstox commented Jan 11, 2016

@seanpdoyle it's empty!

@seanpdoyle
Copy link
Contributor

@movstox

it's empty!

The output of $ heroku config | grep SKIP_EMBER being empty is a good thing.

What environment are you running in?

$ heroku config | grep ENV

@movstox
Copy link
Author

movstox commented Jan 11, 2016

RACK_ENV:                 production
RAILS_ENV:                production

@seanpdoyle
Copy link
Contributor

Hmm, this is a real head scratcher.

Would you mind trying to compare your application to https://github.com/seanpdoyle/ember-cli-rails-heroku-example, being on the lookout for configuration differences?

That repo demonstrates how to serve an application from multiple routes (similar to yours but there's only a single Ember codebase -- shouldn't really affect the configuration though)

@movstox
Copy link
Author

movstox commented Jan 11, 2016

Ok, this would take me some time.

@movstox
Copy link
Author

movstox commented Jan 11, 2016

Also, does it make sense to run heroku run rake ember:compile and see the output?

@seanpdoyle
Copy link
Contributor

Also, does it make sense to run heroku run rake ember:compile and see the output?

That's a great idea!

@movstox
Copy link
Author

movstox commented Jan 12, 2016

@seanpdoyle Finnally, changed the deployment strategy to the one based on Redis(index.html) / S3(assets). I suppose in this case I don't need heroku-buildpack-nodejs on Heroku at all...

@seanpdoyle
Copy link
Contributor

@movstox have you been using the Redis deployment strategy from the start?

@movstox
Copy link
Author

movstox commented Jan 12, 2016

@seanpdoyle no, but I was not able to find the explanation for my issue. Perhaps, it's about Heroku, since my app worked on DigitalOcean and locally. S3/Redis was already available so I've just opted for that.

@seanpdoyle
Copy link
Contributor

changed the deployment strategy to the one based on Redis

@movstox are you using https://github.com/seanpdoyle/ember-cli-rails-deploy-redis?

@movstox
Copy link
Author

movstox commented Jan 12, 2016

@seanpdoyle yes. The only thing I would like it to be able to do is allowing to setup the namespace via env var (i.e. 'appname:index'). Otherwise, looks like it works pretty well.

@seanpdoyle
Copy link
Contributor

@movstox that's great!

The only thing I would like it to be able to do is allowing to setup the namespace via env var (i.e. 'appname:index').

I agree, that would be a great feature.

PRs are welcome!

I'm also currently working on a project that uses that strategy so be on the lookout for coming improvements.

Closing this issue for now.

@movstox
Copy link
Author

movstox commented Jan 12, 2016

@seanpdoyle thanks for your input and good luck.

@maebeale
Copy link

hey there! i'm getting this same error, and heroku run rake ember:compile isn't fixing it.
unfortunately i need to be able to ship this asap. any advice?

heroku config | grep SKIP_EMBER --> is empty

heroku buildpacks:

  1. heroku/nodejs
  2. heroku/ruby

@maebeale
Copy link

update: i was precompiling my assets and apparently should've been letting heroku do that. thanks @drapergeek !!!

@ryanlntn
Copy link

ryanlntn commented Mar 2, 2016

I'm seeing this same issue after upgrading from 0.5.7 to 0.7.2. heroku run rake ember:compile doesn't give any output. I have the following setup:

ember.rb

EmberCli.configure do |config|
  config.app :frontend
end

routes.rb

mount_ember_assets :frontend, to: '/'
mount_ember_app :frontend, to: '/*path'

app/views/ember_cli/ember/index.html.slim

= render_ember_app :frontend do |head|
  - head.append do
    = stylesheet_link_tag :application, media: :all
    = render 'layouts/timezone_restriction'
    = favicon_link_tag '/favicon.ico?v=2'

ember-cli-build.js

/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
  var app = new EmberApp(defaults, {});

  app.import('./bower_components/jQuery.dotdotdot/src/js/jquery.dotdotdot.min.js');
  app.import('./bower_components/moment/moment.js');
  app.import('./bower_components/mediaelement/build/mediaelement-and-player.min.js');
  app.import('./bower_components/typeahead.js/dist/typeahead.jquery.min.js');
  app.import('./bower_components/jquery-ui-sortable/jquery-ui-sortable.min.js');
  app.import('./bower_components/jquery-ui-touch-punch-improved/jquery.ui.touch-punch-improved.js');

  return app.toTree();
};

environment.js

/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'frontend',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    'ember-simple-auth': {
      routeAfterAuthentication: 'asanas'
    },
    EmberENV: {
      FEATURES: {}
    },
    APP: {}
  };

  if (environment === 'development') {
    ENV.APP.LOG_RESOLVER = true;
    ENV.APP.LOG_ACTIVE_GENERATION = true;
    ENV.APP.LOG_TRANSITIONS = true;
    ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    ENV.APP.LOG_VIEW_LOOKUPS = true;
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {}

  return ENV;
};

heroku

$ heroku buildpacks
1. https://github.com/heroku/heroku-buildpack-nodejs
2. https://github.com/heroku/heroku-buildpack-ruby

$ heroku config | grep ENV
RACK_ENV:                     production
RAILS_ENV:                    production

$ heroku config | grep EMBER

Everything builds fine locally. The issue is only present on Heroku. Is it possible some previous config from 0.5.x is short circuiting everything?

@movstox
Copy link
Author

movstox commented Mar 2, 2016

I used redis based setup finally.

On 02.03.2016 at 18:33 GMT Ryan Linton wrote:

I'm seeing this same issue after upgrading from 0.5.7 to 0.7.2. heroku run rake ember:compile doesn't give any output. I have the following setup:

ember.rb
EmberCli.configure do |config| config.app :frontend end
routes.rb
mount_ember_assets :frontend, to: '/' mount_ember_app :frontend, to: '/path'
app/views/ember_cli/ember/index.html.slim
= render_ember_app :frontend do |head| - head.append do = stylesheet_link_tag :application, media: :all = render 'layouts/timezone_restriction' = favicon_link_tag '/favicon.ico?v=2'
ember-cli-build.js
/
global require, module / var EmberApp = require('ember-cli/lib/broccoli/ember-app'); module.exports = function(defaults) { var app = new EmberApp(defaults, {}); app.import('./bower_components/jQuery.dotdotdot/src/js/jquery.dotdotdot.min.js'); app.import('./bower_components/moment/moment.js'); app.import('./bower_components/mediaelement/build/mediaelement-and-player.min.js'); app.import('./bower_components/typeahead.js/dist/typeahead.jquery.min.js'); app.import('./bower_components/jquery-ui-sortable/jquery-ui-sortable.min.js'); app.import('./bower_components/jquery-ui-touch-punch-improved/jquery.ui.touch-punch-improved.js'); return app.toTree(); };
environment.js
/
jshint node: true */ module.exports = function(environment) { var ENV = { modulePrefix: 'frontend', environment: environment, baseURL: '/', locationType: 'auto', 'ember-simple-auth': { routeAfterAuthentication: 'asanas' }, EmberENV: { FEATURES: {} }, APP: {} }; if (environment === 'development') { ENV.APP.LOG_RESOLVER = true; ENV.APP.LOG_ACTIVE_GENERATION = true; ENV.APP.LOG_TRANSITIONS = true; ENV.APP.LOG_TRANSITIONS_INTERNAL = true; ENV.APP.LOG_VIEW_LOOKUPS = true; } if (environment === 'test') { // Testem prefers this... ENV.baseURL = '/'; ENV.locationType = 'none'; // keep test console output quieter ENV.APP.LOG_ACTIVE_GENERATION = false; ENV.APP.LOG_VIEW_LOOKUPS = false; ENV.APP.rootElement = '#ember-testing'; } if (environment === 'production') {} return ENV; };
heroku
$ heroku buildpacks 1. https://github.com/heroku/heroku-buildpack-nodejs 2. https://github.com/heroku/heroku-buildpack-ruby $ heroku config | grep ENV RACK_ENV: production RAILS_ENV: production $ heroku config | grep EMBER

Everything builds fine locally. The issue is only present on Heroku. Is it possible some previous config from 0.5.x is short circuiting everything?


Reply to this email directly or #380 (comment)<>.

@seanpdoyle
Copy link
Contributor

@ryanlntn thanks for providing all that extra context.

mount_ember_app :frontend, to: '/*path'

The dynamic segment glob can be omitted:

mount_ember_app :frontend, to: '/'

heroku run rake ember:compile doesn't give any output

The current implementation of the Rake task will only output on errors.

Additionally, given the way dynos work, I don't think compiling the frontend after the fact will persist the EmberCLI generated files to the file system.

Does your deploy invoke rake assets:precompile? The gem creates a dependency on that task.

@ryanlntn
Copy link

ryanlntn commented Mar 2, 2016

@seanpdoyle It is being invoked:

remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        ** [Honeybadger] Starting Honeybadger version 2.5.1 level=1 pid=619
remote:        Asset precompilation completed (15.93s)
remote:        Cleaning assets
remote:        Running: rake assets:clean

@seanpdoyle
Copy link
Contributor

@ryanlntn what are your package.json versions for:

  • ember-cli
  • ember-cli-rails-addon

@ryanlntn
Copy link

ryanlntn commented Mar 2, 2016

@seanpdoyle

"ember-cli": "1.13.13",
"ember-cli-rails-addon": "~> 0.7.0"

@seanpdoyle
Copy link
Contributor

@ryanlntn just to clarify -- you've followed all the steps for setting up Heroku, including running the generators and executing:

$ heroku config:set NPM_CONFIG_PRODUCTION=false

and you're still seeing the following?

EmberCLI failed to generate an index.html file.

@tute since we've just recently worked through a similar issue, do you have any guess as to what's causing this?

@ryanlntn
Copy link

ryanlntn commented Mar 2, 2016

@seanpdoyle Yeah. I've followed all the Heroku setup steps in the readme and I'm seeing that error.

@tute
Copy link

tute commented Mar 3, 2016

@tute since we've just recently worked through a similar issue, do you have any guess as to what's causing this?

The problem I had was that my frontend/ember-cli-build.js was doing var deploy = require('./config/deploy');, but I had removed that file (made sense only for deploying to S3 and redis) and forgot to remove the require line. So it was a Javascript error that wasn't being surfaced.

@seanpdoyle
Copy link
Contributor

it was a Javascript error that wasn't being surfaced.

@ryanlntn could you try running:

$ rm -rf frontend/{tmp,dist} tmp/ember-cli
$ RAILS_ENV=production bundle exec rake assets:precompile
$ cat tmp/ember-cli/apps/frontend/index.html

@tute
Copy link

tute commented Mar 3, 2016

@ryancoughlin what version of node are you using?

@ryanlntn
Copy link

ryanlntn commented Mar 3, 2016

@seanpdoyle This is the output that gives me:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Sequenched</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="description" content="Sequenched is your yoga class sequence builder. Asana, pranayama, mantra & amazing sample yoga classes. Plan your classes now for free. All devices."
>

    <base href="/" />

    <link rel="stylesheet" href="assets/vendor-d41d8cd98f00b204e9800998ecf8427e.css" integrity="sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= sha512-z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlODJ6+SfaPg==" >
    <link rel="stylesheet" href="assets/frontend-d41d8cd98f00b204e9800998ecf8427e.css" integrity="sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= sha512-z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlODJ6+SfaPg==" >
    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=2">


  </head>
  <body>


    <script src="assets/vendor-fa4c3361719a64a2b310a3d2a7547a69.js"></script>
    <script src="assets/frontend-1ebae450b20e52a49a09e32b214e016a.js"></script>


  </body>
</html>

@tute I'm running v5.6.0.

@bajalovic
Copy link

I saw several questions with same error message (but regarding to Heroku) but I could not fix mine.

I built a docker container image, but the ember app can not be displayed:

I, [2016-03-21T20:56:07.939303 #24]  INFO -- : Started GET "/app" for 192.168.99.1 at 2016-03-21 20:56:07 +0000
I, [2016-03-21T20:56:08.001556 #24]  INFO -- : Processing by EmberCli::EmberController#index as HTML
I, [2016-03-21T20:56:08.001666 #24]  INFO -- :   Parameters: {"ember_app"=>:frontend}
D, [2016-03-21T20:56:08.018137 #24] DEBUG -- :   User Load (0.5ms)  SELECT  `users`.* FROM `users` WHERE `users`.`id` = 1  ORDER BY `users`.`id` ASC LIMIT 1
D, [2016-03-21T20:56:08.044932 #24] DEBUG -- :   Company Load (0.4ms)  SELECT  `companies`.* FROM `companies` WHERE `companies`.`id` = 2 LIMIT 1
I, [2016-03-21T20:56:08.068090 #24]  INFO -- :   Rendered ember_cli/ember/index.html.erb (5.6ms)
I, [2016-03-21T20:56:08.068361 #24]  INFO -- : Completed 500 Internal Server Error in 67ms
F, [2016-03-21T20:56:08.069969 #24] FATAL -- :
ActionView::Template::Error (          EmberCLI failed to generate an `index.html` file.
):
    1: <%= render_ember_app ember_app do |head, body| %>
    2:     <% head.append do %>
    3:         <%= csrf_meta_tags %>
    4:     <% end %>
  app/views/ember_cli/ember/index.html.erb:1:in `_app_views_ember_cli_ember_index_html_erb___227654452272873356_47299009572860'

Inside container there is a RAILS_ENV=production .

Here is my configuration:

# config/routes.rb
mount_ember_app :frontend, to: '/app'

# config/initializers/ember.rb
EmberCli.configure do |c|
  c.app :frontend
end
// frontend/config/environment.js
module.exports = function (environment) {
  var ENV = {
    modulePrefix: 'frontend',
    environment: environment,
    baseURL: '/app',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
      host: 'http://localhost:3000',
      app_fixtures: {
        display_name: 'John Doe',
        first_name: 'John',
        last_name: 'Doe'
      }
    }
  };

  if (environment === 'development') {
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }
  if (environment === 'production') {
  }
  return ENV;
};

I have ember cli 2.3.0 and ember-cli-rails-addon 0.7.0 installed.

My docker container is built by:

FROM rails:onbuild

RUN apt-get update -qq && apt-get install -y build-essential nodejs npm nodejs-legacy
RUN npm install -g phantomjs
RUN npm install -g bower

RUN echo '{ "allow_root": true }' > /root/.bowerrc

RUN bundle exec rake assets:clean
RUN bundle exec rake assets:precompile

CMD ["unicorn", "--config-file", "./config/unicorn.rb", "--host", "0.0.0.0", "--port", "3000"]

@seanpdoyle any idea?

Also, in my production.rb I have

config.serve_static_files = true

@bajalovic
Copy link

After debugging I noticed that gem is trying to load Rails.root.join("tmp/ember-cli/apps/frontend/index.html"), and inside my docker container I had an empty frontend directory.

This lead me to think about compilation of assets - then I saw that there is no ember-cli installed so I added

RUN npm install ember-cli

just after RUN npm install -g bower. As node version is 0.10.x, I had to add one more command

RUN cd frontend && npm rebuild node-sass

I rebuilt image and it is working. However, environment is still development. I had to add RAILS_ENV=production to docker run command

RUN bundle exec rake assets:precompile RAILS_ENV=production

Now everything is up and running.

Basically, the problem was that ember compile did not finish with success (thus frontend dir was empty) but assets:precompile finished with success (no errors were given) as I did not have ember-cli installed.

If the error was saying please install ember-cli first (like it does for bower and node) and assets:precompile has failed, it would save so much time. I spent hours looking in configuration files, integrations, etc..

@seanpdoyle
Copy link
Contributor

@bajalovic thanks for getting to the bottom of this!

ember compile not failing and raising an error is a known issue.

A fix has been merged into master, but a release is blocked by #423 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants