Summary
Type: Bug
Explanation
Python environments made with the current AppImage does not work when put inside a directory with a space in it.
Proposed Solution
At python_appimage/data/python-wrapper.sh, line 7, column 28 to 30 (the $0
) needed to be encapsulated with double quotation marks ("
).
Environment
OS: Arch Linux
Kernel: 5.19.7-arch1-1
Shell: zsh 5.9 (x86_64-pc-linux-gnu)
AppImage: python3.9.14-cp39-cp39-manylinux2014_x86_64.AppImage
Explanation
Greetings! Let it be known that I do not have a lot of expertise in this kind of stuff.
To start, I've been using your python appimages to make a python environment if the version is not available at my package manager (I use Arch Linux, and AUR does not keep older versions of python, nor does it for any other programs).
In any case, this works well for me. I've never had any problems with it for a month that I've been using it. But it had been at least a month since I last touched that thingy. And now, I tried to make a python environment using a python 3.9 appimage, as the service that my project deploys to does not have python 3.10 available.
In any case, this fails specifically at the point where the python environment tries to install pip. This is an example of the error:
Error: Command '['/home/whinee/directory with space/project/pyenv/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 127.
pyenv:source:19: no such file or directory: pyenv/bin/activate
/home/whinee/projects/personal/directory with space/project/pyenv/bin/python: line 25: /home/whinee/opt/python3.9/bin/python3.9: No such file or directory
/home/whinee/projects/personal/directory with space/project/pyenv/bin/python: line 25: /home/whinee/opt/python3.9/bin/python3.9: No such file or directory
/home/whinee/projects/personal/directory with space/project/pyenv/bin/python: line 25: /home/whinee/opt/python3.9/bin/python3.9: No such file or directory
How to Replicate
- At
$HOME
directory, make 2 folder deep file structure, without any spaces in its name. In this example, we will use a/b
.
- Get inside the folder created earlier, and make a folder with a space in its name. In this example, we will use
c d
.
- Get inside the folder created earlier, and make another folder without any spaces in its name. In this example, we will use
e
.
- In your favorite shell, set
pyver
variable with python version you wish to download from this repository. In this example, we will set it as 3.9
- Run the following command:
tmpf=$(mktemp)
wget -O "$tmpf" "$(wget -qSO - "https://api.github.com/repos/niess/python-appimage/releases/tags/python$pyver" 2>/dev/null | grep -E "browser_download_url.*x86_64" | cut -d'"' -f4 | tail -2 | head -1)" >/dev/null
chmod +x "$tmpf"
"$tmpf" --appimage-extract >/dev/null
rm -rf "$tmpf" pyenv/
mkdir pyenv
mv squashfs-root/opt squashfs-root/usr pyenv/
pyenv/usr/bin/python -m venv pyenv/ # point of failure
With this, the last command should fail with the following error:
Error: Command '['$HOME/a/b/c d/e/pyenv/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 127.
pyenv:source:19: no such file or directory: pyenv/bin/activate
$HOME/a/b/c d/e/pyenv/bin/python: line 25: $HOME/opt/python3.9/bin/python3.9: No such file or directory
$HOME/a/b/c d/e/pyenv/bin/python: line 25: $HOME/opt/python3.9/bin/python3.9: No such file or directory
$HOME/a/b/c d/e/pyenv/bin/python: line 25: $HOME/opt/python3.9/bin/python3.9: No such file or directory
Tracking Down Bug
I tried to track where this error came from, as the error did not provide any information on what file is throwing this error, and I found it on ./pyenv/opt/python3.9/lib/python3.9/venv/__main__.py
, at the part where it tries to install pip, as said earlier.
Well... I though that the thingy running that command just do not have enough quotations. But nawp! So I tried tracing the problem in the scripts, starting from the activate script, and got me to the pyenv/bin/python
.
I kinda debugged it, and saw that $APPDIR
's value is /home/whinee/
instead of /home/whinee/projects/personal/directory with space/project/pyenv/
. So I started fiddling with the quotations, and sure enough, it lacked one. I encapsulated $0
at line 7 with double quotations, and it worked like it should!
Proposed Solution
As said earlier, encapsulating python_appimage/data/python-wrapper.sh, line 7, column 28 to 30 with double quotation marks ("
) solved the problem for me.
Rationale for Not Opening Pull Request
But you ask:
whi_ne, why didn't you just made a pull request, instead of writing this issue which can be solved by adding literally 2 characters?
Well... many reasons, actually:
- I might break something unexpectedly, and as I said earlier, I am no expert with this stuff.
- You might have pending changes on your local machine, and making a pull request for this small thing can be quite annoying.
- Me too shy...
Anyways, I hope that this issue will be resolved soon, thanks!