Description
Bug report
Bug description:
This may be an odd edge case, and not sure what the "right" solution is...
If a user has "Desktop & Documents" folders synced with iCloud, and has more than one Mac, and different local usernames on each Mac, then virtual environments created on one Mac don't work on the other Mac.
It seems obvious now that I've dug into this that something would break in this scenario, but also, it wasn't immediately obvious to me why things were failing.
To recreate:
On Mac 1 with local-username-1 syncing "Documents" to iCloud Account:
~/Documents> python3 -m venv <venv_name>
~/Documents> cd <venv_name>
~/Documents/<venv_name> vim anything.py (write/save something)
~/Documents/<venv_name> source bin/activate
~/Documents/<venv_name> python anything.py (It runs!)
On Mac 2 with local-username-2 syncing "Documents" to SAME iCloud Account:
~/Documents> cd <venv_name>
~/Documents/<venv_name> source bin/activate
~/Documents/<venv_name> python anything.py (It fails, "command not found: python")
Possible fix(?):
Change the creation of the activate script so that the VIRTUAL_ENV export statement uses the "USERNAME" environment variable:
export VIRTUAL_ENV='/Users/'${USERNAME}'/Documents/venv_name
I tested this, and it worked for me. I've tried to think of other cases where this change might cause problems, and none come to mind. But I fully accept that this may have major issues I'm oblivious to. Thoughts?
CPython versions tested on:
3.13
Operating systems tested on:
macOS