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

Panic with hugo new if target folder is a symbolic link #9537

Closed
thomasjsn opened this issue Feb 21, 2022 · 7 comments
Closed

Panic with hugo new if target folder is a symbolic link #9537

thomasjsn opened this issue Feb 21, 2022 · 7 comments

Comments

@thomasjsn
Copy link

thomasjsn commented Feb 21, 2022

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.92.2-CDF6A0D6+extended linux/amd64 BuildDate=2022-02-11T14:17:39Z VendorInfo=gohugoio

Does this issue reproduce with the latest release?

Yes

The problem

hugo new fails if target folder is a symbolic link:

$ hugo new posts/drafts/test/index.md 
panic: [BUG] no Page found for "/home/hebron/dev/cavelab-blog/content/posts/drafts/test/index.md"

goroutine 1 [running]:
github.com/gohugoio/hugo/create.(*contentBuilder).applyArcheType(0xc000b76000, {0xc000b60a40, 0x40}, {0xc0005abc58, 0x8})
	/root/project/hugo/create/content.go:276 +0x354
github.com/gohugoio/hugo/create.(*contentBuilder).buildFile(0xc000b76000)
	/root/project/hugo/create/content.go:244 +0x1ad
github.com/gohugoio/hugo/create.NewContent.func1()
	/root/project/hugo/create/content.go:104 +0x297
github.com/gohugoio/hugo/create.NewContent(0xc000115550, {0x0, 0x0}, {0x7ffc6376e528, 0x9702e5})
	/root/project/hugo/create/content.go:108 +0x5fe
github.com/gohugoio/hugo/commands.(*newCmd).newContent(0xc0004fac90, 0xc00098ea00, {0xc00081eec0, 0x1, 0x0})
	/root/project/hugo/commands/new.go:83 +0x150
github.com/spf13/cobra.(*Command).execute(0xc00098ea00, {0xc00081ee90, 0x1, 0x1})
	/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc000996c80)
	/go/pkg/mod/github.com/spf13/cobra@v1.2.1/command.go:974 +0x3bc
github.com/gohugoio/hugo/commands.Execute({0xc00003c0a0, 0x2, 0x2})
	/root/project/hugo/commands/hugo.go:92 +0xb4
main.main()
	/root/project/hugo/main.go:23 +0x58

Target folder drafts is a symbolic link.

$ ls content/posts -l
...
lrwxrwxrwx  1 hebron hebron   43 Aug  3  2021 drafts -> '/home/hebron/notes/Second brain/blog/drafts'

The file content/posts/drafts/test/index.md does get created, but with the following content:

---
title: "Content Placeholder"
_build:
  render: never
  list: never
  publishResources: false
---

This used to work, but has been broken. Not entirely sure in what version it stopped working, but it may have been related to the following change:

Fix path resolution in hugo new 2b01c85 @bep #9129

@jmooring
Copy link
Member

Confirmed. Panic introduced with 9185e11.

@jmooring jmooring changed the title Hugo new fails if target folder is a symbolic link regression: Panic with hugo new if target folder is a symbolic link Feb 21, 2022
@bep bep changed the title regression: Panic with hugo new if target folder is a symbolic link Panic with hugo new if target folder is a symbolic link Mar 9, 2022
@bep bep modified the milestones: v0.94.0, v0.95.0, v0.96.0 Mar 9, 2022
@bep bep modified the milestones: v0.96.0, v0.97.0 Mar 24, 2022
@bep bep modified the milestones: v0.97.0, v0.98.0 Apr 13, 2022
@bep bep modified the milestones: v0.98.0, v0.99.0 Apr 28, 2022
@pandorasNox
Copy link

Run into the same issue, needed to write a workaround bash script facilitating mv.

@bep bep modified the milestones: v0.99.0, v0.100.0 May 24, 2022
@bep bep modified the milestones: v0.100.0, v0.101.0 May 31, 2022
@bep bep modified the milestones: v0.101.0, v0.102.0 Jun 16, 2022
@bep bep modified the milestones: v0.102.0, v0.103.0 Aug 28, 2022
@bep bep modified the milestones: v0.103.0, v0.104.0 Sep 15, 2022
@bep bep removed this from the v0.104.0 milestone Sep 23, 2022
@bep bep modified the milestones: v0.110.0, v0.111.0 Jan 26, 2023
@bep bep modified the milestones: v0.111.0, v0.112.0 Feb 15, 2023
@bep bep modified the milestones: v0.112.0, v0.113.0 Apr 15, 2023
@bep bep modified the milestones: v0.113.0, v0.115.0 Jun 13, 2023
@bep bep modified the milestones: v0.115.0, v0.116.0 Jun 30, 2023
@bep bep modified the milestones: v0.116.0, v0.117.0 Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 5, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@jmooring
Copy link
Member

Won't fix. See #11556.

@thomasjsn
Copy link
Author

Won't fix. See #11556.

@jmooring Just to clarify, is this the correct way to achieve the same result as my symbolic link — using module mount instead?

[module]
[[module.mounts]]
  source = '../../notes/Second brain/blog/drafts'
  target = 'content/posts/drafts'
[[module.mounts]]
  source = 'content'
  target = 'content'

It seems to work :)

@jmooring
Copy link
Member

is this the correct way

Yes. See https://gohugo.io/getting-started/directory-structure/#union-file-system.

@thomasjsn
Copy link
Author

is this the correct way

Yes. See https://gohugo.io/getting-started/directory-structure/#union-file-system.

Perfect, thank you. This is indeed a much better solution than the symbolic link.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants