Repository navigation
failing to source virtualenvwrapper on alpine linux (ash) #105
Description
Activity
May be the same issue as with fish shell however I've not tried it there. Just guessing from the surrounding code.
#100${.sh.file}is ksh syntax, but ksh support was dropped in commit d736549 so that branch probably should've been taken out too.That still won't help your shell, though, because without a default
VIRTUALENVWRAPPER_SCRIPTwon't get set.Really, using
$0should probably be the default -- that will even work in Bash, under most cases, although$BASH_SOURCEis certainly better if it's available.Although, interestingly, when sourcing a script it seems that
$0is the ONLY thing that works for Zsh, and$BASH_SOURCEis the only thing that works for Bash.so I guess the first question is, if you save this script to a file
test_arg0.sh:echo "0: $0" echo "BASH_SOURCE: ${BASH_SOURCE}" echo "ZSH_ARGZERO: ${ZSH_ARGZERO}" echo "ZSH_SCRIPT: ${ZSH_SCRIPT}" # Feel free to add any additional variables # your shell's documentation indicates might be useful.
Then what do you get in
ashfor each of these scenarios?- (At any shell prompt):
ash test_arg0.sh
- (At an
ashshell prompt):source test_arg0.sh
Here's what I get
Zsh
$ zsh test_arg0.sh 0: test_arg0.sh BASH_SOURCE: ZSH_ARGZERO: test_arg0.sh ZSH_SCRIPT: test_arg0.sh $ source test_arg0.sh 0: test_arg0.sh BASH_SOURCE: ZSH_ARGZERO: zsh ZSH_SCRIPT:Bash
$ bash test_arg0.sh 0: test_arg0.sh BASH_SOURCE: test_arg0.sh ZSH_ARGZERO: ZSH_SCRIPT: $ source test_arg0.sh 0: bash BASH_SOURCE: test_arg0.sh ZSH_ARGZERO: ZSH_SCRIPT:- (At any shell prompt):
- added a commit that references this issue
on Mar 24, 2025 May be the same issue as with fish shell however I've not tried it there. Just guessing from the surrounding code.
#100I don't think fish is ever gonna work. It dumps out with an error anytime a variable reference uses curly braces! (What are they THINKING??)
$ source test_arg0.sh test_arg0.sh (line 2): Variables cannot be bracketed. In fish, please use "$BASH_SOURCE". echo "BASH_SOURCE: ${BASH_SOURCE}"
I think there's an alternative implementation for fish.
I've never heard of the ash shell. If its syntax can be supported without breaking anything, I could review patches.
- added a commit that references this issue
on Mar 31, 2025 - added a commit that references this issue
on Mar 31, 2025 I just remembered that alpine publishes docker containers, which makes it really easy to test the
ashshell on a different system. So...$ docker pull alpine:latest $ docker run -t -i alpine:latest /bin/ash / # cat > test_arg0.sh echo "0: $0" echo "BASH_SOURCE: ${BASH_SOURCE}" echo "ZSH_ARGZERO: ${ZSH_ARGZERO}" echo "ZSH_SCRIPT: ${ZSH_SCRIPT}" / # source test_arg0.sh 0: /bin/ash BASH_SOURCE: ZSH_ARGZERO: ZSH_SCRIPT:
Conclusion: None of the existing methods will work for Ash.
$0shows us the wrong path. So we need to look for other supported options.Looking at the man page, I don't see any documented method of determining the path where a sourced script is located.
$0is all it supports, and that remains the path to the shell binary.Ah, crap, that's my fault, I shouldn't have marked that PR as "fixes" this issue, since it doesn't.
...Thanks, you beat me to it.
I've posted a StackExchange question asking how this might be solved.
(Very belated update: StackExchange produced nothing other than additional confirmation that it doesn't seem to be possible.)
Hi, currently the virtualenvwrapper.sh script fails to be sourced on alpine linux.
This line of code
virtualenvwrapper/virtualenvwrapper.sh
Line 106 in c0f5193
currently causes
-ash: /usr/bin/virtualenvwrapper.sh: line 109: syntax error: bad substitutionwhen using the ash shell on alpine linux.