bernardo-bruning / ollama-copilot

Proxy that allows you to use ollama as a copilot like Github copilot
MIT License
342 stars 23 forks source link

Build Error on macOS Big Sur #13

Closed shahrokh-bahtooei closed 3 months ago

shahrokh-bahtooei commented 3 months ago

Building this on macOS Big Sur 11.7.10 raises this error:

% go install github.com/bernardo-bruning/ollama-copilot@latest
# runtime/cgo
_cgo_export.c:3:10: fatal error: 'stdlib.h' file not found

Xcode Command Line Tools is already up-to-date, and this is the version for clang:

% clang -v                                                    
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Isn't it possible to run it on Docker instead?

shahrokh-bahtooei commented 3 months ago

The problem still was with C clang installation using Xcode Command Line Tools, not with Go as hinted in this comment: https://github.com/golang/go/issues/39232#issuecomment-633641304

Using ChatGPT-4o, I could finally troubleshoot this annoying error in these steps:

% sudo rm -rf /Library/Developer/CommandLineTools
% xcode-select --install

Then

% sudo softwareupdate --install --all

Then adding these lines to ~/.zshrc:

export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
export CPATH=$SDKROOT/usr/include:/Library/Developer/CommandLineTools/usr/include/c++/v1

and restarting the terminal.