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

Panic on resource publish when mkdir: file name is too long #4240

Closed
biodranik opened this Issue Jan 8, 2018 · 9 comments

Comments

Projects
None yet
2 participants
@biodranik
Contributor

biodranik commented Jan 8, 2018

I'm using Mac OS X 10.13.2. This is content which causes bug:

content/news/folder/index.md
content/news/folder/image.jpg

Detailed bug description is below:

---
# This is frontmatter of content/news/folder/index.md
# This long slug crashes hugo if any image is copied into content/news/folder/
# The shorter version of the slug with an image generates percent-encoded path for the image together with a correctly utf-8-encoded path for the index.html file.
# This and shorter slugs work correctly without image in content/news/folder/
slug: очень-длинная-строка-для-того-чтобы-крешнуть-самый-лучший-статический-генератор
---

I see at least two erors:

  • Percent-encoded paths for Russian slug instead of normal utf-8 paths without any images in /folder/
  • Secondary error mkdir: file name is too long
2018/01/08 22:02:25 mkdir /Users/alex/Developer/projects/landing-hugo/docs/ru/news/2017/08/%D0%B8%D1%81%D0%BF%D1%8B%D1%82%D0%B0%D0%BD%D0%B8%D1%8F-%D0%B2%D0%B8%D0%B1%D1%80%D0%BE%D0%B4%D0%B8%D0%B0%D0%B3%D0%BD%D0%BE%D1%81%D1%82%D0%B8%D0%BA%D0%B8-vibrobox-%D0%BD%D0%B0-%D0%BF%D1%80%D0%B5%D0%B4%D0%BF%D1%80%D0%B8%D1%8F%D1%82%D0%B8%D0%B8-%D0%BF%D0%BE-%D0%BF%D1%80%D0%BE%D0%B8%D0%B7%D0%B2%D0%BE%D0%B4%D1%81%D1%82%D0%B2%D1%83-%D0%B0%D0%B2%D1%82%D0%BE%D0%BC%D0%BE%D0%B1%D0%B8%D0%BB%D0%B5%D0%B9-geely-%D0%B2-%D0%B1%D0%B5%D0%BB%D0%B0%D1%80%D1%83%D1%81%D0%B8: file name too long
panic: mkdir /Users/alex/Developer/projects/landing-hugo/docs/ru/news/2017/08/%D0%B8%D1%81%D0%BF%D1%8B%D1%82%D0%B0%D0%BD%D0%B8%D1%8F-%D0%B2%D0%B8%D0%B1%D1%80%D0%BE%D0%B4%D0%B8%D0%B0%D0%B3%D0%BD%D0%BE%D1%81%D1%82%D0%B8%D0%BA%D0%B8-vibrobox-%D0%BD%D0%B0-%D0%BF%D1%80%D0%B5%D0%B4%D0%BF%D1%80%D0%B8%D1%8F%D1%82%D0%B8%D0%B8-%D0%BF%D0%BE-%D0%BF%D1%80%D0%BE%D0%B8%D0%B7%D0%B2%D0%BE%D0%B4%D1%81%D1%82%D0%B2%D1%83-%D0%B0%D0%B2%D1%82%D0%BE%D0%BC%D0%BE%D0%B1%D0%B8%D0%BB%D0%B5%D0%B9-geely-%D0%B2-%D0%B1%D0%B5%D0%BB%D0%B0%D1%80%D1%83%D1%81%D0%B8: file name too long


goroutine 27 [running]:
log.Panicln(0xc420ccb900, 0x1, 0x1)
	/usr/local/Cellar/go/1.9.2/libexec/src/log/log.go:340 +0xc0
github.com/gohugoio/hugo/vendor/github.com/spf13/afero.WriteReader(0x2b07360, 0x2b8ce00, 0xc4210ba000, 0x22e, 0x2afb0e0, 0xc4208739e8, 0x2afb1a0, 0xc420e80d20)
	/private/tmp/hugo-20180108-44182-1t9hvji/hugo-0.32.3/src/github.com/gohugoio/hugo/vendor/github.com/spf13/afero/util.go:49 +0x24f
