Skip to content

Commit 0a9d6b6

Browse files
committed
Add more candidate directories to be added to $PATH
- Check for `~/homebrew/bin` and `~/homebrew/sbin` to cope when homebrew is installed in a user's home directory. Closes #28 - While we're in there, check for `/usr/local/sbin`, `/opt/homebrew/sbin`, `/opt/local/sbin`, `~/bin` and `~/sbin` directories too. Signed-off-by: Joe Block <[email protected]>
1 parent 1ea4d93 commit 0a9d6b6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lima-plugin

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,26 @@ def prep_environment_for_lima(vm: str = "default", env: dict = dict(os.environ))
270270
"""
271271
Set up an environment dictionary we can use to run a lima command.
272272
273-
Also adds /usr/local/bin, /opt/homebrew/bin and /opt/local/bin to $PATH
274-
if they exist and are directories.
273+
Also adds /usr/local/{s}bin, /opt/homebrew/{s}bin, /opt/local/{s}bin,
274+
~/homebrew/{s}bin and ~/{s}bin to $PATH if they exist and are directories.
275275
276276
:param str vm: VM to work in
277277
:param dict env: Environment variables to base returned environment on
278278
279279
:return dict: Environment dictionary, with extra bindirs added to $PATH
280280
"""
281-
extrapaths = ["/usr/local/bin", "/opt/homebrew/bin", "/opt/local/bin"]
281+
extrapaths = [
282+
"/opt/homebrew/bin",
283+
"/opt/homebrew/sbin",
284+
"/opt/local/bin",
285+
"/opt/local/sbin",
286+
"/usr/local/bin",
287+
"/usr/local/sbin",
288+
f"{os.environ.get('HOME')}/bin",
289+
f"{os.environ.get('HOME')}/homebrew/bin",
290+
f"{os.environ.get('HOME')}/homebrew/sbin",
291+
f"{os.environ.get('HOME')}/sbin",
292+
]
282293
for p in extrapaths:
283294
if os.path.isdir(p):
284295
logging.info("Adding %s to $PATH", p)

0 commit comments

Comments
 (0)