GoLand on macOS (17.x) without XCode developer tools

Completed

I am trying to avoid installing XCode Developer tools.

I can build my Go project without issues in a terminal.

However GoLand is looking for some other tool and triggering the “Please install developer tools” trap.

 

This is what happens if i try to build the project inside GoLand:

GOROOT=<path to go I set up in GoLand project settings> #gosetup
GOPATH=/Users/<my username>/go #gosetup
$GOROOT/bin/go build -o /Users/<...>/Library/Caches/JetBrains/GoLand2024.1/tmp/GoLand/___go_build_main_go__1_ /<path to project>/main.go #gosetup
# runtime/cgo
xcode-select: note: No developer tools were found, requesting install.
If developer tools are located at a non-default location on disk, use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, and cancel the installation dialog.
See `man xcode-select` for more details.
Compilation finished with exit code 1

The go build step works fine. i.e. GOROOT is set correctly.

However the next step tagged runtime/cgo fails.

Here's my question: what is that step doing? What binary does it try to invoke that is missing (and XCode D.T. would install)? 

0
3 comments

Answering my own question. The tool that triggers xcode-select is clang.

 

I have clang (and other tools) installed in a non-standard location (via nix). 

How can I add ~/.nix-profile/bin (which has clang, git, and more) to the PATH used by the IDE?

I spelunked the documentation but i could not find a way.

0

Managed to get GoLand to use nix and avoid XCode tools entirely!

Here's a recap of the settings that worked for me:

1. Set GOROOT to the full Nix store path (in my case: /nix/store/n1k6wf8q10q7k0863gb78b1rf0j07r7r-go-1.22.1/share/go/bin/go

2. Set GOPATH (Global) to /Users/myself/go

3. Enable Go Modules integration. 

In the Environment i set:

CC=clang
CXX=clang++
GCCGO=gccgo

In the System environment variables i added 2 entries as prefix to PATH:

/Users/myself/.nix-profile/bin:/nix/var/nix/profiles/default/bin:<original PATH here>

 

Now my project builds just fine in GoLand, and I avoided installing XCode Command Line tools entirely!

0

If you are reading this you may also want to use git from Nix (to avoid the warnings/prompt to install XCode tool)

Settings > Version Control > git > Path to Git executable: /Users/myself/.nix-profile/bin/git

0

Please sign in to leave a comment.