From 790c64f0e8f1904a881c7a9df738603b5681ca43 Mon Sep 17 00:00:00 2001 From: jsboige Date: Sat, 12 Sep 2026 22:44:07 +0200 Subject: [PATCH] =?UTF-8?q?fix(vibe-coding,#15672):=20blocs=20copiables=20?= =?UTF-8?q?Linux=20du=20chemin=20canonique=20align=C3=A9s=20+=20test=20her?= =?UTF-8?q?m=C3=A9tique?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Doc: curl install.claude.com -> claude.ai/install.sh (commande officielle re-consultée 2026-09-12), export PATH ~/.claude/bin (ère npm) -> ~/.local/bin (chemin du binaire natif, cohérent avec l'encadré canonique L14). Test: verify_installation_true mocke désormais aussi subprocess.run -- le verdict ne dépend plus d'une CLI réellement installée sur l'hôte; companion de falsification (run en échec -> False). Co-Authored-By: Claude Sonnet 5 --- .../docs/INSTALLATION-CLAUDE-CODE.md | 11 ++++---- .../notebooks/helpers/test_claude_cli.py | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/MyIA.AI.Notebooks/GenAI/Vibe-Coding/Claude-Code/docs/INSTALLATION-CLAUDE-CODE.md b/MyIA.AI.Notebooks/GenAI/Vibe-Coding/Claude-Code/docs/INSTALLATION-CLAUDE-CODE.md index 2a5897e47b..cf6dccb86e 100644 --- a/MyIA.AI.Notebooks/GenAI/Vibe-Coding/Claude-Code/docs/INSTALLATION-CLAUDE-CODE.md +++ b/MyIA.AI.Notebooks/GenAI/Vibe-Coding/Claude-Code/docs/INSTALLATION-CLAUDE-CODE.md @@ -49,14 +49,15 @@ claude --version #### Linux / WSL ```bash -# Installation via script -curl -fsSL https://install.claude.com | sh +# Installation via le script officiel (binaire natif, Node.js non requis) +curl -fsSL https://claude.ai/install.sh | bash -# Ajouter au PATH (si necessaire) -echo 'export PATH="$HOME/.claude/bin:$PATH"' >> ~/.bashrc -source ~/.bashrc +# Si "claude --version" reste introuvable apres avoir rouvert le terminal : +# echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc ``` +Le binaire natif vit sous `~/.local/bin` (cf. encadré ci-dessus) et les installations natives se mettent à jour automatiquement en arrière-plan. Source consultée le 2026-09-12 : [code.claude.com/docs/en/quickstart](https://code.claude.com/docs/en/quickstart). + **Verification :** ```bash diff --git a/MyIA.AI.Notebooks/GenAI/Vibe-Coding/Claude-Code/notebooks/helpers/test_claude_cli.py b/MyIA.AI.Notebooks/GenAI/Vibe-Coding/Claude-Code/notebooks/helpers/test_claude_cli.py index 147b894a83..b8236ef7c7 100644 --- a/MyIA.AI.Notebooks/GenAI/Vibe-Coding/Claude-Code/notebooks/helpers/test_claude_cli.py +++ b/MyIA.AI.Notebooks/GenAI/Vibe-Coding/Claude-Code/notebooks/helpers/test_claude_cli.py @@ -77,10 +77,35 @@ def test_verify_installation_false_when_not_in_path(monkeypatch): def test_verify_installation_true_when_in_path(monkeypatch): + # Hermetic: mock BOTH layers -- shutil.which resolves the binary AND + # subprocess.run answers -- so the verdict never depends on a real CLI + # installed on the host running the suite (#15672). monkeypatch.setattr(claude_cli.shutil, "which", lambda cmd: "/usr/local/bin/claude") + + class _FakeOk: + returncode = 0 + stdout = "1.0.100 (Claude Code)\n" + stderr = "" + + monkeypatch.setattr(claude_cli.subprocess, "run", lambda *a, **k: _FakeOk()) assert claude_cli.verify_installation() is True +def test_verify_installation_false_when_run_fails(monkeypatch): + # Falsification companion: same PATH hit, failing '--version' run. + # Proves the True verdict above depends on execution, not on + # shutil.which alone. + monkeypatch.setattr(claude_cli.shutil, "which", lambda cmd: "/usr/local/bin/claude") + + class _FakeFail: + returncode = 127 + stdout = "" + stderr = "command failed" + + monkeypatch.setattr(claude_cli.subprocess, "run", lambda *a, **k: _FakeFail()) + assert claude_cli.verify_installation() is False + + # -------------------------------------------------------------------------- # run_claude — SIMULATION_MODE (deterministic) # --------------------------------------------------------------------------