Skip to content

Instantly share code, notes, and snippets.

@dkdndes
Created December 9, 2020 17:12
Show Gist options
  • Save dkdndes/017e7b535653b27b15d2c787433c8932 to your computer and use it in GitHub Desktop.
Save dkdndes/017e7b535653b27b15d2c787433c8932 to your computer and use it in GitHub Desktop.
#!/bin/sh
# check if pyenv is available
# edit: fixed redirect issue in earlier version
if which pyenv >/dev/null 2>&1; then
# assumes default location of brew in `/usr/local/bin/brew`
/usr/bin/env PATH="${PATH//$(pyenv root)\/shims:/}" /usr/local/bin/brew "$@"
else
/usr/local/bin/brew "$@"
fi
@dkdndes
Copy link
Author

dkdndes commented Dec 9, 2020

Let pyenv play nice with Homebrew

If you run brew doctor, it might have some complaints.

$ brew doctor

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
./configure scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:

~/.pyenv/shims/python3.6m-config
~/.pyenv/shims/python3.7-config
~/.pyenv/shims/python3.7m-config
~/.pyenv/shims/python-config
~/.pyenv/shims/python3-config
~/.pyenv/shims/python3.6-config

If you do not solve this, any Python dependent package from Homebrew might be compiled against a Python version managed by pyenv. See the second trick to create a wrapper script to solve these issues.

Trick #2: A wrapper for brew

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment