Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Cannot include assets without a file extension #347

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

Cannot include assets without a file extension #347

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

Comments

@DanielHeath
Copy link
Contributor

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
Copy link

gunn commented Sep 19, 2012

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

@vollnhals
Copy link

any update on this issue?

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

@gunn
Copy link

gunn commented Nov 8, 2012

@vollnhals is it still a problem with edge sprockets?

@vollnhals
Copy link

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
Copy link
Contributor

josh commented Feb 7, 2013

Nope.

@josh josh closed this as completed Feb 7, 2013
@DanielHeath
Copy link
Contributor Author

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

@ajacksified
Copy link

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
Copy link

afeld commented Jun 4, 2013

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

@wadetandy
Copy link

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
Copy link

Nice fix, @wadetandy.

@DanielHeath
Copy link
Contributor Author

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
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
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
Extension-less files (e.g. READMEs) will cause Sprockets static
compilation (precompilation) to fail.

See issue: sstephenson/sprockets#347

Signed-off-by: Alex Coles <[email protected]>
@myabc
Copy link

myabc 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
Copy link

myabc 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
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 <[email protected]>
@jrafanie
Copy link

jrafanie 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
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
Copy link
Contributor Author

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
Copy link
Contributor

josh 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
Copy link

jrafanie 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
Copy link

+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
Sprockets 2.x dies with anything without an extension, 
READMEs from vendored assets are the most frequent offenders.

Fixes sstephenson/sprockets#347.
avgerin0s added a commit to Jarviis/Jarviis that referenced this issue Apr 10, 2015
This is done because of a wontfix bug in Sprockets
sstephenson/sprockets#347
avgerin0s added a commit to Jarviis/Jarviis that referenced this issue Apr 10, 2015
This is done because of a wontfix bug in Sprockets
sstephenson/sprockets#347
avgerin0s added a commit to Jarviis/Jarviis that referenced this issue Apr 10, 2015
This is done because of a wontfix bug in Sprockets
sstephenson/sprockets#347
avgerin0s added a commit to Jarviis/Jarviis that referenced this issue Apr 10, 2015
This is done because of a wontfix bug in Sprockets
sstephenson/sprockets#347
@cseelus
Copy link

cseelus 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
Copy link

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
Copy link

+1 same here

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

No branches or pull requests