GithubHelp home page GithubHelp logo

Comments (14)

leshill avatar leshill commented on May 24, 2024

Hi @afeld,

Just updated to Rails 3.2.6 in an example app and I am not seeing this. The Gemfile.lock shows:

handlebars_assets (0.4.4)
sprockets (2.1.3)

rake assets:precompile works as well. Is there something else I can look at to help?

from handlebars_assets.

ph avatar ph commented on May 24, 2024

I have the same problem in production on heroku

HomeController# (ActionView::Template::Error) "couldn't find file 'handlebars.runtime'\n (in /app/app/assets/javascripts/application.js:14)"

running

handlebars_assets (0.4.4)
sprockets (2.1.3)

from handlebars_assets.

leshill avatar leshill commented on May 24, 2024

Hi @ph,

Do you mind trying v0.6.2 (just released?)

from handlebars_assets.

ph avatar ph commented on May 24, 2024

yes its work now, thank you.

from handlebars_assets.

leshill avatar leshill commented on May 24, 2024

Awesome.

from handlebars_assets.

tolsen avatar tolsen commented on May 24, 2024

Hello. I work with @afeld. We are still seeing this problem in Rails 3.2.8 with handlebars_assets 0.6.2 and sprockets 2.1.3. Here is the first 10 lines of the backtrace:

Sprockets::FileNotFound: couldn't find file 'handlebars.runtime' (in /opt/jux/apps/jux/releases/20120821022836/app/assets/javascripts/app.combined.js:14)
[GEM_ROOT]/gems/sprockets-2.1.3/lib/sprockets/context.rb:100:in resolve' [GEM_ROOT]/gems/sprockets-2.1.3/lib/sprockets/context.rb:140:inrequire_asset'
[GEM_ROOT]/gems/sprockets-2.1.3/lib/sprockets/directive_processor.rb:215:in process_require_directive' [GEM_ROOT]/gems/sprockets-2.1.3/lib/sprockets/directive_processor.rb:165:inblock in process_directives'
[GEM_ROOT]/gems/sprockets-2.1.3/lib/sprockets/directive_processor.rb:163:in each' [GEM_ROOT]/gems/sprockets-2.1.3/lib/sprockets/directive_processor.rb:163:inprocess_directives'
[GEM_ROOT]/gems/sprockets-2.1.3/lib/sprockets/directive_processor.rb:97:in evaluate' [GEM_ROOT]/gems/tilt-1.3.3/lib/tilt/template.rb:76:inrender'
[GEM_ROOT]/gems/sprockets-2.1.3/lib/sprockets/context.rb:177:in block in evaluate' [GEM_ROOT]/gems/sprockets-2.1.3/lib/sprockets/context.rb:174:ineach'

from handlebars_assets.

leshill avatar leshill commented on May 24, 2024

Hi @tolsen,

Make sure the gem is in a group that is actually available when compiling assets in production; assets should work.

from handlebars_assets.

tolsen avatar tolsen commented on May 24, 2024

It is in the assets group:

group :assets do
gem 'handlebars_assets'
gem 'uglifier'
gem 'yui-compressor'
end

The only thing we've changed is to upgrade Rails from 3.2.3 to 3.2.8 (@afeld tried 3.2.6).

from handlebars_assets.

leshill avatar leshill commented on May 24, 2024

Hi @tolsen,

Thanks for showing that. Debugging via comments is difficult at best :/

What happens when you run rake assets:precompile locally?

The handlebars.runtime.js file is located inside the gem at vendor/assets/javascripts which is where Sprockets expects it when using Rails. If you want to move past this particular problem you can copy it to app/assets/javascripts where it will be found without the gem. At that point, I would expect the problem to be that the .hbs files are unknown, since it looks like there is an issue loading the gem.

from handlebars_assets.

tolsen avatar tolsen commented on May 24, 2024

asset compilation works fine locally. No errors.

Copying handlebars.runtime.js to vendor/assets/javascripts completely fixes the problem. There are no problems with the .hbs files.

We can do this as a workaround for now. But if you like I can further investigate this issue (besides, I'd rather not have to remember to manually copy the everytime we update handlebars_assets). Is there a load path for Sprockets that I can look at?

from handlebars_assets.

leshill avatar leshill commented on May 24, 2024

Hi @tolsen,

Yes, please do. That is not what I expected at all :/ Try checking the value of:

Sprockets::Environment.new.paths

from handlebars_assets.

tolsen avatar tolsen commented on May 24, 2024

Hi @leshill,

Sprockets::Environment.new.paths is empty: []

I inserted logging code in a javascript asset:

/*
 * <%= require('pp'); nil %>
 * <%= Rails.logger.warn('PATH'); nil %>
 * <%= Rails.logger.warn(PP.pp(Sprockets::Environment.new.paths, '')); nil %>
 */

which resulted in the following output in the log:

PATH
[]

Here's our asset configuration:

    config.assets.enabled = true

    # Version of your assets, change this if you want to expire all your assets
    config.assets.version = '1.0'

    # Change the path that assets are served from
    # config.assets.prefix = "/assets"

    # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
    #config.assets.precompile += [ /\.(js|css)(\.|$)/ ]
    config.assets.precompile += [ /(^|\/)[^_\/][^\/]*\.css$/, /\.js$/ ]

    config.assets.paths << "#{Rails.root}/app/assets/templates"
  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Choose the compressors to use
  config.assets.js_compressor  = :uglifier
  config.assets.css_compressor = :yui

  # using suggestion from https://github.com/rails/sass-rails/issues/63
  config.after_initialize do
    config.assets.css_compressor = nil
  end
  config.sass.style = :compressed

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = true

  # Generate digests for assets URLs.
  config.assets.digest = true

from handlebars_assets.

leshill avatar leshill commented on May 24, 2024

Hi @tolsen,

Hmmm, that is odd.

Noticed this line:

config.assets.paths << "#{Rails.root}/app/assets/templates"

Sprockets probably allows a String; you could try a Pathname:

config.assets.paths << Rails.root.join('app/assets/templates')

And as of this commit templates is stripped from paths by default. You can change that with lib/handlebars_assets/config.rb by setting path_prefix as needed.

from handlebars_assets.

asumaran avatar asumaran commented on May 24, 2024

I got this error when running in production mode in my local desktop (OS X 10.8.3)

$ RAILS_ENV=production bundle exec rails s

The file console-8946dbb40970d6a70732335eb7242b1d.js only shows the following text

throw Error("Sprockets::FileNotFound: couldn't find file 'handlebars.runtime'\n  (in {Rails.root}/app/assets/javascripts/console.js:1)")

The content of my console.js file is

//= require handlebars.runtime
//= require jquery
//= require jquery_ujs
//= require_tree ./templates/console 

The gem is added in the assets group as follows

group :assets do
  gem "handlebars_assets"
  # more gems
end

and this is my current gemfile.lock if anyone wants to look into
https://gist.github.com/asumaran/01699d3f84333e3792fd

And there's no files in vendor/assets/javascripts/

The thing is that in development mode works well. Any thoughts?

UPDATE: I solved copying the handlebars.runtime file to vendor/assets/javascripts/ from the Gem folder and is working now but I don't know if this it is the correct way to solve this.

from handlebars_assets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.