refinery / refinerycms

An extendable Ruby on Rails CMS that supports Rails 6.0+
https://www.refinerycms.com/
MIT License
3.9k stars 1.26k forks source link

Refinery Overrides Sprockets manifests? #3178

Closed bsodmike closed 7 years ago

bsodmike commented 8 years ago

Hi @parndt @bricesanchez,

Thanks to your help I've got this booting in Rails 5. Having run the CMS generator I noticed,

-- You may need to remove 'app/views/layouts/application.html.erb' for Refinery to function properly --

I've also noticed that since v3, refiinery/core now has its own application sprockets SASS (*.scss) manifests. I'm potentially going against the grain of Refinery, but bare with me.

Before adding Refinery in, I renamed the CSS/JS manifests in app/views/layouts/application.html.erb to main_application respectively, and these were added to the assets initialiser to ensure they are precompiled. Everything looked good so far.

Once Refinery is booted as part of the env (but not mounted in routes), here's where it gets interesting — those manifests can not longer be found, but application (CSS) loads fine, which is the default CSS manifest from within Refinery. I'm trying to figure out, which part of Refinery is preventing this from loading...

Started GET "/stylesheets/main_application.css" for 127.0.0.1 at 2016-05-11 09:11:07 +0530

ActionController::RoutingError (No route matches [GET] "/stylesheets/main_application.css"):

actionpack (5.0.0.beta3) lib/action_dispatch/middleware/debug_exceptions.rb:53:in `call'
web-console (3.1.1) lib/web_console/middleware.rb:131:in `call_app'
web-console (3.1.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.1.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.1.1) lib/web_console/middleware.rb:18:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.0.beta3) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.0.beta3) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.0.beta3) lib/active_support/tagged_logging.rb:70:in `block in tagged'
activesupport (5.0.0.beta3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.0.beta3) lib/active_support/tagged_logging.rb:70:in `tagged'
railties (5.0.0.beta3) lib/rails/rack/logger.rb:24:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
request_store (1.3.1) lib/request_store/middleware.rb:9:in `call'

Any pointers would be most appreciated, thanks again!

bsodmike commented 8 years ago

I've been able to trace this a bit further, which required debugging through both rails and sprockets-rails. All I can say is something within Refinery is changing behaviour within sprockets-rails.

I started digging here,

From: ./reference/rails/actionview/lib/action_view/helpers/asset_tag_helper.rb @ line 95 ActionView::Helpers::AssetTagHelper#stylesheet_link_tag:

     92: def stylesheet_link_tag(*sources)
     93:   binding.pry

and calling caller let me look through for a bit more detail

"/Users/foo/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/byebug-8.2.4/lib/byebug/context.rb:96:in `at_line'",
"./reference/rails/actionview/lib/action_view/helpers/asset_tag_helper.rb:95:in `stylesheet_link_tag'",
"/Users/foo/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-rails-3.0.4/lib/sprockets/rails/helper.rb:160:in `block (2 levels) in stylesheet_link_tag'",
"/Users/foo/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-rails-3.0.4/lib/sprockets/rails/helper.rb:159:in `map'",
"/Users/foo/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-rails-3.0.4/lib/sprockets/rails/helper.rb:159:in `block in stylesheet_link_tag'",
"/Users/foo/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-rails-3.0.4/lib/sprockets/rails/helper.rb:156:in `map'",
"/Users/foo/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-rails-3.0.4/lib/sprockets/rails/helper.rb:156:in `stylesheet_link_tag'",
"./app/views/layouts/application.html.erb:38:in `_app_views_layouts_application_html_erb___3526913260436728250_70199735354840'",

Taking a closer look inside sprockets-rails presented some divergent behaviour. asset = lookup_debug_asset(source, type: :javascript) succeeds for the refinery's application manifest, but my frontend/application.css is not resolved.

If I remove Refinery from being loaded into the env, however, it resolves fine

asset_resolver_strategies.first.instance_variable_get('@env')[path]
=> #<Sprockets::Asset:3ff7827c4f5c "./app/assets/stylesheets/frontend/application.scss?type=text/css&id=55c57fef44c3ce33d79534794b3cbdf96d89439dd559fb4195a6ab6f491cbd0e">

Thoughts?

parndt commented 8 years ago

Ugh, assets.

To my knowledge, we're note doing anything special that should interfere with assets. However, I haven't fully audited every single dependency, so maybe others will know of something that'd interfere?

bsodmike commented 8 years ago

I tried going to as many of the dependencies and the only thing I could find that hooks into Sprockets is the sass-rails dependency in Refinery, but there's no manipulation done on it (and internally it only cares about SASS stuff).

Therefore, I tried something different - I renamed the core/app/assets/stylesheets/application.scss to core/app/assets/stylesheets/frontend_application.scss and tried adding that to the top-level layout, which prompted that I add it to the assets initialiser's precomp list. And that worked, meaning Sprockets has no issues in resolving manifests inside Refinery.

But any manifests defined outside of Refinery (top-level) are seemingly being ignored. And if I remove Refinery (just from the Gemfile), boom. those top-level manifests start working. Real head scratcher here.

I'll set about generating a fresh Rails 5 + Refinery app to demonstrate this better.

bsodmike commented 8 years ago

You'll find a complete example here: https://github.com/bsodmike/refinery-rails-5-sprockets-issue-3178

Checkout the screenshots folder and all you need to do is clone this and commentout Refinery in the Gemfile and run it again.

Once Refinery is commented out and isn't loaded into the env, you'll find app/assets/stylesheets/frontend/application.scss renders without any issues. Further more, which is another clue, any app/assets/stylesheets/application.scss file is ignored, and the manifest withing Refinery the one that gets rendered on the frontend.

Hope this helps!

bsodmike commented 8 years ago

Cheers for adding the tags @bricesanchez. Appreciate any progress on verifying the demo I've provided.

bricesanchez commented 8 years ago

It's on my work table :)

bsodmike commented 8 years ago

Using the demo I've provided, I basically loaded a forked copy of the refinery code-base from Github, set to the feature/rails-5 branch.

I then proceeded to delete the sprocket manifests within '/core' and made sure my Gemfile directed that core was being loaded from my local install.

Having done so, once I made the following changes to the demo app,

gem 'refinerycms', path: '~/workspace/rails/refinery-cloned-for-rails-5-sprockets-issue-3178'
gem 'refinerycms-core', path: '~/workspace/rails/refinery-cloned-for-rails-5-sprockets-issue-3178/core'
    <%= stylesheet_link_tag 'application', media: 'all' %>
    <%= javascript_include_tag 'application' %>

The error reflects that it is now unable to locate those manifests, which were previously being loaded from within Refinery itself.

screen shot 2016-06-04 at 11 33 52

If this is changed to attempt to load the SASS manifest from the demo app, <%= stylesheet_link_tag 'frontend/application', media: 'all' %>, however,

screen shot 2016-06-04 at 11 31 34

This seems to confirm my suspicion as to there being some kind of 'top-level' fixation within sprockets that seems to scope it to looking for assets only within Refinery; as to why though, I am not sure 😭

bsodmike commented 8 years ago

Thanks for the milestone @bricesanchez ping me if you need me to dig any further :)

bricesanchez commented 8 years ago

@bsodmike i will come back to rails 5 support soon, i've some work to do on others PRs first.

bricesanchez commented 8 years ago

I'm facing assets error on engines like refinerycms-wymeditor with the feature/rails-5 branch. I'm sure it's related to changes on Sprockets with the manifest: https://github.com/rails/sprockets/blob/master/UPGRADING.md#manifestjs

I'm trying to understand what happens and how to solve it.

Help is welcome!

bsodmike commented 8 years ago

@bricesanches will try take a look this weekend :)

bsodmike commented 8 years ago

@bricesanchez could you kindly take a look at https://github.com/bsodmike/refinery-rails-5-sprockets-issue-3178/tree/todo/check_wymeditor_breakage which is specifically the todo/check_wymeditor_breakage branch.

My prior example has now been upgraded (specifically in this branch) to the latest version of rails, and I've also included refinerycms-wymeditor.

I am getting some errors too and want to check if you're seeing something similar,

screen shot 2016-10-03 at 15 06 17

Having run rails g refinery:cms --fresh-installation I've noticed that Refinery now removes app/views/layouts/application.html.erb, which for the past couple years is not how we have generally worked.

Our usual approach is to custom skin the frontend and rendering aspects from Refinery as needed. If you look at the topic branch provided, I've placed this application layout back, and attempted to render CSS via <%= stylesheet_link_tag 'frontend/application', media: 'all' %> — this still breaks.

Of course, <%= stylesheet_link_tag 'application', media: 'all' %> works, as this pulls the defaults from within Refinery.

bricesanchez commented 8 years ago

I am getting some errors too and want to check if you're seeing something similar,

I'm familiar with this errors :)

I've noticed that Refinery now removes app/views/layouts/application.html.erb

It's not wanted, i will fix that.

Of course, <%= stylesheet_link_tag 'application', media: 'all' %> works, as this pulls the defaults from within Refinery.

That's probably why my manifest.js file did not worked. Hahaha, i've missed that, i will check if it fixed my problems.

bsodmike commented 8 years ago

That's probably why my manifest.js file did not worked. Hahaha, i've missed that, i will check if it fixed my problems.

Well, I suppose my concern as per this issue is that I do want to be able to do <%= stylesheet_link_tag 'frontend/application', media: 'all' %> etc, and have Sprockets work like 'normal' rather than assets from within Refinery being 'scoped' somehow as the global default for the entire app frontend.

However, this approach may not gel with how the updated Refinery is suppose to work — or to rephrase — how we as devs are forced to use it. I hope this isn't a constraint.

It's not wanted, i will fix that.

Do you mean that you'll allow app/views/layouts/application.html.erb to exist? Or that layout is not needed a la the latest Refinery 'architecture'?

bricesanchez commented 8 years ago

Well, I suppose my concern as per this issue is that I do want to be able to do <%= stylesheet_link_tag 'frontend/application', media: 'all' %> etc, and have Sprockets work like 'normal' rather than assets from within Refinery being 'scoped' somehow as the global default for the entire app frontend.

However, this approach may not gel with how the updated Refinery is suppose to work — or to rephrase — how we as devs are forced to use it. I hope this isn't a constraint.

We follows standards and should not have constraints with Sprockets. So it's a bug to fix on Refinery.

Do you mean that you'll allow app/views/layouts/application.html.erb to exist? Or that layout is not needed a la the latest Refinery 'architecture'?

First, i will check what happens on current Refinery stable version and do the same on this new Refinery if it's relevant to do it. So i will probably : allow app/views/layouts/application.html.erb to exist

bsodmike commented 8 years ago

Noted, thanks! @bricesanchez

bricesanchez commented 8 years ago

@bsodmike thanks for testing this branch :)

bsodmike commented 8 years ago

@bricesanchez thanks to your comment pointing me at @parndt's fix, I was able to finally solve this — although, I don't know why this is so!

Here's the fix: https://github.com/bsodmike/refinery-rails-5-sprockets-issue-3178/commit/deb1aa6263858396992780c9fd9f220faf4bf740

It is only after adding that custom initialiser, to basically add the top-level app's asset paths back to Rails.application.assets.paths was I asked to add my custom manifest for pre-compilation — w000t progress!

screen shot 2016-10-15 at 11 04 55

I was then able to just add the stylesheets folder, and 💥

screen shot 2016-10-15 at 11 06 35

My guess is there's something in Refinery (or another dependency) that's removing and/or messing up the asset lookup paths. Thoughts?

bsodmike commented 8 years ago

Something that's rather curious about this, that I wanted to test, with my initialiser in place to use the last stable release of wymeditor — and that brings up all those asset errors again.

Therefore, it seems the top-level assets path needs to be added to engines as well as the top-level (as I have).

bsodmike commented 8 years ago

@parndt obvious and hackish quick fix would be to have Refinery Core implement the initialiser in the host-app as well as forcing all Refinery engines to run it as well. Crude — yes. Hmm.

parndt commented 8 years ago

@bsodmike @bricesanchez is there a way that we can push this bug upstream? Nothing changed in Refinery, all we did was upgrade Rails(/Sprockets) versions?

bsodmike commented 8 years ago

@parndt I just tried removing Refinery & the Sprockets initialiser that you provided in my example — it's just a Rails app now, and assets are resolved fine.

As such, I don't think we can push this bug upstream...

parndt commented 8 years ago

Sorry my question was more "is this broken for all Rails engines now?"

bricesanchez commented 8 years ago

Sorry my question was more "is this broken for all Rails engines now?"

I think it's broken for all refinery engines who could to be used in Rails 5.

I had the same problem with refinerycms-blog.

So at this time, i'm agree with @bsodmike quote :

My guess is there's something in Refinery (or another dependency) that's removing and/or messing up the asset lookup paths. Thoughts?

