ublue-os / config

A layer to provide configuration files (udev rules, service units, etc)
https://universal-blue.org
Apache License 2.0
38 stars 26 forks source link

Brew leads to mixed up python paths #260

Open Libretto7 opened 2 months ago

Libretto7 commented 2 months ago

Using brew to install a python program also installs python3 and pip3 into /home/linuxbrew/.linuxbrew/ . But there's also a python(3) and pip(3) on the host.

The problem is that when the user uses the commands python or pip, it defaults to the programs installed on the host and when the user uses python3 or pip3 the programs of the brew install get used.

So if you want to use python without spinning up a distrobox (which should be possible), the different paths can lead to confusion. For example:

The brew python should not be in PATH as it is just a dependency of brew programs and should not be used directly. pip3 install also tells you that this pip (the brew one) should not be used.

m2Giles commented 2 months ago

If you want to always have system python and pip being used when using an interactive shell:

You can add them to the beginning of PATH as part of your bashrc. They will then have precedence over the python installed by brew

castrojo commented 2 months ago

Ok so I just tested this. If we do a brew unlink python it removes the python stuff from the path, just for python, seems like a clean solution. I was able to still install and run python apps installed from brew, and it seems to be defaulting to the system python afaict.

This seems like a good default to go with, it'd be weird if python behaved different on a ublue system than a fedora one.

m2Giles commented 2 months ago

we can also put Brew at the end of PATH so we defer to system binaries.

The unlink will relink after the next upgrade I believe

marcoceppi commented 2 months ago

Putting it at the end of the path means if I brew install Python for myself I won't get it as expected. If a brew installed software requires Python brew shouldn't be doing the brew link for Python that feels like a brew issue