emberjs/ember-rails

Dependency problems with ember-source

ninja- opened this issue · 6 comments

When using the newest ember-source, ember-rails is stuck with some kind of dependency problem:

gem 'ember-rails'
gem 'ember-source', '~> 1.10.0' # or the version you need
Bundler could not find compatible versions for gem "handlebars-source":
  In Gemfile:
    ember-rails (= 0.16.4) ruby depends on
      handlebars-source (< 3, > 1.0.0) ruby

    ember-rails (= 0.16.4) ruby depends on
      handlebars-source (3.0.0)

the reason I wanted to update in first place is the

template must be a function. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?

error

I could update after removing gemfile.lock.
The template error still holds, and the compiled template looks like this

Ember.TEMPLATES["login"] = Ember.Handlebars.template({"1":function(depth0,helpers,partials,data) {
  var stack1, buffer = '';
  data.buffer.push("  <h2>");
  stack1 = helpers._triageMustache.call(depth0, "title", {"name":"_triageMustache","hash":{},"hashTypes":{},"hashContexts":{},"types":["ID"],"contexts":[depth0],"data":data});
  if (stack1 != null) { data.buffer.push(stack1); }
  data.buffer.push("</h2>\n  ");
  stack1 = helpers._triageMustache.call(depth0, "text", {"name":"_triageMustache","hash":{},"hashTypes":{},"hashContexts":{},"types":["ID"],"contexts":[depth0],"data":data});
  if (stack1 != null) { data.buffer.push(stack1); }
  data.buffer.push("\n");
  return buffer;
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
  var stack1, buffer = '';
  data.buffer.push("<h1>Posts</h1>\n\n");
  stack1 = helpers.each.call(depth0, {"name":"each","hash":{},"hashTypes":{},"hashContexts":{},"fn":this.program(1, data),"inverse":this.noop,"types":[],"contexts":[],"data":data});
  if (stack1 != null) { data.buffer.push(stack1); }
  return buffer;
},"useData":true});

config.handlebar.ember_template is set to HTMLBars but changing it to Handlebars doesnt change anything

The needed step after updating the ember-source gem was to clear cache & spring stop.
The template error is now gone.
I suggest changing README as ember-source 1.9 no longer works with latest version of ember-rails, which could be confusing for new users.

It looks like ember-rails gem no longer declares handlebars gem as a dependency. I was following the readme and handlebars isn't in the Gemfile.lock nor added to application.js. So I assume we have to add handlebars to our Gemfile, which is fine, as long as those two additional steps are added to the readme.

Actually, it appears we need to add the handlebars-source gem, not handlebars, and perhaps it should be version < 3.0. Further, it looks like handlebars-source 2.0 will not upgrade to 3.0 with bundle install unless you spec the version in your Gemfile. I wonder if those two facts didn't conspire to cause the problem you were seeing.

It seems this dependency problems is caused by bundler.

In addition, this template error is caused by sprockets' cache. If you use sprockets 3.0.0.beta10 or later, ember-source version is used in cache key.
So it is no longer problem.

It looks like ember-rails gem no longer declares handlebars gem as a dependency

Yes. But older ember-source depends on handlebars-source.
If handlebars-source is accessible from ember-rails, handlebars support will automatically be applied.