Skip to content
This repository has been archived by the owner. It is now read-only.

Cannot include assets without a file extension #347

Closed
DanielHeath opened this issue Jul 31, 2012 · 21 comments

Comments

Projects
None yet
@DanielHeath
Copy link
Contributor

commented Jul 31, 2012

Unpacking javascript libraries into vendor/assets results in an error "Asset logical path has no extension" when compiling assets.

This is an issue as many 3rd party javascript libraries include a 'LICENCE' file.

For the moment we can just delete those files each time we upgrade the library but ideally that wouldn't be necessary.

@gunn

This comment has been minimized.

Copy link

commented Sep 19, 2012

+1 also, adding .txt as an extension is another workaround.

@vollnhals

This comment has been minimized.

Copy link

commented Nov 7, 2012

any update on this issue?

this is affecting us hard as we have many 3rd party git submodules under vendor/assets/javascripts.

@gunn

This comment has been minimized.

Copy link

commented Nov 8, 2012

@vollnhals is it still a problem with edge sprockets?

@vollnhals

This comment has been minimized.

Copy link

commented Nov 12, 2012

i am using sprockets-2.8.1 and have this error. there are only two commits on top in master that do not change anything related.
or am i misunderstanding "edge sprockets"?

@josh

This comment has been minimized.

Copy link
Contributor

commented Feb 7, 2013

Nope.

@josh josh closed this Feb 7, 2013

@DanielHeath

This comment has been minimized.

Copy link
Contributor Author

commented Feb 7, 2013

Why was this closed? Doesn't sound like there was any resolution.

@ajacksified

This comment has been minimized.

Copy link

commented Feb 12, 2013

have a dependency
pull it in as a submodule or subtree
it has a Makefile

never be able to use sprockets unless I manually link to everything

Why is this a nofix? And what is

Nope.

supposed to mean?

@afeld

This comment has been minimized.

Copy link

commented Jun 4, 2013

For anyone needing a workaround, see the Rakefile addition here: https://gist.github.com/afeld/5704079

@wadetandy

This comment has been minimized.

Copy link

commented Oct 2, 2013

I'm guessing most people here are running into this problem while using the Rails asset pipeline. The default Rails configuration tells sprockets to compile all files that aren't JS or CSS, and then allows the developer to whitelist specific js and css assets. This is one of the reason your LICENSE files are getting pulled into the compilation phase. I found it was better to remove this setting and replace it with a more specific one that only whitelists the extensions that I want compiled:

initializer 'setup_asset_pipeline', :group => :all  do |app|
  # We don't want the default of everything that isn't js or css, because it pulls too many things in
  app.config.assets.precompile.shift

  # Explicitly register the extensions we are interested in compiling
  app.config.assets.precompile.push(Proc.new do |path|
    File.extname(path).in? [
      '.html', '.erb', '.haml',                 # Templates
      '.png',  '.gif', '.jpg', '.jpeg',         # Images
      '.eot',  '.otf', '.svc', '.woff', '.ttf', # Fonts
    ]
  end)
end
@ajacksified

This comment has been minimized.

Copy link

commented Oct 2, 2013

Nice fix, @wadetandy.

@DanielHeath

This comment has been minimized.

Copy link
Contributor Author

commented Oct 2, 2013

Perhaps rails should default to *.* instead of * in that case

carpeliam added a commit to pophealth/popHealth that referenced this issue Nov 14, 2013

wcch pushed a commit to wcch/pophealth53 that referenced this issue Nov 22, 2013

add extensions to filenames
this is a workaround for sstephenson/sprockets#347


Former-commit-id: 422f601

domcleal pushed a commit to domcleal/katello that referenced this issue Dec 10, 2013

Assets: Added extension to font-awesome license
Added extension to license to fix this error:

Asset logical path has no extension: font-awesome/LICENSE

It appears to be caused by sstephenson/sprockets#347

grauwoelfchen pushed a commit to grauwoelfchen/ruby-stylus that referenced this issue Jan 27, 2014

myabc added a commit to opf/openproject that referenced this issue Mar 21, 2014

Add workaround for asset precompilation failures
Extension-less files (e.g. READMEs) will cause Sprockets static
compilation (precompilation) to fail.

See issue: sstephenson/sprockets#347

Signed-off-by: Alex Coles <alex@alexbcoles.com>
@myabc

This comment has been minimized.

Copy link

commented Mar 23, 2014

Appears to occur with Rails 3.2.x and Sprockets 2.2.2.backport2. To reproduce:

rails _3.2.17_ new sprockets_fail
cd sprockets_fail
echo 'gem "sprockets", "2.2.2.backport2"' >> Gemfile
bundle update sprockets
touch app/assets/javascripts/README
bundle exec rake assets:precompile
@myabc

This comment has been minimized.

Copy link

commented Mar 23, 2014

Also reproducible issue with Rails 4.0.x and Sprockets (2.11.0).

rails _4.0.3_ new sprockets_fail
touch app/assets/javascripts/README
bundle exec rake assets:precompile

This appears to be a regression. Rails 3.2.x with latest supported (non-backported) Sprockets (2.2.2) does not appear to suffer from this issue.

myabc added a commit to opf/openproject that referenced this issue Mar 24, 2014

Configure whitelisting of assets to be precompiled
Replace default Rails configuration Proc with our own that checks
against a whitelist of extensions.

Poorly-built Bower components often include a number of files not
needed at runtime. This solution has the added benefit of keeping
non-essential files  (.gzip .map .json .md .php .sh .txt) from being
served to users.

This is an alternative solution to the one found in commit c0d7533
See issue: sstephenson/sprockets#347

Signed-off-by: Alex Coles <alex@alexbcoles.com>
@jrafanie

This comment has been minimized.

Copy link

commented Sep 4, 2014

@josh Is the recommendation to rename the assets so they have a file extension or to modify Rails to only precompile assets with specific file extensions, such as: https://gist.github.com/afeld/5704079 or how @myabc did it: opf/openproject@3d7ec71 . I'm not a license person but would some licenses prevent you from renaming a file to add an extension?

cc @myabc @DanielHeath I see some people went the route of renaming files or changing rails' default proc, I'm leaning towards the latter... what are your thoughts?

jrafanie added a commit to jrafanie/manageiq that referenced this issue Sep 4, 2014

Exclude files with no extension from precompiling.
https://bugzilla.redhat.com/show_bug.cgi?id=1135050

Fixes the issue precompiling assets with sprockets >= 2.4.4:
"Asset logical path has no extension: codemirror-4.2/AUTHORS"

See the reported upstream issue here[1].
The commit that started this issue is here [2].

This has been an issue in many versions of sprockets since v2.4.4:
v2.12.1  v2.12.0 v2.11.1 v2.11.0 v2.10.1 v2.10.0 v2.9.3 v2.9.2 v2.9.1 v2.9.0 v2.8.2 v2.8.1 v2.8.0 v2.7.0 v2.6.0 v2.5.0 v2.4.5 v2.4.4

The solutions found in [1] were to either:
a) rename assets to add a file extension (such as AUTHORS -> AUTHORS.txt)
b) modify the config.assets.precompile Proc to whitelist which file extensions that were desired or to exclude files without an extension.

[1] sstephenson/sprockets#347
[2] sstephenson/sprockets@5dbd7c6
@DanielHeath

This comment has been minimized.

Copy link
Contributor Author

commented Sep 5, 2014

Some licenses require you to send changes upstream; I'd shoot the project owners an email and call it done.

In Ruby projects where I hit a bug upstream, I typically write a monkey-patch over the bug.
This patch includes

  • The fix (directly re-writing the method from the original source).
  • A check on the version number of the upstream library (so that when I upgrade I can remove the patch).
@josh

This comment has been minimized.

Copy link
Contributor

commented Sep 5, 2014

I see some people went the route of renaming files or changing rails' default proc, I'm leaning towards the latter... what are your thoughts?

Yes. I mostly don't find Rails' default compile list to be very bower friendly. I have some potential ideas to move away from config.precompile entirely. See #626.

@jrafanie

This comment has been minimized.

Copy link

commented Sep 5, 2014

Thanks. I went with the less painful option for now, exclude files without an extension, but it feels like a choice I'll have to revisit as it doesn't feel right.

@loureirorg

This comment has been minimized.

Copy link

commented Feb 11, 2015

+1. Same problem here. I'm monkey-patching my no-extension files :/

elia added a commit to elia/sprockets-rails that referenced this issue Mar 17, 2015

Skip any assets without an extension
Sprockets 2.x dies with anything without an extension, 
READMEs from vendored assets are the most frequent offenders.

Fixes sstephenson/sprockets#347.

eavgerinos added a commit to Jarviis/Jarviis that referenced this issue Apr 10, 2015

Don't precompile extensionless file in Asset Pipeline
This is done because of a wontfix bug in Sprockets
sstephenson/sprockets#347

eavgerinos added a commit to Jarviis/Jarviis that referenced this issue Apr 10, 2015

Don't precompile extensionless file in Asset Pipeline
This is done because of a wontfix bug in Sprockets
sstephenson/sprockets#347

eavgerinos added a commit to Jarviis/Jarviis that referenced this issue Apr 10, 2015

Don't precompile extensionless file in Asset Pipeline
This is done because of a wontfix bug in Sprockets
sstephenson/sprockets#347

eavgerinos added a commit to Jarviis/Jarviis that referenced this issue Apr 10, 2015

Don't precompile extensionless file in Asset Pipeline
This is done because of a wontfix bug in Sprockets
sstephenson/sprockets#347
@cseelus

This comment has been minimized.

Copy link

commented May 15, 2015

+1

Also a problem with OSXs 'Icon\r' files used by Google Drive/Dropbox. See http://superuser.com/questions/298785/icon-file-on-os-x-desktop

@baweaver

This comment has been minimized.

Copy link

commented Feb 18, 2016

vitalets/angular-xeditable#426

Still a perpetual issue, and really not a fan of having to jump through multiple 'fixes' to resolve this every time it comes up. This needs to be fixed in the base code as a default option, not a configuration flag.

@mariohmol

This comment has been minimized.

Copy link

commented Feb 26, 2016

+1 same here

raj209 pushed a commit to raj209/PopHealth_Testing that referenced this issue Sep 26, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.