github.com/gohugoio/hugo/helpers.WriteToDisk(0xc4210ba000, 0x22e, 0x2afb0e0, 0xc4208739e8, 0x2b07360, 0x2b8ce00, 0x0, 0xc420f8b480)
	/private/tmp/hugo-20180108-44182-1t9hvji/hugo-0.32.3/src/github.com/gohugoio/hugo/helpers/path.go:532 +0x5d
github.com/gohugoio/hugo/resource.(*genericResource).Publish(0xc4212a1570, 0x0, 0x0)
	/private/tmp/hugo-20180108-44182-1t9hvji/hugo-0.32.3/src/github.com/gohugoio/hugo/resource/resource.go:272 +0x1da
github.com/gohugoio/hugo/hugolib.(*PageOutput).renderResources(0xc420f8b440, 0xc420ffc0a0, 0x1a61b01)
	/private/tmp/hugo-20180108-44182-1t9hvji/hugo-0.32.3/src/github.com/gohugoio/hugo/hugolib/page_output.go:294 +0xd1
github.com/gohugoio/hugo/hugolib.pageRenderer(0xc42035b8c0, 0xc420c7a840, 0xc420c7a7e0, 0xc421535fe0)
	/private/tmp/hugo-20180108-44182-1t9hvji/hugo-0.32.3/src/github.com/gohugoio/hugo/hugolib/site_render.go:115 +0xa29
created by github.com/gohugoio/hugo/hugolib.(*Site).renderPages
	/private/tmp/hugo-20180108-44182-1t9hvji/hugo-0.32.3/src/github.com/gohugoio/hugo/hugolib/site_render.go:45 +0x153
@bep

This comment has been minimized.

Member

bep commented Jan 8, 2018

slug: очень-длинная-строка-для-того-чтобы-крешнуть-самый-лучший-статический-генератор

Does it crash if you make the above ... short?

@bep bep added the Bug label Jan 8, 2018

@biodranik

This comment has been minimized.

Contributor

biodranik commented Jan 8, 2018

No, but incorrectly generates percent-encoded path, as I described in comments to the slug.

@bep

This comment has been minimized.

Member

bep commented Jan 8, 2018

No, but incorrectly generates percent-encoded path,

Can you create a separate issue for that.

@bep bep changed the title from Crash and percent encoding of path from slug in non-ascii alphabet when using .Resources to Panic on resource publish when mkdir: file name is too long Jan 8, 2018

@bep bep added this to the v0.33 milestone Jan 8, 2018

@bep

This comment has been minimized.

Member

bep commented Jan 8, 2018

The fix for this particular issue is to not panic, i.e. return a proper error that gets logged. The "filename too long" is OS dependent and not something we want to validate.

@biodranik

This comment has been minimized.

Contributor

biodranik commented Jan 8, 2018

Just checked, /bin/mkdir has a hard-coded limit of 256 characters in the path on Mac OS X 10.13

@biodranik

This comment has been minimized.

Contributor

biodranik commented Jan 8, 2018

However, this panic is a minor issue, the major one is that any .Resource generates an incorrect percent-encoded path.

@bep

This comment has been minimized.

Member

bep commented Jan 8, 2018

Howewer, this panic is a minor issue, the major one is that any .Resource generates an incorrect percent-encoded path.

Sure. But you use an ascii slug and it will work.

@biodranik

This comment has been minimized.

Contributor

biodranik commented Jan 8, 2018

It's inconsistent with alias in FrontMatter which correctly generates UTF-8 encoded folders for index.html. Why does slug use percent-encoding but alias does not?

@biodranik

This comment has been minimized.

Contributor

biodranik commented Jan 8, 2018

No, it is even worse: alias and slug work in the same way (correctly) without any images in subsection (.Page.Resource), but if you put any image slug stops working.

@bep bep modified the milestones: v0.33, v0.34 Jan 11, 2018

bep added a commit to spf13/afero that referenced this issue Jan 15, 2018

@bep bep closed this in f8a119b Jan 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment