Open deronnax opened 3 months ago
If you're looking for a workaround you can set the SHELL
environment variable and userpath
will pick that up (i.e. the added --env
argument):
docker run --env 'SHELL=/bin/sh' -it --rm alpine:3.20 sh -c "apk add -v py3-pip && pip install --break-system-package userpath && userpath append /opt/brew"
this feels like a bug, the detect_shells
function: https://github.com/ofek/userpath/blob/981085be7669815a186420e1211ed9944ab928ba/userpath/interface.py#L95 will fail to detect the shell when:
SHELL
env var is not setIn this case it falls back to trying the default shells https://github.com/ofek/userpath/blob/981085be7669815a186420e1211ed9944ab928ba/userpath/shells.py#L4 which includes bash
. Maybe these default should be reduced to just sh
since that's defined in POSIX and is generally more likely to be available than bash
Another approach for unix
systems might be to try pw_shell
before falling back:
import os
import pwd
def shell_from_pwd():
try:
pw = pwd.getpwuid(os.getuid())
except KeyError:
return None
else:
return pw.pw_shell
Which should return /bin/sh
on Alpine Linux
Easily reproducible with docker:
I think it's a bug but I don't know. Anyway, it makes fail
pipx ensurepath
on Alpine linux.