mirror of
https://github.com/karpathy/nanochat.git
synced 2026-04-01 13:15:21 +00:00
Ensure uv is available on fresh installs
Some uv install locations are not always present in the $PATH environment variable, e.g. $HOME/.local/bin until the directory is created. This patch replicates the uv install directory resolution and updates the $PATH variable to ensure the uv commands get executed.
This commit is contained in:
parent
f068604948
commit
0bcda4ccb4
|
|
@ -20,6 +20,26 @@ mkdir -p $NANOCHAT_BASE_DIR
|
|||
|
||||
# install uv (if not already installed)
|
||||
command -v uv &> /dev/null || curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
if ! command -v uv &> /dev/null; then
|
||||
# uv installation path is not in $PATH, add it. This code mimics what the
|
||||
# uv install script does to determine the install path.
|
||||
|
||||
if [ -n "${XDG_BIN_HOME:-}" ]; then
|
||||
_install_dir="$XDG_BIN_HOME"
|
||||
elif [ -n "${XDG_DATA_HOME:-}" ]; then
|
||||
_install_dir="$XDG_DATA_HOME/../bin"
|
||||
else
|
||||
if [ -n "${HOME:-}" ]; then
|
||||
_inferred_home="$HOME"
|
||||
elif [ -n "${USER:-}" ]; then
|
||||
_inferred_home=$(getent passwd "$USER" | cut -d: -f6)
|
||||
else
|
||||
_inferred_home=$(getent passwd "$(id -un)" | cut -d: -f6)
|
||||
fi
|
||||
_install_dir="$_inferred_home/.local/bin"
|
||||
fi
|
||||
export PATH="$_install_dir:$PATH"
|
||||
fi
|
||||
# create a .venv local virtual environment (if it doesn't exist)
|
||||
[ -d ".venv" ] || uv venv
|
||||
# install the repo dependencies
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user