thebravoman commented 7 years ago

I was fighting the same issue for a few hours. Can confirm that @bsodmike solution (https://github.com/bsodmike/refinery-rails-5-sprockets-issue-3178/commit/deb1aa6263858396992780c9fd9f220faf4bf740) works.

thebravoman commented 7 years ago

Unfortunately this (bsodmike/refinery-rails-5-sprockets-issue-3178@deb1aa6) does not work for a production environment. Error is below and it happens because in config/environments/production.rb there is a config.cache_classes = true.

/home/kireto/.rvm/gems/ruby-2.2.2/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:66:in `config=': can't modify immutable cached environment (RuntimeError)
    from /home/kireto/.rvm/gems/ruby-2.2.2/gems/sprockets-3.7.1/lib/sprockets/paths.rb:37:in `prepend_path'
    from /home/kireto/robopartans/reduco/fllcasts/config/initializers/app_assets.rb:9:in `block (2 levels) in <top (required)>'
    from /home/kireto/robopartans/reduco/fllcasts/config/initializers/app_assets.rb:6:in `each'
    from /home/kireto/robopartans/reduco/fllcasts/config/initializers/app_assets.rb:6:in `block in <top (required)>'
    from /home/kireto/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:36:in `call'
bsodmike commented 7 years ago

Hey @thebravoman thanks for the heads up. That snippet of code was originally by @parndt so hope he'd have some ideas.

thebravoman commented 7 years ago

Continuing debugging

Here are the paths without refinery:

/home/kireto/robopartans/reduco/fllcasts/app/assets/fonts
/home/kireto/robopartans/reduco/fllcasts/app/assets/images
/home/kireto/robopartans/reduco/fllcasts/app/assets/javascripts
/home/kireto/robopartans/reduco/fllcasts/app/assets/stylesheets
/home/kireto/.rvm/gems/ruby-2.2.2/gems/ckeditor_rails-4.5.10/lib/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/ckeditor_rails-4.5.10/vendor/assets/images
/home/kireto/.rvm/gems/ruby-2.2.2/gems/ckeditor_rails-4.5.10/vendor/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/ckeditor_rails-4.5.10/vendor/assets/stylesheets
/home/kireto/.rvm/gems/ruby-2.2.2/gems/modernizr-rails-2.7.1/vendor/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-5.0.5/app/assets/images
/home/kireto/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-5.0.5/app/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-5.0.5/app/assets/stylesheets
/home/kireto/.rvm/gems/ruby-2.2.2/gems/jquery-rails-4.2.2/vendor/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/coffee-rails-4.2.1/lib/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/cocoon-1.2.9/app/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/rails4-autocomplete-1.1.1/lib/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/SaasySimple-0c9f9f08985e/app/assets/images
/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/SaasySimple-0c9f9f08985e/app/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/SaasySimple-0c9f9f08985e/app/assets/stylesheets
/home/kireto/.rvm/gems/ruby-2.2.2/gems/actioncable-5.0.0/lib/assets/compiled
/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.2.0.0/assets/stylesheets
/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.2.0.0/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.2.0.0/assets/fonts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.2.0.0/assets/images

Here are the paths with refinery:

/home/kireto/.rvm/gems/ruby-2.2.2/gems/speakingurl-rails-8.0.2/lib
/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/refinerycms-1f4ec66f94f1/core/app/assets/fonts
/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/refinerycms-1f4ec66f94f1/core/app/assets/images
/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/refinerycms-1f4ec66f94f1/core/app/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/refinerycms-1f4ec66f94f1/core/app/assets/stylesheets
/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/refinerycms-1f4ec66f94f1/core/vendor/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/refinerycms-i18n-727bdc58c307/app/assets/images
/home/kireto/.rvm/gems/ruby-2.2.2/gems/ckeditor_rails-4.5.10/lib/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/ckeditor_rails-4.5.10/vendor/assets/images
/home/kireto/.rvm/gems/ruby-2.2.2/gems/ckeditor_rails-4.5.10/vendor/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/ckeditor_rails-4.5.10/vendor/assets/stylesheets
/home/kireto/.rvm/gems/ruby-2.2.2/gems/modernizr-rails-2.7.1/vendor/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-5.0.5/app/assets/images
/home/kireto/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-5.0.5/app/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-5.0.5/app/assets/stylesheets
/home/kireto/.rvm/gems/ruby-2.2.2/gems/jquery-rails-4.2.2/vendor/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/coffee-rails-4.2.1/lib/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/cocoon-1.2.9/app/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/rails4-autocomplete-1.1.1/lib/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/SaasySimple-0c9f9f08985e/app/assets/images
/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/SaasySimple-0c9f9f08985e/app/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/SaasySimple-0c9f9f08985e/app/assets/stylesheets
/home/kireto/.rvm/gems/ruby-2.2.2/gems/actioncable-5.0.0/lib/assets/compiled
/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.2.0.0/assets/stylesheets
/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.2.0.0/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.2.0.0/assets/fonts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.2.0.0/assets/images
/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.2.0.0/assets/stylesheets
/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.2.0.0/assets/javascripts
/home/kireto/.rvm/gems/ruby-2.2.2/gems/font-awesome-sass-4.7.0/assets/stylesheets
/home/kireto/.rvm/gems/ruby-2.2.2/gems/font-awesome-sass-4.7.0/assets/fonts

This happens because sprokets decides to append the refinery paths instead of the path of my app.

This is different from rails 4 behavior where I have both refinery and my paths:

"/home/kireto/.rvm/gems/ruby-2.2.2/gems/speakingurl-rails-8.0.2/lib"
"/home/kireto/robopartans/reduco/fllcasts/app/assets/fonts"
"/home/kireto/robopartans/reduco/fllcasts/app/assets/images"
"/home/kireto/robopartans/reduco/fllcasts/app/assets/javascripts"
"/home/kireto/robopartans/reduco/fllcasts/app/assets/stylesheets"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/refinerycms-wymeditor-1.1.0/app/assets/images"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/refinerycms-wymeditor-1.1.0/app/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/refinerycms-wymeditor-1.1.0/app/assets/stylesheets"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/refinerycms-core-3.0.5/app/assets/images"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/refinerycms-core-3.0.5/app/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/refinerycms-core-3.0.5/app/assets/stylesheets"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/refinerycms-core-3.0.5/vendor/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/refinerycms-i18n-3.0.1/app/assets/images"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/ckeditor_rails-4.6.2/lib/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/ckeditor_rails-4.6.2/vendor/assets/images"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/ckeditor_rails-4.6.2/vendor/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/ckeditor_rails-4.6.2/vendor/assets/stylesheets"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/modernizr-rails-2.7.1/vendor/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-5.0.5/app/assets/images"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-5.0.5/app/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/jquery-ui-rails-5.0.5/app/assets/stylesheets"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/jquery-rails-4.2.2/vendor/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/coffee-rails-4.2.1/lib/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/cocoon-1.2.9/app/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/rails4-autocomplete-1.1.1/lib/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/SaasySimple-0c9f9f08985e/app/assets/images"
"/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/SaasySimple-0c9f9f08985e/app/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/bundler/gems/SaasySimple-0c9f9f08985e/app/assets/stylesheets"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.7/assets/stylesheets"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.7/assets/javascripts"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.7/assets/fonts"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.7/assets/images"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/font-awesome-sass-4.7.0/assets/stylesheets"
"/home/kireto/.rvm/gems/ruby-2.2.2/gems/font-awesome-sass-4.7.0/assets/fonts"
thebravoman commented 7 years ago

Tracked it down to an example app that shows the behavior. https://github.com/thebravoman/sprockets_not_loading_assets

There are three branches rails4 rails5_without_engine rails5_with_engine

I have created an issue at sprockets repo although I am not yet sure if this is a sprockets problem or refinery problem - https://github.com/rails/sprockets/issues/458

bsodmike commented 7 years ago

Awesome work @thebravoman

bsodmike commented 7 years ago

@thebravoman how did you get around the lib/sprockets/cached_environment.rb:66:in 'config=': can't modify immutable cached environment (RuntimeError) issue?

I've re-testing this again, accounting for your patch in sprockets-rails #388 and have run into the same issue. See my commit for details https://github.com/bsodmike/refinery-rails-5-sprockets-issue-3178/commit/da4f5612a823d45ce0ab2eacfb38219a2baa0330

Update

This was the last error trace, from the commit linked above.

~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.7.0/lib/sprockets/cached_environment.rb:66:in `config=': can't modify immutable cached environment (RuntimeError)
    from ~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.7.0/lib/sprockets/paths.rb:37:in `prepend_path'
    from ~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/refinerycms-wymeditor-7ba5e79d22a7/lib/refinery/wymeditor/engine.rb:15:in `block (2 levels) in <class:Engine>'
    from ~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/refinerycms-wymeditor-7ba5e79d22a7/lib/refinery/wymeditor/engine.rb:12:in `each'
    from ~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/refinerycms-wymeditor-7ba5e79d22a7/lib/refinery/wymeditor/engine.rb:12:in `block in <class:Engine>'

Just traced the error from sprockets for attempting to modify immutable cached env - this is a result of @parndt's proposed patch. Next step is to update the wymeditor dependency to remove this patch and re-check @thebravoman's proposed finisher hook fix.

bsodmike commented 7 years ago

Quick summary of progress re. https://github.com/bsodmike/refinery-rails-5-sprockets-issue-3178/commit/166cf5abdadae0a6e54de2c40f9baec7b7f7fc40

@thebravoman I attempted applying your patch and that had no effect on either the broken Refinery Admin (same missing Wymeditor assets errors ) or frontend.

However, this is an interesting nugget I ran into, prior to updating refinerycms from feature/rails5 SHA 53635cc9c4 to f8a1152f9 — it explicitly states

   <!-- Sprockets is unable to render this template if Refinery is installed -->
   <%= stylesheet_link_tag    'frontend/base', media: 'all' %>

Here's the full info.

F, [2017-04-08T04:45:51.764211 #25225] FATAL -- : [2a8a2516-4201-4540-b3ef-3c027b2d7b56] ActionView::Template::Error (Undefined variable: "$grid-gutter-width".):
F, [2017-04-08T04:45:51.764381 #25225] FATAL -- : [2a8a2516-4201-4540-b3ef-3c027b2d7b56]      7:
F, [2017-04-08T04:45:51.764467 #25225] FATAL -- : [2a8a2516-4201-4540-b3ef-3c027b2d7b56]      8:     <!-- Sprockets is unable to render this template if Refinery is installed -->
F, [2017-04-08T04:45:51.764527 #25225] FATAL -- : [2a8a2516-4201-4540-b3ef-3c027b2d7b56]      9:     <%= stylesheet_link_tag    'frontend/base', media: 'all' %>
F, [2017-04-08T04:45:51.764555 #25225] FATAL -- : [2a8a2516-4201-4540-b3ef-3c027b2d7b56]     10:     <%= javascript_include_tag 'application' %>
F, [2017-04-08T04:45:51.764578 #25225] FATAL -- : [2a8a2516-4201-4540-b3ef-3c027b2d7b56]     11:   </head>
F, [2017-04-08T04:45:51.764601 #25225] FATAL -- : [2a8a2516-4201-4540-b3ef-3c027b2d7b56]     12:
F, [2017-04-08T04:45:51.764613 #25225] FATAL -- : [2a8a2516-4201-4540-b3ef-3c027b2d7b56]     13:   <body>
F, [2017-04-08T04:45:51.764625 #25225] FATAL -- : [2a8a2516-4201-4540-b3ef-3c027b2d7b56]
F, [2017-04-08T04:45:51.764637 #25225] FATAL -- : [2a8a2516-4201-4540-b3ef-3c027b2d7b56] app/views/layouts/application.html.erb:10:in `_app_views_layouts_application_html_erb___2799836782624915161_70142477271720'

I decided to update the refinerycms dependency in my PoC since

  1. it was quite stale and
  2. having ag'd (silver searcher!) through multiple refinery dependencies I could not find any reference to SASS $grid-gutter-width.
bricesanchez commented 7 years ago

@bsodmike See https://github.com/refinery/refinerycms/commit/b2401c5b55e00594bf069e0c5f8e8edd4f4b2acf for the bug with $grid-gutter-width

thebravoman commented 7 years ago

how did you get around the lib/sprockets/cached_environment.rb:66:in 'config=': can't modify immutable cached environment (RuntimeError) issue?

@bsodmike - i can remember that I ran into this issue and somehow solved it, but can not remember how exactly.

bricesanchez commented 7 years ago

Hi all, could i do something to fix this problem?

bricesanchez commented 7 years ago

It should be fixed now: https://github.com/refinery/refinerycms/pull/3122/commits/96eb5910cf9b5ab5f002c95e800dbc2687355cd8