bulletmark / pipxu

Install and Run Python Applications in Isolated Environments using UV
101 stars 1 forks source link

Install error: unexpected argument 'Support/pipxu/venvs/1' found #3

Closed bradfeehan closed 6 months ago

bradfeehan commented 6 months ago

Installing with the script, I get this error:

>>> Running uv venv -q --python=python3 /Users/brad.feehan/Library/Application Support/pipxu/venvs/1
error: unexpected argument 'Support/pipxu/venvs/1' found

Usage: uv venv [OPTIONS] [NAME]

For more information, try '--help'.
Error: failed to create /Users/brad.feehan/Library/Application Support/pipxu/venvs/1 for pipxu.

Cause

The virtualenv is created in a path with a space, which is interpreted as two arguments to the uv command, instead of one argument containing a space.

The default path for PIPXU_HOME is set in pipxu/pipxu.py:124.

This refers to platformdirs.user_data_dir() which is a good practice. However on MacOS this is "${HOME}/Library/Application Support", and it causes the error when the PIPXU_HOME contains a space.

Potential fix

A hacky solution would be to quote the directory, but then directories containing " quote characters would fail (kinda pathological but also technically possible).

As a better solution, it probably shouldn't use shell quoting rules to execute subprocesses. Instead, use an interface that allows passing arguments as individual strings, so nothing requires quoting.

Workaround

Manually tell pipxu to store its stuff in a directory with no space characters in the path:

export PIPXU_HOME="${HOME}/.pipxu"
mkdir -p "${PIPXU_HOME}"
bulletmark commented 6 months ago

Yeah, I knew paths with spaces would probably not be handled correctly because that is not a practical problem on Linux systems. You have prompted me to do program arguments properly. From the commit 870f1eb:

Now all command line arguments are created and passed internally as a sequence (of string args) for eventually passing to subprocess.run() and a shell is never used so we don't have to worry about shell quoting trickery.

This change is released as version 1.14.

bulletmark commented 6 months ago

@bradfeehan, can I please ask: Did this program work fine on a Mac after I fixed this?