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

Differentiate error messages between "PostCSS not found" and "libSass not compiled in" #5111

Closed
anthonyfok opened this issue Aug 24, 2018 · 4 comments · Fixed by #5114
Closed
Labels

Comments

@anthonyfok
Copy link
Member

As of 0.47.1, according to Transform() in resource/postcss/postcss.go, when Hugo cannot find the executable "postcss" in "node_modules/postcss-cli/bin/" (fetched via npm install postcss-cli without the -g flag) or in the PATH, it would show errors.FeatureNotAvailableErr, i.e.:

this feature is not available in your current Hugo version

resulting in, for example:

ERROR 2018/08/24 00:46:39 error: failed to transform resource: POSTCSS: failed to transform "styles/main.css" (text/css): this feature is not available in your current Hugo version

which is slightly misleading for the end user because the correct solution is not to look for another Hugo version (extended or not), but to have PostCSS (postcss-cli) installed properly so that Hugo can find it.

I hesitate to change the error message directly because errors.FeatureNotAvailableErr is also used, accurately, when libSass is not compiled in. I thought of creating another error message altogether, but hesitated when I realized that in resource/transform.go errors.FeatureNotAvailableErr is used as a check.

So, yes, I thought I should ask you (bep) first how to best approach this issue. :-)

Admittedly, a very minor issue, and non-urgent. Thanks in advance for looking into this!

P.S. I came across this when I finally tested my recent changes to snapcraft.yaml going into 0.47.1, and discovered that my fix didn't work. (Oops, sorry!) First of all, I inadvertently deleted the "usr/bin/nodejs" binary in the clean-up, and secondly, it was a rather old v4 version that got installed as "usr/bin/nodejs" instead of "usr/bin/node". A fix for that will be ready soon, by using the "nodejs" plugin in Snap.

@anthonyfok
Copy link
Member Author

ERROR 2018/08/24 00:46:39 error: failed to transform resource: POSTCSS: failed to transform "styles/main.css" (text/css): this feature is not available in your current Hugo version

which is slightly misleading for the end user

Just to clarify: what I meant is that I got confused myself, recalling that the PostCSS feature is not tied to the "extended" Hugo version, and I had to git grep for the error message and eventually found the check for "postcss" binary in resource/postcss/postcss.go. It is easy for Go developers to check for this, but the novice end user might not know that npm install -g postcss-cli (as documented in the comments) is the solution.

This is actually documented at https://gohugo.io/hugo-pipes/postcss/, though the actual npm command isn't given. I think I will expand that page a bit, especially the caveat that apparently Snap-based Hugo cannot find globally installed node.js modules.

@bep
Copy link
Member

bep commented Aug 24, 2018

I suggest you make this simple. If you locate the place this error is logged, you can just check the variable where "POSTCSS" is fetched -- you can consider that value to be stable.

@anthonyfok
Copy link
Member Author

I suggest you make this simple. If you locate the place this error is logged, you can just check the variable where "POSTCSS" is fetched -- you can consider that value to be stable.

Thank you for your great advice! I have made a PR in #5114.

Meanwhile, I have also expanded a little bit on https://gohugo.io/hugo-pipes/postcss/ in gohugoio/hugoDocs@64b9ecc.

@github-actions
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 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants