Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uv run fails to run binaries from ~/Library/Application Support on macOS #9348

Closed
gusutabopb opened this issue Nov 22, 2024 · 8 comments · Fixed by indygreg/python-build-standalone#395
Assignees
Labels
bug Something isn't working upstream An upstream dependency is involved

Comments

@gusutabopb
Copy link

When executing uv run, a list of available commands is shown. python and python3 work fine, but other commands list do not. I don't think uv should be shipping with pip, etc so the provided command list seems wrong.

I tried using different Python version (e.g. -p 3.12) but the results were the same.

Listing commands

> ~> uv -v run
DEBUG uv 0.5.4 (c62c83c37 2024-11-20)
DEBUG No project found; searching for Python interpreter
DEBUG Searching for default Python interpreter in virtual environments or managed installations
DEBUG Searching for managed installations at `Library/Application Support/uv/python`
DEBUG Found managed installation `cpython-3.13.0-macos-aarch64-none`
DEBUG Found `cpython-3.13.0-macos-aarch64-none` at `/Users/gustavo/Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13` (managed installations)
DEBUG Using Python 3.13.0 interpreter at: /Users/gustavo/Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13
Provide a command or script to invoke with `uv run <command>` or `uv run <script>.py`.

The following commands are available in the environment:

- idle3
- idle3.13
- pip
- pip3
- pip3.13
- pydoc3
- pydoc3.13
- python
- python3
- python3-config
- python3.13
- python3.13-config

See `uv run --help` for more information.

Running python - OK

python3 works as well.

⋊> ~> uv -v run python
DEBUG uv 0.5.4 (c62c83c37 2024-11-20)
DEBUG No project found; searching for Python interpreter
DEBUG Searching for default Python interpreter in virtual environments or managed installations
DEBUG Searching for managed installations at `Library/Application Support/uv/python`
DEBUG Found managed installation `cpython-3.13.0-macos-aarch64-none`
DEBUG Found `cpython-3.13.0-macos-aarch64-none` at `/Users/gustavo/Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13` (managed installations)
DEBUG Using Python 3.13.0 interpreter at: /Users/gustavo/Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13
DEBUG Running `python`
Python 3.13.0 (main, Oct  7 2024, 23:47:22) [Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Running pydoc3 - FAIL

pip, pip3, idle3, etc fail as well.

⋊> ~> uv -v run pydoc3
DEBUG uv 0.5.4 (c62c83c37 2024-11-20)
DEBUG No project found; searching for Python interpreter
DEBUG Searching for default Python interpreter in virtual environments or managed installations
DEBUG Searching for managed installations at `Library/Application Support/uv/python`
DEBUG Found managed installation `cpython-3.13.0-macos-aarch64-none`
DEBUG Found `cpython-3.13.0-macos-aarch64-none` at `/Users/gustavo/Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13` (managed installations)
DEBUG Using Python 3.13.0 interpreter at: /Users/gustavo/Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13
DEBUG Running `pydoc3`
/Users/gustavo/Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/pydoc3: line 2: /Users/gustavo/Library
Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13: No such file or directory
/Users/gustavo/Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/pydoc3: line 2: exec: /Users/gustavo/Library
Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13: cannot execute: No such file or directory
DEBUG Command exited with code: 126
@gusutabopb gusutabopb changed the title Wrong list of commands when running uv run python uv run displays an incorrect list of commands Nov 22, 2024
@charliermarsh charliermarsh added the bug Something isn't working label Nov 22, 2024
@zanieb
Copy link
Member

zanieb commented Nov 22, 2024

Hm I can't reproduce this

❯ uv run -v
DEBUG uv 0.5.3 (56d362208 2024-11-19)
DEBUG No project found; searching for Python interpreter
DEBUG Searching for default Python interpreter in virtual environments, managed installations, or search path
DEBUG Searching for managed installations at `/Users/zb/.local/share/uv/python`
DEBUG Found managed installation `cpython-3.13.0-macos-aarch64-none`
DEBUG Found `cpython-3.13.0-macos-aarch64-none` at `/Users/zb/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13` (managed installations)
DEBUG Using Python 3.13.0 interpreter at: /Users/zb/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13
Provide a command or script to invoke with `uv run <command>` or `uv run <script>.py`.

The following commands are available in the environment:

- idle3
- idle3.13
- pip
- pip3
- pip3.13
- pydoc3
- pydoc3.13
- python
- python3
- python3-config
- python3.13
- python3.13-config

See `uv run --help` for more information.
❯ uv run python3.13
Python 3.13.0 (main, Oct 16 2024, 08:05:40) [Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
KeyboardInterrupt
>>> 
❯ uv run pydoc3
pydoc - the Python documentation tool

pydoc3 <name> ...
    Show text documentation on something.  <name> may be the name of a
    Python keyword, topic, function, module, or package, or a dotted
    reference to a class or function within a module or module in a
    package.  If <name> contains a '/', it is used as the path to a
    Python source file to document. If name is 'keywords', 'topics',
    or 'modules', a listing of these things is displayed.

pydoc3 -k <keyword>
    Search for a keyword in the synopsis lines of all available modules.

pydoc3 -n <hostname>
    Start an HTTP server with the given hostname (default: localhost).

pydoc3 -p <port>
    Start an HTTP server on the given port on the local machine.  Port
    number 0 can be used to get an arbitrary unused port.

pydoc3 -b
    Start an HTTP server on an arbitrary unused port and open a web browser
    to interactively browse documentation.  This option can be used in
    combination with -n and/or -p.

pydoc3 -w <name> ...
    Write out the HTML documentation for a module to a file in the current
    directory.  If <name> contains a '/', it is treated as a filename; if
    it names a directory, documentation is written for all the contents.


 /                                                                                                                     
❯ uv run pip3 --version
pip 24.1.2 from /Users/zb/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13/site-packages/pip (python 3.13)

@zanieb zanieb added the needs-mre Needs more information for reproduction label Nov 22, 2024
@gusutabopb gusutabopb changed the title uv run displays an incorrect list of commands uv run fails to run binaries from ~/Library/Application Support on macOS Nov 23, 2024
@gusutabopb
Copy link
Author

The binaries (pydoc3, etc) were present in the installation directory (~/Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/) but uv failed to find them. I updated the issue description to clarify that.

I believe this is somewhat related to #5806 and perhaps with the whitespace in Application Support not being properly escaped somehow.

I can reproduce this consistently on macOS using this:

> rm -rf ~/.local/share/uv
> rm -rf ~/Library/Application\ Support/uv/
> mkdir -p ~/Library/Application\ Support/uv
> uv -v --python-preference only-managed run --python 3.13.0 pydoc3

Output:

DEBUG uv 0.5.4 (c62c83c37 2024-11-20)
DEBUG No project found; searching for Python interpreter
DEBUG Searching for Python 3.13.0 in virtual environments or managed installations
DEBUG Searching for managed installations at `Library/Application Support/uv/python`
DEBUG Requested Python not found, checking for available download...
DEBUG Acquired lock for `Library/Application Support/uv/python`
DEBUG Using request timeout of 30s
INFO Fetching requested Python...
DEBUG Downloading https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.13.0%2B20241016-aarch64-apple-darwin-install_only_stripped.tar.gz to temporary location: /Users/gustavo/Library/Application Support/uv/python/.cache/.tmptaZksd
DEBUG Extracting cpython-3.13.0%2B20241016-aarch64-apple-darwin-install_only_stripped.tar.gz
DEBUG Moving /Users/gustavo/Library/Application Support/uv/python/.cache/.tmptaZksd/python to Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none
DEBUG Released lock at `/Users/gustavo/Library/Application Support/uv/python/.lock`
DEBUG Using Python 3.13.0 interpreter at: /Users/gustavo/Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13
DEBUG Running `pydoc3`
/Users/gustavo/Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/pydoc3: line 2: /Users/gustavo/Library
Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13: No such file or directory
/Users/gustavo/Library/Application Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/pydoc3: line 2: exec: /Users/gustavo/Library
Support/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13: cannot execute: No such file or directory
DEBUG Command exited with code: 126

Note that if ~/Library/Application\ Support/uv/ doesn't exist, the issue goes away:

> rm -rf ~/Library/Application\ Support/uv/
> uv -v --python-preference only-managed run --python 3.13.0 pydoc3
DEBUG uv 0.5.4 (c62c83c37 2024-11-20)
DEBUG No project found; searching for Python interpreter
DEBUG Searching for Python 3.13.0 in virtual environments or managed installations
DEBUG Searching for managed installations at `.local/share/uv/python`
DEBUG Requested Python not found, checking for available download...
DEBUG Acquired lock for `.local/share/uv/python`
DEBUG Using request timeout of 30s
INFO Fetching requested Python...
DEBUG Downloading https://github.com/indygreg/python-build-standalone/releases/download/20241016/cpython-3.13.0%2B20241016-aarch64-apple-darwin-install_only_stripped.tar.gz to temporary location: /Users/gustavo/.local/share/uv/python/.cache/.tmp2Z3nJ4
DEBUG Extracting cpython-3.13.0%2B20241016-aarch64-apple-darwin-install_only_stripped.tar.gz
DEBUG Moving /Users/gustavo/.local/share/uv/python/.cache/.tmp2Z3nJ4/python to .local/share/uv/python/cpython-3.13.0-macos-aarch64-none
DEBUG Released lock at `/Users/gustavo/.local/share/uv/python/.lock`
DEBUG Using Python 3.13.0 interpreter at: /Users/gustavo/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/bin/python3.13
DEBUG Running `pydoc3`
pydoc - the Python documentation tool

pydoc3 <name> ...
    Show text documentation on something.  <name> may be the name of a
    Python keyword, topic, function, module, or package, or a dotted
    reference to a class or function within a module or module in a
    package.  If <name> contains a '/', it is used as the path to a
    Python source file to document. If name is 'keywords', 'topics',
    or 'modules', a listing of these things is displayed.

pydoc3 -k <keyword>
    Search for a keyword in the synopsis lines of all available modules.

pydoc3 -n <hostname>
    Start an HTTP server with the given hostname (default: localhost).

pydoc3 -p <port>
    Start an HTTP server on the given port on the local machine.  Port
    number 0 can be used to get an arbitrary unused port.

pydoc3 -b
    Start an HTTP server on an arbitrary unused port and open a web browser
    to interactively browse documentation.  This option can be used in
    combination with -n and/or -p.

pydoc3 -w <name> ...
    Write out the HTML documentation for a module to a file in the current
    directory.  If <name> contains a '/', it is treated as a filename; if
    it names a directory, documentation is written for all the contents.

DEBUG Command exited with code: 0

@charliermarsh
Copy link
Member

Interesting, thanks. (We no longer write there by default IIRC but it's preserved for backwards compatibility.)

@charliermarsh
Copy link
Member

I think it must be an issue with the shebang that's being used in python-build-standalone (upstream)?

@charliermarsh
Copy link
Member

Filed: indygreg/python-build-standalone#394. Should be an easy fix.

@charliermarsh charliermarsh added upstream An upstream dependency is involved and removed needs-mre Needs more information for reproduction labels Nov 24, 2024
@charliermarsh charliermarsh self-assigned this Nov 24, 2024
@charliermarsh
Copy link
Member

And now a PR here: indygreg/python-build-standalone#395. I think that's right?

@gusutabopb
Copy link
Author

Thanks!

If anyone else hits this until it's fixed upstream, the quick fix is to simply delete your ~/Library/Application Support and reinstall any necessary Python versions in the new default location (~/.local/share/uv).

@zanieb
Copy link
Member

zanieb commented Dec 3, 2024

This is fixed upstream, but we need to release it there and here still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream An upstream dependency is involved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants