McShelby / hugo-theme-relearn

A theme for Hugo designed for documentation
https://mcshelby.github.io/hugo-theme-relearn/
MIT License
418 stars 185 forks source link

variant: avoid Hugo permission errors on build #831

Closed kamar535 closed 6 months ago

kamar535 commented 6 months ago

I've used the excellent Relearn theme before but now, I can only run hugo --renderToMemory server. Running hugo or hugo server fails due to permission denied errors.

Details and discussion here:

kamar535 commented 6 months ago

And here’s a failing minimal example as provided by jmooring in the the Hugo forums:

git clone --single-branch -b hugo-forum-topic-49335 https://github.com/jmooring/hugo-testing hugo-forum-topic-49335
cd hugo-forum-topic-49335
hugo server

This fails with:

ERROR Failed to publish Resource: open /home/jmooring/code/hugo-testing/public/css/theme-relearn-light.css: permission denied ERROR Failed to publish Resource: open /home/jmooring/code/hugo-testing/public/css/theme-relearn-dark.css: permission denied

More from jmooring:

If I vendor the module it works fine:

hugo mod vendor
hugo

This is just a clue as to what the problem might be. I am not recommending that you do this. You’d have to undo it to update the theme in the future (though undoing it just a matter of deleting the _vendor directory in the root of the project).

jmooring commented 6 months ago

See also:

Perhaps you can change the default behavior so that new users have a better experience.

McShelby commented 6 months ago

After three issues here, I can say that it's worth a change.

I had my reasons to do it this way, initially but it's not worth the resulting hassle for the users.

kamar535 commented 6 months ago

After reading the issues linked by @jmooring I've now tried:

1) Running hugo --noChmod but I still get the same permission errors.
2) But, setting themeVariantModifier = ".gen" in the [params] section in hugo.toml as described in the theme Configuration section of the theme Relearn documentation worked fine. I'm happy this workaround exists but at the same time appreciate that the root cause will be fixed in the next release of the Relearn theme.

McShelby commented 6 months ago

Just as an information: Fixing this will introduce a breaking change and will lead into a major release (in terms of semver).

Because I want to put some other breaking changes into this release, it will take a few days to wrap this up.

McShelby commented 6 months ago

I've pushed to main,

@kamar535 Could you give it another try? Some other stuff changed, may requiring additional changes by you: https://mcshelby.github.io/hugo-theme-relearn/basics/migration/index.html#600

McShelby commented 6 months ago

I checked with the latest head of the theme and jmoorings example by modifying the commands to

git clone --single-branch -b hugo-forum-topic-49335 https://github.com/jmooring/hugo-testing hugo-forum-topic-49335
cd hugo-forum-topic-49335
hugo mod get -u
hugo server

As this now works without any issues, I hope it's resolved.