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

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

Closed
javierav opened this Issue Jun 12, 2012 · 14 comments

Comments

Projects
None yet
@javierav

javierav commented Jun 12, 2012

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:inreplace!'
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:inaction'
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:ininject_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:ininvoke_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:ineach'
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:ininvoke_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:instart'
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<top (required)>'
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:inblock 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:inrequire'
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:inrequire'
from script/rails:6:in `

'

@javierav

This comment has been minimized.

Show comment
Hide comment
@javierav

javierav Jun 12, 2012

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.

javierav commented Jun 12, 2012

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.

@rhodee

This comment has been minimized.

Show comment
Hide comment
@rhodee

rhodee Jun 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?

rhodee commented Jun 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?

@cmeiklejohn

This comment has been minimized.

Show comment
Hide comment
@cmeiklejohn

cmeiklejohn Jun 22, 2012

Contributor

//= require handlebars is unnecessary, remove it.

Contributor

cmeiklejohn commented Jun 22, 2012

//= require handlebars is unnecessary, remove it.

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Jun 24, 2012

Contributor
 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)
Contributor

rromanchuk commented Jun 24, 2012

 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)
@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Jun 24, 2012

Contributor

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

Contributor

rromanchuk commented Jun 24, 2012

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

@rromanchuk

This comment has been minimized.

Show comment
Hide comment
@rromanchuk

rromanchuk Jun 24, 2012

Contributor

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

Contributor

rromanchuk commented Jun 24, 2012

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

@leondu

This comment has been minimized.

Show comment
Hide comment
@leondu

leondu Jul 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

leondu commented Jul 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
@leondu

This comment has been minimized.

Show comment
Hide comment
@leondu

leondu Jul 26, 2012

ps, I do have application.js

leondu commented Jul 26, 2012

ps, I do have application.js

@rhodee

This comment has been minimized.

Show comment
Hide comment
@rhodee

rhodee Aug 7, 2012

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.

rhodee commented Aug 7, 2012

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

This comment has been minimized.

Show comment
Hide comment
@frede

frede Dec 8, 2012

+1 doesnt find handlebars anyhow

frede commented Dec 8, 2012

+1 doesnt find handlebars anyhow

@ianpetzer

This comment has been minimized.

Show comment
Hide comment
@ianpetzer

ianpetzer Apr 5, 2013

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.

ianpetzer commented Apr 5, 2013

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.

@cv711

This comment has been minimized.

Show comment
Hide comment
@cv711

cv711 May 15, 2013

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

cv711 commented May 15, 2013

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

@mbajur

This comment has been minimized.

Show comment
Hide comment
@mbajur

mbajur Aug 9, 2013

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

mbajur commented Aug 9, 2013

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

@MiguelMadero

This comment has been minimized.

Show comment
Hide comment
@MiguelMadero

MiguelMadero Oct 21, 2013

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.

MiguelMadero commented Oct 21, 2013

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