Skip to content

realpath not available on macOS 12 (breaks venv activate and uv tool run) #13807

@kandji-trent

Description

@kandji-trent

Summary

The realpath binary is not available on macOS 12 and earlier. This results in error messages when attempting to activate a (relocatable) virtual environment or when running a tool without installing (uvx or uv tool run) as both of these use realpath in the script.

The offending lines of code appear to be:

Here is an example running on macOS 12.7.6, ARM with uv venv --relocatable

anka@arm-12_7_5 ~ % uv venv --relocatable
Using CPython 3.13.3
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
anka@arm-12_7_5 ~ % source .venv/bin/activate
.venv/bin/activate:81: command not found: realpath
(anka) anka@arm-12_7_5 ~ % which realpath 
realpath not found

Here is a example running on an macOS 12.7.6, ARM with uvx

anka@arm-12_7_5 ~ % uvx kst --version
/Users/anka/.cache/uv/archive-v0/-v1Dn8vBMUCf8TwtMb7Lg/bin/kst: line 2: realpath: command not found
/Users/anka/.cache/uv/archive-v0/-v1Dn8vBMUCf8TwtMb7Lg/bin/kst: line 2: /Users/anka/python: No such file or directory
/Users/anka/.cache/uv/archive-v0/-v1Dn8vBMUCf8TwtMb7Lg/bin/kst: line 2: exec: /Users/anka/python: cannot execute: No such file or directory

If the tool is first installed with uv tool install, then this does not happen. This make sense since the console script uses a different (simplified) shabang.

anka@arm-12_7_5 ~ % uv tool install kst
Resolved 21 packages in 11ms
Installed 21 packages in 22ms
 + annotated-types==0.7.0
 + certifi==2025.4.26
 + charset-normalizer==3.4.2
 + click==8.1.8
 + idna==3.10
 + kst==1.0.2
 + markdown-it-py==3.0.0
 + mdurl==0.1.2
 + platformdirs==4.3.8
 + pydantic==2.11.5
 + pydantic-core==2.33.2
 + pygments==2.19.1
 + requests==2.32.3
 + rich==14.0.0
 + ruamel-yaml==0.18.12
 + ruamel-yaml-clib==0.2.12
 + shellingham==1.5.4
 + typer==0.16.0
 + typing-extensions==4.14.0
 + typing-inspection==0.4.1
 + urllib3==2.4.0
Installed 1 executable: kst
anka@arm-12_7_5 ~ % kst --version
kst, version 1.0.2
anka@arm-12_7_5 ~ % uvx kst --version
kst, version 1.0.2

I have tested this across both Intel and ARM versions of macOS and Python 3.11-13

Platform

macOS 12 arm64, macOS 12 amd64

Version

uv 0.7.9 (13a86a2 2025-05-30)

Python version

Python 3.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAsking for clarification or support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions