[rush] Managed Git LFS hooks conflict with reused Azure Pipelines workspaces
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
Summary
Rush's managed Git-hook installation has two incompatible failure modes when a repository also uses Git LFS:
- If the repository does not declare the Git LFS hook names under
common/git-hooks,rush install/rush updateempties.git/hooksand removes Git LFS's canonical hooks. A latergit pushcan push LFS pointer commits without uploading the corresponding LFS objects. - If the repository does declare an LFS hook name so Rush adds its built-in LFS delegation, Rush leaves a noncanonical wrapper in
.git/hooks. Azure Pipelines checkout runsgit lfs install --local; on a reused self-hosted agent, Git LFS rejects the existing Rush wrapper and the checkout fails before repository code can run.
This is not a recent regression. I verified the same installation logic in locally available Rush versions 5.172 through 5.180.
Related history
- #3816 and #4132 introduced the current delegate-hook approach and its Git LFS chaining.
- A comment on #1042 describes intentionally ignoring
git lfs installerrors after Rush ownspre-push. That works in a setup script, but Azure Pipelines treats the same error as a fatal checkout failure. - #4247 fixed error propagation from a managed
pre-pushhook, but does not cover hook installation interoperability.
I did not find an existing issue for the combination of hook-folder clearing, missing LFS uploads, and Azure's repeated git lfs install --local.
Reproduction A: Rush removes Git LFS's upload hook
-
Create a Rush repository with at least one managed hook, for example:
common/git-hooks/pre-commit -
Configure Git LFS:
git lfs install --local.git/hooks/pre-pushis now Git LFS's canonical hook. -
Run:
rush update -
Inspect
.git/hooks.
Actual result
Rush calls ensureEmptyFolder(hookDestination) and recreates only hook names represented under common/git-hooks. The canonical pre-push, post-checkout, post-commit, and post-merge hooks are removed.
A later normal git push does not invoke git lfs pre-push, so new LFS objects are not uploaded.
Expected result
Installing Rush-managed hooks should not silently remove hooks owned by another tool, especially Git LFS's upload hook.
Reproduction B: Rush's LFS wrapper breaks Azure checkout
-
Add a placeholder such as:
common/git-hooks/pre-pushRush recognizes the name and generates a wrapper that delegates to the repository hook and then invokes:
git lfs pre-push "$@" -
Use an Azure Pipelines self-hosted agent with checkout configured for LFS.
-
Run a build job that executes
rush installorrush update. -
Reuse the same agent workspace for a later job or pipeline checkout.
Azure's checkout task runs:
git lfs install --local
Actual result
Git LFS rejects Rush's noncanonical wrapper:
Hook already exists: pre-push
#!/usr/bin/env bash
set -e
SCRIPT_DIR="..."
SCRIPT_IMPLEMENTATION_PATH=".../common/git-hooks/pre-push"
...
git lfs pre-push "$@"
To resolve this, either:
1: run `git lfs update --manual` for instructions on how to merge hooks.
2: run `git lfs update --force` to overwrite your hook.
##[error]Git-lfs installation failed with exit code: 2
The checkout fails before any repository script can repair the hook.
This was observed with Azure Pipelines agent checkout using Git LFS 3.4.1 on Linux. The repository's developer machine used Git LFS 3.7.1 and reproduced the same git lfs install --local conflict.
Expected result
A hook arrangement produced by Rush's documented installation flow should remain compatible with common checkout tooling that initializes Git LFS, or Rush should explicitly document and validate the incompatibility.
Why this is difficult to work around
- Omitting the placeholder avoids Azure's conflict but lets Rush remove LFS's upload hook.
- Adding the placeholder preserves LFS behavior during
git pushbut leaves a wrapper thatgit lfs install --localrejects. git lfs install --local --forceafter every Rush install restores canonical hooks and works when the repository has no custom implementation for those hook names, but it would overwrite legitimate custom Rush-managed hooks.- A stale wrapper on a reused self-hosted agent can break unrelated branches before they have checked out a corrective commit.
Possible direction
The most general fix may be for Rush to stop emptying the complete hooks directory:
- Track which hooks were generated by Rush.
- Replace or remove only Rush-generated hooks.
- Preserve unmanaged hooks, including canonical Git LFS hooks, when there is no same-name repository hook.
- Define and document collision behavior when both Rush and another tool manage the same hook.
- Add integration coverage for:
git lfs install --localfollowed byrush updaterush updatefollowed bygit lfs install --local- repeated Azure-style checkout/install cycles in one worktree
At minimum, the Git-hooks documentation should state that Rush empties .git/hooks, explain the special LFS-hook-name behavior, and discuss checkout tools that invoke git lfs install.
Standard questions
| Question | Answer |
|---|---|
@microsoft/rush globally installed version? |
Version selector; tested with Rush 5.180.0 |
rushVersion from rush.json? |
5.180.0 |
useWorkspaces? |
true |
| Package manager | pnpm 10.34.6 |
| Operating system | Linux |
| Node.js version | 24.18.0 |
| Git LFS versions | 3.7.1 locally; 3.4.1 in Azure Pipelines |
| Would you consider contributing a PR? | Yes |
- Vorherrschende Sprache
- TypeScript
- Sterne
- 6.5k
- Forks
- 710
- Ø Merge
- 1 T. 23 Std.
- Gemergte PRs (30 T.)
- 47
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/rushstack
-
[rush] Upgrade the pnpm-sync-lib dependency to 0.3.5.Evtl. vergeben @martinnaj hat das vor 8 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
microsoft/rushstack#5971 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
microsoft/rushstack#5902 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
microsoft/rushstack#5839 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
microsoft/rushstack#5683 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
[rush] With pnpm 12, `rush update` does not update pnpm-lock.yaml after pnpm changes a peer variantEvtl. vergeben @brunojppb hat das vor 1 Tag übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
microsoft/rushstack#6117 · 12 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in microsoft/rushstack
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
farbenmeer/tapi#531 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
naver/egjs-flicking#971 ·
-
Renderer treats a sub-pixel width difference as a resize, which cancels the `motion()` entranceOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
Tenant
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
MTES-MCT/Dossier-Facile-Frontend#2061 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
backnotprop/plannotator#1784 ·
Maintainer antworten meist innerhalb von 1 Tag