ember-rails icon indicating copy to clipboard operation
ember-rails copied to clipboard

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

Open javierav opened this issue 14 years ago • 14 comments

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 avatar Jun 12 '12 19:06 javierav

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 avatar Jun 12 '12 21:06 javierav

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 avatar Jun 19 '12 15:06 rhodee

//= require handlebars is unnecessary, remove it.

cmeiklejohn avatar Jun 22 '12 01:06 cmeiklejohn

 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 avatar Jun 24 '12 18:06 rromanchuk

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

rromanchuk avatar Jun 24 '12 18:06 rromanchuk

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

rromanchuk avatar Jun 24 '12 18:06 rromanchuk

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 avatar Jul 26 '12 08:07 leondu

ps, I do have application.js

leondu avatar Jul 26 '12 08:07 leondu

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 avatar Aug 07 '12 14:08 rhodee

+1 doesnt find handlebars anyhow

friedhelm-langhof avatar Dec 08 '12 19:12 friedhelm-langhof

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 avatar Apr 05 '13 10:04 ianpetzer

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

cv711 avatar May 15 '13 13:05 cv711

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

mbajur avatar Aug 09 '13 13:08 mbajur

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 avatar Oct 21 '13 22:10 MiguelMadero