The problem
In a GoLand 2018.3 EAP run configuration, a Makefile run configuration finds the go
binary on macOS, but not on Ubuntu, causing make targets like this one to fail:
# Makefile
client/test.wasm: client/main.go # Building WASM
GOARCH=wasm GOOS=js go build -o client/test.wasm client/main.go
$ /usr/bin/make -f (some edited path)/Makefile
client/test.wasm/bin/sh: 1: go: not found
make: *** [client/test.wasm] Error 127
$
Simple enough to fix...
The diagnostic
On the command line, the same GOARCH=wasm GOOS=js go build -o client/test.wasm client/main.go
line works normally. Looks like a path issue in Goland or the plugin. Checking in the Makefile:
# Makefile
client/test.wasm: client/main.go
# "${PATH}"
# Building WASM
GOARCH=wasm GOOS=js go build -o client/test.wasm client/main.go
$ # Building WASM
make: *** [client/test.wasm] Error 127# "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
$
So indeed, on at least this version, the PATH is not taken into account. Let's fix this.
The solution
Of course, one could just add the Go bin path to the tasks in these targets, but this is uncalled for on other environments, so we can just remind GoLand to add this path to the run configuration.
- Edit the Run configuration
- Edit the
Environment variables
field - Add a definition for the
PATH
variable taken from anecho $PATH
on the command line - Apply and close
Oddities
As usual, Make has its own peculiar charm, requiring the variable name to use the braced format shown above instead of a plain $PATH
.
Trying to extend the PATH variable by just adding something like $PATH:/usr/local/go/bin
or ${PATH}:/usr/local/go/bin
won't work:
- in the first case, Make will receive the result of evaluation
$P
, then theATH
string, so other binaries beyond the ones in/usr/local/go/bin
will be missing - in the second case, Make detects a variable referencing itself and aborts the task
Top comments (0)