# \[Snap\] Pipeline error with PostCSS (environment issue?)

**URL:** https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583
**Category:** support
**Created:** [August 14, 2018, 4:51pm UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583 "2018-08-14T16:51:52Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![jbandlow](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jbandlow/32/6657_2.png) [@jbandlow](https://discourse.gohugo.io/u/jbandlow)
#### Post date: [August 14, 2018, 4:51pm UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/1 "2018-08-14T16:51:52Z")

</div>

I’m trying to use

```auto
{{ $styles := resources.Get "style/main.scss" | resources.ToCSS | resources.PostCSS }}

```

but when I build, I get this error:

```bash
INFO 2018/08/14 09:25:25 postcss: use config file /home/jbandlow/Programming/web/followinggradients/postcss.config.js
/usr/bin/env: 'node': No such file or directory
ERROR 2018/08/14 09:25:25 error: failed to transform resource: exit status 127

```

If I remove the final pipe, everything works, and so I believe that the error is occurring when [this code](https://github.com/gohugoio/hugo/blob/ebe4d39f175f73e4f130972cb3d74ef0af5d5761/resource/postcss/postcss.go#L99) is calling the postcss script:

```bash
$ cat node_modules/postcss-cli/bin/postcss 
#!/usr/bin/env node

require('../')

```

I’ve installed post-css and autoprefixer with `npm install -D`, and the following works as expected:

```bash
node_modules/postcss-cli/bin/postcss static/main.css --config postcss.config.js 

```

On a lark, I even tried to run postcss from Go. With the following, `go run mytest.go` works as expected:

```auto
// mytest.go
package main

import (
        "fmt"
        "log"
        "os/exec"
)

func main() {
        out, err := exec.Command("node_modules/postcss-cli/bin/postcss", "static/main.css").Output()
        if err != nil {
                log.Fatal(err)
        }
        fmt.Printf("%s", out)
}

```

My Hugo environment:

```bash
$ hugo env
Hugo Static Site Generator v0.46/extended linux/amd64 BuildDate: 2018-08-01T13:25:43Z
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.10.3"

```

and for whatever it’s worth, it was installed via `snap`.

I can’t shake the feeling that I’m missing something really silly here, but if so, I just can’t see it. Does anyone have any ideas?

---

<div class="post-metadata">

### Author: ![jhabdas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jhabdas/32/6579_2.png) [@jhabdas](https://discourse.gohugo.io/u/jhabdas)
#### Post date: [August 14, 2018, 5:51pm UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/2 "2018-08-14T17:51:59Z")

</div>

Did you try to globally install the node deps as suggested in the code you linked to?

---

<div class="post-metadata">

### Author: ![jbandlow](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jbandlow/32/6657_2.png) [@jbandlow](https://discourse.gohugo.io/u/jbandlow)
#### Post date: [August 14, 2018, 6:21pm UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/4 "2018-08-14T18:21:08Z")

</div>

If `postcss-cli` and `autoprefixer` are installed both locally and globally, I get the same error. If they are only installed globally, I get

```bash
ERROR 2018/08/14 11:17:18 error: failed to transform resource: POSTCSS: failed to transform "style/main.css" (text/css): this feature is not available in your current Hugo version

```

---

<div class="post-metadata">

### Author: ![jhabdas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jhabdas/32/6579_2.png) [@jhabdas](https://discourse.gohugo.io/u/jhabdas)
#### Post date: [August 14, 2018, 6:35pm UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/5 "2018-08-14T18:35:25Z")

</div>

Not sure what Snap have you but you may have some luck bumping up to the [Node 8 LTS](https://nodejs.org/) if running an old version. Node deps are not well known for backwards compatibility. Use NVM to manage your Node version of you find yourself debugging compatability issues so you don’t pull your hair out.

_Please pardon my typos, I’m on a small screen_

---

<div class="post-metadata">

### Author: ![jbandlow](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jbandlow/32/6657_2.png) [@jbandlow](https://discourse.gohugo.io/u/jbandlow)
#### Post date: [August 14, 2018, 7:00pm UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/6 "2018-08-14T19:00:48Z")

</div>

@jhabdas Thanks for your suggestions. My system node (which I have been using) is v8.10.0, but I tried bumping it up to the LTS (v8.11.3) with nvm, and it didn’t make a difference.

---

<div class="post-metadata">

### Author: ![jhabdas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jhabdas/32/6579_2.png) [@jhabdas](https://discourse.gohugo.io/u/jhabdas)
#### Post date: [August 14, 2018, 7:34pm UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/7 "2018-08-14T19:34:46Z")

</div>

Oof. Based on that last error I’d suspect integration, package or regression given everything else you tried. Not sure how far you want to go but pulling the Hugo binary or trying a Docker build from source might be the next logical step.

---

<div class="post-metadata">

### Author: ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)
#### Post date: [August 14, 2018, 7:48pm UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/8 "2018-08-14T19:48:36Z")

</div>

> [@jbandlow](#):
>
> /usr/bin/env: ‘node’: No such file or directory

I have had that issue many moons ago in the Gulp world. I think this is resolved in newer Node version, but the above suggests a node binary mismatch. I think it _was called_ nodejs at some point – you will find tutorials online about creating symlinks from nodejs to node etc. But I suspect that a upgrade to a newer version of node will also resolve this.

---

<div class="post-metadata">

### Author: ![jbandlow](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jbandlow/32/6657_2.png) [@jbandlow](https://discourse.gohugo.io/u/jbandlow)
#### Post date: [August 14, 2018, 9:49pm UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/9 "2018-08-14T21:49:43Z")

</div>

@bep I’ve upgraded my system Node to v10.8.0 and npm to v6.2.0, and (as far as I’m aware) purged all older versions. It’s still the case that everything runs as expected if I run postcss from the command line, or from Gulp, or from my own hacked up Go program (see OP) – it’s only hugo that gives this error.

When I next have a moment, I’ll try building hugo from source in case this is some artifact of installing from snap – in the meantime I welcome any other suggestions of things to look at!

---

<div class="post-metadata">

### Author: ![jbandlow](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jbandlow/32/6657_2.png) [@jbandlow](https://discourse.gohugo.io/u/jbandlow)
#### Post date: [August 15, 2018, 2:04am UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/10 "2018-08-15T02:04:26Z")

</div>

Ok, I’m convinced this was related to details of my Snap installation of Hugo. There are subtleties around the security model (see [here](https://gohugo.io/getting-started/installing/#snap-package) and the related issue) that I don’t fully understand, but it appears that when running as a Snap I did not have **read** permission to `/usr/bin` or `/usr/local/bin`. For example, I was getting the following in `/var/syslog`:

```auto
Aug 14 18:28:52 pop-os kernel: [637475.173347] audit: type=1400 audit(1534296532.347:175): apparmor="DENIED" operation="open" profile="/snap/core/5145/usr/lib/snapd/snap-confine" name="/etc/pop-os/os-release" pid=7571 comm="snap-confine" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
Aug 14 18:28:52 pop-os kernel: [637475.175425] audit: type=1400 audit(1534296532.351:176): apparmor="DENIED" operation="open" profile="snap.hugo.hugo" name="/etc/pop-os/os-release" pid=7571 comm="snap-exec" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

```

I tried removing the snap and re-installing with `sudo snap install hugo --classic --channel=extended`, but I continued to get the same error. Removing the Snap and installing the 0.46-extended deb-file resolved the issue.

The snap behavior may or may not be a bug, but at this point I have a work-around and I’ve shaved enough yaks for today, so I don’t plan to dig any further. If more knowledgeable folks think it’s broken and would like more info, please tag me and I’d be happy to help.

Thanks all!

---

<div class="post-metadata">

### Author: ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)
#### Post date: [August 15, 2018, 6:58am UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/11 "2018-08-15T06:58:01Z")

</div>

I remember some permission issues related to Snap and the old Pygments integration, which is similar on the technical level. @anthonyfok may have more info.

---

<div class="post-metadata">

### Author: ![anthonyfok](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/anthonyfok/32/106_2.png) [@anthonyfok](https://discourse.gohugo.io/u/anthonyfok)
#### Post date: [August 18, 2018, 12:55pm UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/12 "2018-08-18T12:55:27Z")

</div>

@jbandlow Sorry for the troubles you experienced, and thank you for your detailed investigation.  
@bep Thank you for bringing this to my attention.

I have updated snapcraft.yaml to include nodejs (with /usr/bin/node) into the Hugo snap itself, like how we dealt with Pygments in the past, in commit [ef20ec1](https://github.com/gohugoio/hugo/commit/ef20ec1fbaa8f5841b3fbe18978d4d8c19d8fc53). It will be available with the next Hugo release (0.47.1 or 0.48). Hope it would remedy the situation.

---

<div class="post-metadata">

### Author: ![anthonyfok](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/anthonyfok/32/106_2.png) [@anthonyfok](https://discourse.gohugo.io/u/anthonyfok)
#### Post date: [August 24, 2018, 11:40pm UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/13 "2018-08-24T23:40:21Z")

</div>

Update: My previous commit [ef20ec1](https://github.com/gohugoio/hugo/commit/ef20ec1fbaa8f5841b3fbe18978d4d8c19d8fc53) did not actually fix the issue. Sorry for my inadequate testing.

But I am happy to announce that the very latest Hugo Snap, released today (Aug 24) with revision number 2599 (channel: extended), now comes with a working bin/node and works properly with a locally installed PostCSS installed with `npm install postcss-cli` without the `-g` flag. Fixes in commits [2c934be](https://github.com/gohugoio/hugo/commit/2c934be8ab01e18fc2f5c56c35a6957f2d7b3af3) and [66f688f](https://github.com/gohugoio/hugo/commit/66f688f7120560ca787c1a23e3e7fbc3aa617956).

---

<div class="post-metadata">

### Author: ![jbandlow](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jbandlow/32/6657_2.png) [@jbandlow](https://discourse.gohugo.io/u/jbandlow)
#### Post date: [August 29, 2018, 6:19pm UTC](https://discourse.gohugo.io/t/snap-pipeline-error-with-postcss-environment-issue/13583/14 "2018-08-29T18:19:01Z")

</div>

@anthonyfok I was able to give this a try today and it works great. Thanks so much!
