In a GoLand make
run config, tasks defined in the Makefile
correctly find
the go
binary on macOS, but not on Ubuntu, causing errors like this one :
|
|
|
|
Let’s fix this…
The diagnosing process
Let’s check how the same command behaves when run on the command line:
|
|
No error, compile works normally. So it has to be an issue with GoLand or the
make
plugin.
Let’s check the Makefile
:
|
|
|
|
So, at least on that version, the run configuration ignores the PATH
variable
environment variable. This is easy to fix.
The fix
A simple fix would just add the Go binaries directory to the Make tasks (i.e.
modify the Makefile
) but, since this is not needed on other environments, better
just tell GoLand to add the path to the run configuration instead of the Makefile
.
- Run
echo $PATH
on the command line. - Modify the relevant run configuration.
- In the run configuration dialog, modify the
Environment variables
field - Add one row for the
PATH
environment variable, copied and pasted from the output of the first step. - Click
Apply
and close the dialog.
make
oddities
As usual, make
has its own peculiar charm: it requires the name of the variable
to be within braces to be recognized, instead of just using $PATH
.
Trying to modify the PATH
variable by expanding it with something like
$PATH:/usr/local/go/bin
or ${PATH}:/usr/local/go/bin
instead of copy/pasting
the value does not work :
- with the former,
make
receives the evaluated result of$P
, then concatenates theATH
string to that result, causing binaries in all directories except/usr/local/go/bin
to become unavailable. - with the latter,
make
detects a self-referencing variable, and cancels the task.