How do I get Homebrew on Linux to preserve my PATH when building formulae?

188 Views Asked by At

I am trying to use Homebrew on Linux (Ubuntu 20.04) to install Swift Mint. I have installed swiftenv using Homebrew, and swift using swiftenv. In my .profile, I have included

export SWIFTENV_ROOT=/home/linuxbrew/.swiftenv
if which swiftenv > /dev/null; then eval "$(swiftenv init -)"; fi

to put swift in my PATH. Running echo $PATH gives

/home/linuxbrew/.swiftenv/shims:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/me/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

and which swift yields /home/linuxbrew/.swiftenv/shims/swift.

However, running brew install mint errors with

swift build --disable-sandbox -c release --arch arm64 --arch x86_64
make: swift: Command not found
make: *** [Makefile:18: build] Error 127

READ THIS: https://docs.brew.sh/Troubleshooting

To explore, I obtain a debug shell after the error with brew install --debug mint In the debug shell, running echo $PATH gives

/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/shims/linux/super:/usr/bin:/bin:/usr/sbin:/sbin

and which swift turns up nothing.

What am I supposed to do to pass /home/linuxbrew/.swiftenv/shims into brew so that this package can build? Ideally, the solution would allow me to run (the swiftenv part of) my .profile before building the formula so that I can avoid the possible fragility of swiftenv moving its shims directory.

0

There are 0 best solutions below