Skip to content

Commit 1a39248

Browse files
authored
Use hf installer with bash (#3498)
* Use hf installer with bash * fix installer CI * fix installers in CI
1 parent 3d3e08c commit 1a39248

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

.github/workflows/check-installers.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,8 @@ jobs:
3636
3737
export PATH="$BIN_DIR:$PATH"
3838
39-
HF_VERSION_PATH="$HF_TEST_ROOT/hf-version.txt"
40-
hf version | tee "$HF_VERSION_PATH"
41-
if ! grep -Eq 'huggingface_hub version: [0-9]+(\.[0-9]+){1,2}' "$HF_VERSION_PATH"; then
42-
echo "hf version output missing huggingface_hub version" >&2
43-
cat "$HF_VERSION_PATH" >&2
39+
if ! hf version | tee /dev/stderr | grep -Eq '[0-9]+(\.[0-9]+){1,2}(\.[a-zA-Z]+[0-9]+)?'; then
40+
echo "incorrect hf version output" >&2
4441
exit 1
4542
fi
4643
@@ -69,13 +66,15 @@ jobs:
6966
7067
$env:PATH = "$binDir;$env:PATH"
7168
72-
$hfVersionPath = Join-Path $hfTestRoot 'hf-version.txt'
73-
& hf.exe version | Tee-Object -FilePath $hfVersionPath
69+
$hfVersionOutput = & hf.exe version 2>&1
70+
$hfVersionOutput | Out-Host # Show the output
71+
7472
if ($LASTEXITCODE -ne 0) {
75-
throw 'hf version failed'
73+
throw 'hf version failed'
7674
}
77-
if (-not (Select-String -Path $hfVersionPath -Pattern 'huggingface_hub version: [0-9]+(\.[0-9]+){1,2}')) {
78-
throw 'hf version output missing huggingface_hub version'
75+
76+
if (-not ($hfVersionOutput -match '[0-9]+(\.[0-9]+){1,2}(\.[a-zA-Z]+[0-9]+)?')) {
77+
throw 'incorrect hf version output'
7978
}
8079
8180
$env:NO_COLOR = '1'

docs/source/en/guides/cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Alternatively, you can install the `hf` CLI with a single command:
2626
On macOS and Linux:
2727

2828
```bash
29-
>>> curl -LsSf https://hf.co/cli/install.sh | sh
29+
>>> curl -LsSf https://hf.co/cli/install.sh | bash
3030
```
3131

3232
On Windows:

docs/source/en/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Use our one-liner installers to set up the `hf` CLI without touching your Python
110110
On macOS and Linux:
111111

112112
```bash
113-
curl -LsSf https://hf.co/cli/install.sh | sh
113+
curl -LsSf https://hf.co/cli/install.sh | bash
114114
```
115115

116116
On Windows:

src/huggingface_hub/cli/_cli_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def _check_cli_update() -> None:
160160
elif method == "hf_installer" and os.name == "nt":
161161
update_command = 'powershell -NoProfile -Command "iwr -useb https://hf.co/cli/install.ps1 | iex"'
162162
elif method == "hf_installer":
163-
update_command = "curl -LsSf https://hf.co/cli/install.sh | sh -"
163+
update_command = "curl -LsSf https://hf.co/cli/install.sh | bash -"
164164
else: # unknown => likely pip
165165
update_command = "pip install -U huggingface_hub"
166166

src/huggingface_hub/utils/_runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def _is_hf_installer_installation() -> bool:
348348
"""Return `True` if the current environment was set up via the official hf installer script.
349349
350350
i.e. using one of
351-
curl -LsSf https://hf.co/cli/install.sh | sh
351+
curl -LsSf https://hf.co/cli/install.sh | bash
352352
powershell -ExecutionPolicy ByPass -c "irm https://hf.co/cli/install.ps1 | iex"
353353
"""
354354
venv = sys.prefix # points to venv root if active

utils/installers/install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
# Hugging Face CLI Installer for Linux/MacOS
3-
# Usage: curl -LsSf https://hf.co/cli/install.sh | sh -s -- [OPTIONS]
3+
# Usage: curl -LsSf https://hf.co/cli/install.sh | bash -s -- [OPTIONS]
44

55

66
if [ -z "$BASH_VERSION" ]; then
@@ -87,7 +87,7 @@ run_command() {
8787

8888
usage() {
8989
cat <<'EOF'
90-
Usage: curl -LsSf https://hf.co/cli/install.sh | sh -s -- [OPTIONS]
90+
Usage: curl -LsSf https://hf.co/cli/install.sh | bash -s -- [OPTIONS]
9191
9292
Options:
9393
--force Recreate the Hugging Face CLI virtual environment if it exists

0 commit comments

Comments
 (0)