Skip to content
This repository

rails g ember:bootstrap fail if don't exists application.js file #64

Closed
arandaio opened this Issue June 12, 2012 · 14 comments

11 participants

Javier Aranda Stefan Penner Denis Christopher Meiklejohn Ryan Romanchuk Leon Du frede ianpetzer Christos Vontas Mike Bajur Miguel Madero
Javier Aranda

Tested in ember-rails 0.5.0 and 0.6.0

If app/assets/javascripts don't exists or not have any application.js file inside, this operation fail.

$ rails g ember:bootstrap
[EMBER-RAILS] ember.variant was not found in your current environment
insert app/assets/javascripts/application.js
/Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/actions/inject_into_file.rb:99:in binread': No such file or directory - /Users/javierav/code/ember-demo/app/assets/javascripts/application.js (Errno::ENOENT)
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/actions/inject_into_file.rb:99:in
replace!'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/actions/inject_into_file.rb:60:in invoke!'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/actions.rb:95:in
action'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/actions/inject_into_file.rb:31:in insert_into_file'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/ember-rails-0.6.0/lib/generators/ember/bootstrap_generator.rb:17:in
inject_ember'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/task.rb:27:in run'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/invocation.rb:120:in
invoke_task'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/invocation.rb:126:in block in invoke_all'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/invocation.rb:126:in
each'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/invocation.rb:126:in map'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/invocation.rb:126:in
invoke_all'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/group.rb:238:in dispatch'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.2/lib/thor/base.rb:408:in
start'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.5/lib/rails/generators.rb:171:in invoke'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.5/lib/rails/commands/generate.rb:12:in
'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in require'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in
block in require'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:236:in load_dependency'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:251:in
require'
from /Users/javierav/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.5/lib/rails/commands.rb:29:in <top (required)>'
from script/rails:6:in
require'
from script/rails:6:in `'

Javier Aranda

Others detected problems:

If the application.js file don't have a line with the code //= require the generator don't insert any text in this file. If the line exists, after the insertions, the code is:

//= require .......
ProjectName = Ember.Application.create();
//= require....

The last require is the original require that I have in my application.js These is not processed by Assets and becomes in an javascript exception.

Denis
rhodee commented June 19, 2012

Running ember-rails 0.6.0 I encounter the following:

ActionView::Template::Error (couldn't find file 'handlebars'
(in /sandbox/ember_demo/app/assets/javascripts/application.js:15)):
3: <head>
4:   <title>EmberDemo</title>
5:   <%= stylesheet_link_tag    "application", :media => "all" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8: </head>
9: <body>
app/views/layouts/application.html.erb:6:in    `_app_views_layouts_application_html_erb__4471938073240671435_70234118761920'

Rendered /.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.5/lib/action_dispatch/middleware/templates/rescues/_trace.erb (21.7ms)
Rendered /.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.5/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.8ms)
Rendered /.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.5/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (27.6ms)
[2012-06-19 10:58:31] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true

The app is bare Rails (sqlite3, one model, two controllers all boilerplate). Then I run:

 rails g ember:bootstrap
  [EMBER-RAILS] `ember.variant` was not found in your current environment
  insert  app/assets/javascripts/application.js
  create  app/assets/javascripts/models
  create  app/assets/javascripts/models/.gitkeep
  create  app/assets/javascripts/controllers
  create  app/assets/javascripts/controllers/.gitkeep
  create  app/assets/javascripts/views
  create  app/assets/javascripts/views/.gitkeep
  create  app/assets/javascripts/routes
  create  app/assets/javascripts/routes/.gitkeep
  create  app/assets/javascripts/helpers
  create  app/assets/javascripts/helpers/.gitkeep
  create  app/assets/javascripts/templates
  create  app/assets/javascripts/templates/.gitkeep
  create  app/assets/javascripts/ember_demo.js
  create  app/assets/javascripts/routes/app_router.js
  create  app/assets/javascripts/store.js
  generate  ember:view
  [EMBER-RAILS] `ember.variant` was not found in your current environment
  create  app/assets/javascripts/views/application_view.js
  create  app/assets/javascripts/templates/application.handlebars
  create  app/assets/javascripts/controllers/application_controller.js

My Manifest looks like this:

 //= require jquery
 //= require jquery_ujs
 //= require handlebars
 //= require ember
 //= require ember-data
 //= require_self
 //= require ember_demo
 EmberDemo = Ember.Application.create();
 //= require_tree .

Why am I getting this error at this stage? Where specifically did I go wrong from the current docs on Master in the gem's repo?

Christopher Meiklejohn

//= require handlebars is unnecessary, remove it.

Ryan Romanchuk
 rails g ember:bootstrap

[EMBER-RAILS] `ember.variant` was not found in your current environment
      insert  app/assets/javascripts/application.js
/Users/rromanchuk/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.14.6/lib/thor/actions/inject_into_file.rb:99:in `binread': No such file or directory - /Users/rromanchuk/dev/[myproj]/app/assets/javascripts/application.js (Errno::ENOENT)
Ryan Romanchuk

blah, this is a bad bug, ..shouldn't fail out of the box like this

Ryan Romanchuk

Was failing because my application file has the extension of application.coffee not application.js

Leon Du
leondu commented July 26, 2012

FAIL!

I tried with 0.6 and a brand new rails app, still it gives me:

rails g ember:bootstrap
[EMBER-RAILS] `ember.variant` was not found in your current environment
      insert  app/assets/javascripts/application.js
      create  app/assets/javascripts/models
      create  app/assets/javascripts/models/.gitkeep
      create  app/assets/javascripts/controllers
      create  app/assets/javascripts/controllers/.gitkeep
      create  app/assets/javascripts/views
      create  app/assets/javascripts/views/.gitkeep
      create  app/assets/javascripts/routes
      create  app/assets/javascripts/routes/.gitkeep
      create  app/assets/javascripts/helpers
      create  app/assets/javascripts/helpers/.gitkeep
      create  app/assets/javascripts/templates
      create  app/assets/javascripts/templates/.gitkeep
      create  app/assets/javascripts/ember_rest_demo.js
      create  app/assets/javascripts/routes/app_router.js
      create  app/assets/javascripts/store.js
    generate  ember:view
[EMBER-RAILS] `ember.variant` was not found in your current environment
      create  app/assets/javascripts/views/application_view.js
      create  app/assets/javascripts/templates/application.handlebars
      create  app/assets/javascripts/controllers/application_controller.js
Leon Du
leondu commented July 26, 2012

ps, I do have application.js

Denis

Add the line config.ember.variant = :development to your config/environment/development.rb for example and you should no longer receive this message. That said you should do this prior to running the bootstrap scripts in order to avoid this warning. You can obviously add it to the other environment configs as you wish.

frede

+1 doesnt find handlebars anyhow

ianpetzer

I was experiencing this problem while trying to deploy my app to Heroku. Turns out that I'd only specified my config.ember.variant in development.rb. I added it to production.rb which solved my problems.

Christos Vontas
cv711 commented May 15, 2013

Addind the equivalent config.ember.variant both in development and production solved it for me.

Stefan Penner stefanpenner closed this August 03, 2013
Mike Bajur

None of listed solutions solves the original issue (fail if application.js file don't exists).

Miguel Madero

I just did it and I still had to manually add application.js first. Seems like an easy fix, I might have a look if we decide to go with this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.