Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude Sprockets 4 manifest.js by default #48

Open
amiuhle opened this issue Oct 24, 2016 · 15 comments
Open

Exclude Sprockets 4 manifest.js by default #48

amiuhle opened this issue Oct 24, 2016 · 15 comments

Comments

@amiuhle
Copy link

amiuhle commented Oct 24, 2016

Using Sprockets 4.0.0.beta4, I got the error below when trying to deploy. In development, everything worked fine, and adding exclude: ['vendor/bundle', 'app/assets/config'] in the initializer helped.

URI::InvalidURIError: expected file:// scheme:
/path/to/app/releases/20161024082816/app/assets/config/manifest.js:2
/path/to/app/shared/bundle/ruby/2.3.0/gems/sprockets-4.0.0.beta4/lib/sprockets/uri_utils.rb:95:in `parse_asset_uri'
/path/to/app/shared/bundle/ruby/2.3.0/gems/sprockets-4.0.0.beta4/lib/sprockets/unloaded_asset.rb:136:in `load_file_params'
/path/to/app/shared/bundle/ruby/2.3.0/gems/sprockets-4.0.0.beta4/lib/sprockets/unloaded_asset.rb:65:in `params'
/path/to/app/shared/bundle/ruby/2.3.0/gems/sprockets-4.0.0.beta4/lib/sprockets/loader.rb:33:in `load'
/path/to/app/shared/bundle/ruby/2.3.0/gems/sprockets-4.0.0.beta4/lib/sprockets/cached_environment.rb:21:in `block in initialize'
/path/to/app/shared/bundle/ruby/2.3.0/gems/sprockets-4.0.0.beta4/lib/sprockets/cached_environment.rb:48:in `load'
/path/to/app/shared/bundle/ruby/2.3.0/gems/sprockets-commoner-0.6.3/lib/sprockets/commoner/bundle.rb:71:in `block in call'
/path/to/app/shared/bundle/ruby/2.3.0/gems/sprockets-commoner-0.6.3/lib/sprockets/commoner/bundle.rb:65:in `map'
/path/to/app/shared/bundle/ruby/2.3.0/gems/sprockets-commoner-0.6.3/lib/sprockets/commoner/bundle.rb:65:in `call'
/path/to/app/shared/bundle/ruby/2.3.0/gems/sprockets-commoner-0.6.3/lib/sprockets/commoner/bundle.rb:54:in `call'

app/assets/config/manifest.js:

//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
@schneems
Copy link

schneems commented Nov 8, 2016

Ping, any ideas here, could there be a problem in this gem? Does shopify still use this gem? cc/ @bouk @TylerHorth

@rafaelfranca
Copy link
Member

Weird. We do use this gem and we also use the manifest file even with sprockets 3 and we don't see this error in our application. Maybe something changed in sprockets or sprockets-rails that is including the manifest file in the bundle?

@bouk
Copy link
Contributor

bouk commented Nov 8, 2016

Yes, we still use this gem but I don't think we currently have an application that's being deployed with it and Sprockets 4

@amiuhle could you provide some more information on when this happens and what your application looks like? I assumed this would happen when precompiling the assets, but I can't reproduce it

@schneems
Copy link

schneems commented Nov 8, 2016

The issue seems to be cache related. The problem only happens on the second push. I'm shooting in the dark here, but maybe shopify deploys with the same absolute path to the cache? Versus this app is running on Heroku and gets a different path on each deploy.

@TylerHorth
Copy link
Contributor

# sprockets/uri_utils.rb
    def parse_asset_uri(uri)
      scheme, _, path, query = split_file_uri(uri)

      unless scheme == 'file'
        raise URI::InvalidURIError, "expected file:// scheme: #{uri}"
      end

      return path, parse_uri_query_params(query)
    end

Might be worth throwing a debugger in there and seeing what the uri is before the exception is raised. Might give us some hints towards what is actually going wrong here.

@amiuhle
Copy link
Author

amiuhle commented Nov 9, 2016

I just tried to reproduce this, but couldn't... I don't think it's worth putting any more effort into this, at least if someone else has the same problem, they'll find the workaround above.

If you agree, you can close this. Thanks for the feedback!

@schneems
Copy link

@TylerHorth uri is in the exception output alread. I think it's either false or nil or empty string:

raise URI::InvalidURIError, "expected file:// scheme: #{uri}"
# => "URI::InvalidURIError: expected file:// scheme: "

@TylerHorth
Copy link
Contributor

Ah. You're right, I missed that. It's probably nil since that's what resolve returns when a file cant be found.

I don't have enough knowledge of commoner to make a guess as to what could have gone wrong, but if it can no longer be reproduced it's probably not worth more investigation.

@dimroc
Copy link

dimroc commented Mar 10, 2017

I just ran into this issue and I'm wondering if it's related to an issue I ran into here:
rails/sprockets#451

@dimroc
Copy link

dimroc commented Mar 10, 2017

remote:        URI::InvalidURIError: expected file:// scheme:
remote:        /tmp/build_02fbcf7b380e429bf9912ee9e770601c/app/assets/config/manifest.js:1
remote:        /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/uri_utils.rb:94:in `parse_asset_uri'
remote:        /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/unloaded_asset.rb:134:in `load_file_params'
remote:        /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/unloaded_asset.rb:64:in `params'
remote:        /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:34:in `load'
remote:        /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
remote:        /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
remote:        /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-commoner-0.6.4/lib/sprockets/commoner/bundle.rb:70:in `block in call'
remote:        /tmp/build_02fbcf7b380e429bf9912ee9e770601c/vendor/bundle/ruby/2.4.0/gems/sprockets-commoner-0.6.4/lib/sprockets/commoner/bundle.rb:64:in `map'

Full stack here: https://gist.github.com/dimroc/7cedcf211e966fb1065b18ce3313fc79

@bouk
Copy link
Contributor

bouk commented Mar 10, 2017

Ohhh I just realized we don't run into this because our manifest.js is not included in our commoner compilation. I can probably reproduce this now

@dimroc
Copy link

dimroc commented Mar 10, 2017

I've never run into this locally, only when deploying to Heroku. For anyone else that stumbles into this, you can get by with heroku repo:purge_cache. But that might be a temporary fix.

@ian
Copy link

ian commented Mar 15, 2017

Same problem over here. @dimroc's solution works everytime for me as a crutch. Is there a more permanent solution that anyone has found?

@dimroc
Copy link

dimroc commented Mar 30, 2017

For anyone else frustrated by this, I got around the problem by not using the new manifest.js and returning to the initializers/assets.rb way of doing things. sprockets-commoner works fine in that scenario.

Rails.application.config.assets.version = '1.1.5'
Rails.application.config.assets.precompile += [
  %w{client.js vendor.js},
  %w{admin.css dealership.css}
].flatten

@xuanchien
Copy link

xuanchien commented Oct 31, 2018

Got this issue today and @dimroc's solution worked. But we need to install Heroku Repo plugin first

https://github.com/heroku/heroku-repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants