The problem
In a GoLand 2018.3 EAP run configuration, a Makefile run configuration finds thego
binary on macOS, but not on Ubuntu, causing make targets like this one to fail:
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:
So inded, 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