Handlebars precompile version error with Ember rc1 - ember.js

Upgrading Ember to 1.0.0-rc1 results in the following error:
Uncaught Template was precompiled with an older version of Handlebars
than the current runtime. Please update your precompiler to a newer
version (>= 1.0.0-rc.3) or downgrade your runtime to an older version (<= 1.0.rc.2).
I am using a version of handlebars that should work according to the error message above:
DEBUG: Ember.VERSION : 1.0.0-rc.1 ember.js:339
DEBUG: Handlebars.VERSION : 1.0.0-rc.3 ember.js:339
DEBUG: jQuery.VERSION : 1.9.1
I also upgraded my ember-rails gem to 0.9.2
How do I get around this error?

This was caused by barber gem which is using handlebars rc2 for template precompilation. I've made a pull request which fixes it. If you need this working now, you can just use my fork :)
Update: instructions for using darthdeus fork:
1) Add the following to your Gemfile:
gem "barber", :git => "git://github.com/darthdeus/barber.git", :branch => "update-handlebars-to-rc3"
2) Clear your tmp dir
rm -rf tmp
3) Restart your server
edit: for future readers the changes have been merged now, so using a master branch from the official repo should work.

Related

TypeError: Cannot read property 'serve:before' of undefined on Ionic CLI 2.2.1 + Gulp 4

I am developing a Web Application that have a lot of legacy dependencies.
On the trial of updating some packages, I updated the gulp/gulpfile.js and tinkered then to run. Gulp was on version 3.5 and now is on 4.0.
By the way, the error thrown in the terminal by running : ionic serve --address localhost --nobrowser is :
Error: spawn cordova EACCES
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Mind letting us know? https://github.com/driftyco/ionic-cli/issues
******************************************************
Dependency warning - for the CLI to run correctly,
it is highly recommended to install/upgrade the following:
Please update your Cordova CLI to version >=4.2.0 `npm install -g cordova`
******************************************************
TypeError: Cannot read property 'serve:before' of undefined
at Object.runWithGulp (/usr/lib/node_modules/ionic/lib/cli.js:237:17)
at Object.runr (/usr/lib/node_modules/ionic/lib/cli.js:194:18)
at /usr/lib/node_modules/ionic/lib/cli.js:54:9
at _fulfilled (/usr/lib/node_modules/ionic/node_modules/q/q.js:787:54)
at /usr/lib/node_modules/ionic/node_modules/q/q.js:816:30
at Promise.promise.promiseDispatch (/usr/lib/node_modules/ionic/node_modules/q/q.js:749:13)
at /usr/lib/node_modules/ionic/node_modules/q/q.js:557:44
at flush (/usr/lib/node_modules/ionic/node_modules/q/q.js:108:17)
at process._tickCallback (internal/process/next_tick.js:61:11)
Cannot read property 'serve:before' of undefined (CLI v2.2.1)
Your system information:
Cordova CLI: undefined
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 5.4
Node Version: v10.16.3
Xcode version: Not installed
Then, some patch of the gulpfile.js :
gulp.task('build', gulp.series('bundle', 'copyTask', 'revTask', 'revReplaceTask'));
gulp.task('default', gulp.series('sassTask', 'cleanTask', 'build', 'watchTask'));
gulp.task('serve:before', gulp.series('cleanTask', 'watchTask', 'build'));
Before the tinkering, gulp.task('serve:before' [...]) functioned well. I guess it is related with the Ionic 2.2.1 CLI.
If someone could help me by a hint or an advice for mismatching the problem, I would be glad.
This happened to me while I upgraded Node to v12 which forced me to upgrade Gulp to v4.
The solution that worked for me is:
Go to npm\node_modules\ionic\lib\cli.js (Wherever it's located).
Change the following lines as such in cli.js:
237: if (true || gulp.tasks[beforeHook]) {
257: if (true || gulp.tasks[afterHook]) {
270: return Q.nfcall(null/*gulp.start.bind(gulp)*/, hookName)
Basically, the reason is that gulp.tasks and gulp.start don't exist in Gulp v4.
By putting true || in the first occurrences, gulp.tasks won't run and by putting null in the last occurrence, the gulp.start won't run.
I hope this helps the next people that encounter this problem.

Ember-cli: Live reload not working

I started my first project with ember cli and I noticed that the live reload isn't working. When I start the development server, I get multiple error messages (see below). Changes to the code base are only available after a restart of the server.
$ ember server
version: 0.1.2
Livereload server on port 35729
Serving on http://0.0.0.0:4200/
2014-12-03 17:51 ember[16491] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-03 17:51 ember[16491] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
...
2014-12-03 17:51 ember[16491] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
2014-12-03 17:51 ember[16491] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-21)
Build successful - 1180ms.
Slowest Trees | Total
-------------------------------+----------------
Concat | 368ms
ES6Concatenator | 150ms
ES3SafeFilter | 149ms
JSHint - App | 104ms
JSHint - Tests | 80ms
At this stage I have the following packages/addons installed:
DEBUG: -------------------------------
DEBUG: Ember : 1.7.0
DEBUG: Ember Data : 1.0.0-beta.10
DEBUG: EmberFire : 1.3.1
DEBUG: Handlebars : 1.3.0
DEBUG: jQuery : 1.11.1
DEBUG: -------------------------------
Any idea what could cause this issue? It is quite annoying to restart the server for every change.
Thank you for your suggestions.
The error is essentially caused by FSEvents watching too many files. If you're using Sublime Text, try excluding node_modules/, tmp/, and dist/ from your project (add them to the folder_exclude_patterns array in your Sublime user preferences).
If you're not using Sublime, or if doing so doesn't fix the issue, try upgrading your version of Node and version of ember-cli to the latest versions, as well as installing watchman using brew install watchman if you have Homebrew installed/are on OS X (as the latest versions of ember-cli no longer rely on FSEvents.
Source: https://github.com/ember-cli/ember-cli/issues/1260#issuecomment-67549158
Add this parameters(liveReload and Watcher) to the file /.ember-cli and this will end with something like this:
{
/**
Ember CLI sends analytics information by default. The data is ...
*/
"disableAnalytics": false,
"liveReload": true,
"watcher": "polling"
}
/* Pooling, this is where the magic come, allow to edit file in the host and outside(EX: Virtual machines and servers relate) */

can't install simple_captcha produces uninitialized constant Sprockets::Helpers

I have included the simple_captcha gem as instructed on their site:
gem 'simple_captcha', :git => 'git://github.com/galetahub/simple-captcha.git'
I have then run bundler to install it.
Finally when I go to run the following command I get an error:
rails generate simple_captcha
.rvm/gems/ruby-1.9.3-p327#eapi4/bundler/gems/simple-captcha-e99cc7e8bf6b/lib/simple_captcha/form_builder.rb:7:in `included': uninitialized constant Sprockets::Helpers (NameError)
I've searched on the web and can't find any other users with this problem.
Any help appreciated
They say in this pull request that the plugin doesn't support rails 4, You can download their branch and try it out.
Looking at the diff it shows your problem
- base.send(:include, Sprockets::Helpers::RailsHelper)
- base.send(:include, Sprockets::Helpers::IsolatedHelper)
+ base.send(:include, Sprockets::Rails::Helper)
https://github.com/galetahub/simple-captcha/pull/39/files
you could this as the previous version of simple_captcha is not supported on rails 3.
Azdaroth forked of simple_captcha
gem 'simple_captcha', :git => 'git://github.com/Azdaroth/simple-captcha.git', :branch => 'rails-4'

Puppet install gem fails but gem is installed anyways

I have a Puppet manifest that installs the Zurb Foundation gem:
class compass {
package { ["rubygems"]:
ensure => 'installed'
}
package { ['zurb-foundation']:
ensure => '3.0.6',
provider => 'gem',
require => Package['rubygems']
}
}
This causes the following error when running puppet apply:
err: /Stage[main]/Compass/Package[zurb-foundation]/ensure: change from absent to 3.0.6 failed: Could not update: Execution of '/usr/bin/gem install -v 3.0.6 --include-dependencies --no-rdoc --no-ri zurb-foundation' returned 1: INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
Building native extensions. This could take a while...
ERROR: Error installing zurb-foundation:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:4:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/ffi-1.9.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/ffi-1.9.0/ext/ffi_c/gem_make.out
at /etc/puppet/manifests/classes/compass.pp:25
However, doing a gem list yields the following results:
# gem list
*** LOCAL GEMS ***
chunky_png (1.2.8)
compass (0.12.2)
fssm (0.2.10)
rake (10.1.0)
rb-fsevent (0.9.3)
sass (3.2.0.alpha.277)
zurb-foundation (3.0.6)
The error causes puppet apply to not complete properly, since a lot of items are skipped because of failed dependencies. What can I do?
I think that the problem is that you don't have the ruby dev kit installed for you ruby (that's what's used to build native extensions).
You'll want to add something like (it may be different depending on your version of ruby):
package { 'ruby-dev':
ensure => installed,
before => Package['zurb-foundation'],
}
This should allow the gem to be built properly and let your puppet run finish too.

Handlebars Asset not Compiling with ember-rails after Upgrade to Rails 4

I have a Rails app with Ember on the front-end. Today, I upgraded to Rails 4 and the only issue I cannot resolve is that my Handlebars templates are not being compiled or included as an asset (in development mode). I'm not getting any error messages.
I generated a brand new Rails 4 test app and installed Ember and it serves the Handlebars files just fine. All gems in the test app are present in my app. I tried running rake rails:upgrade, and that had no effect. I tried modifying the ember-rails source to output log messages and the messages and execution paths were the same for the test app and my app.
I'm requiring the templates the same way I always did:
require_tree ./templates
I tried using ember-rails 0.11.1 and from Github master, with no luck.
Related gem versions:
* ember-data-source (0.0.5)
* ember-rails (0.11.1 4dc902b)
* ember-source (1.0.0.rc2.0)
* sprockets (2.9.0)
* sprockets-rails (2.0.0.rc3)
* barber (0.4.1)
Templates are all in app/assets/javascripts/templates and all use the extension .handlebars. Although I tried .hbs and .js.hjs too.
From the Chrome console:
Ember.TEMPLATES
Object {}
I am able to manually compile assets from the Rails command line like this:
environment = Sprockets::Environment.new
environment.append_path 'app/assets/javascripts'
a = environment['templates/test.handlebars']
a.to_s => "..compiled template.."
And the engine is registered:
environment.engines
=> {..".handlebars"=>Ember::Handlebars::Template..}
Rails.application.config.assets.paths includes the app/assets/javascripts folder, as it should.
Any help with this would be greatly appreciated, Thanks!
I've narrowed it down to the following block in ember-rail's engine.rb file. For my app, it is sending register_engine on Sprockets, not app.assets. On the fresh Rails 4 test app, it was also doing this. However, in my app when I force the execution to use app.assets, the handlebar templates are compiled.
I believe since my app was upgraded from Rails 3, somewhere some configuration is missing to properly use Sprockets. I'll post more when I know.
initializer "ember_rails.setup", :after => :append_assets_path, :group => :all do |app|
sprockets = if ::Rails::VERSION::MAJOR == 4
Sprockets.respond_to?('register_engine') ? Sprockets : app.assets
else
app.assets
end
sprockets.register_engine '.handlebars', Ember::Handlebars::Template
sprockets.register_engine '.hbs', Ember::Handlebars::Template
sprockets.register_engine '.hjs', Ember::Handlebars::Template
end
UPDATE:
For me,changing the railties order in application.rb was enough to fix the problem. I believe some other engine was clearing the Sprockets config, so by loading the Ember::Rails engine later in the process, I was able to hack a way around that issue.
config.railties_order = [:main_app, :all, Ember::Rails::Engine]