Auto-update runs npm install -g when a Gemini CLI source checkout is run from outside the clone
I maintainer di solito rispondono entro 1 giorno
@tanveerhkit ci sta già lavorando.
Dal 13/11/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
Direzione di ricerca
Inizia da packages/cli/src/utils/installationInfo.ts e dai test unitari di getInstallationInfo(); attualmente simulano la directory di lavoro come radice del progetto. Segui come il percorso di ingresso della CLI e la directory corrente determinano il tipo di installazione, poi aggiungi test per l’esecuzione di un checkout del codice sorgente da un’altra directory. Il lavoro è completato quando questo caso viene identificato come clone locale e non può attivare un aggiornamento globale di npm.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happened?
When Gemini CLI is run from a source checkout (for example node ~/gemini-cli/bundle/gemini.js, or the alias / npm link setups suggested in CONTRIBUTING.md) from any directory other than the clone itself, the CLI classifies itself as a global npm installation. With auto-update enabled (the default), it then spawns npm install -g @google/gemini-cli@<channel> in the background.
I hit this while testing. Running the source bundle from a plain folder showed Installed with npm. Attempting to automatically update now..., and the npm debug log shows it ran npm install --global @google/gemini-cli@nightly, which installed a global copy of the published nightly next to my source checkout. The checkout is detected as Running from a local git clone. Please update with "git pull". only when run from inside the clone itself.
Root cause
getInstallationInfo() in packages/cli/src/utils/installationInfo.ts treats the CLI as a local git clone only if:
isGitRepository(process.cwd()) &&
realPath.startsWith(normalizedProjectRoot) &&
!realPath.includes('/node_modules/')
projectRoot comes from config.getProjectRoot(), which returns targetDir, i.e. the directory the user runs the CLI in. So both checks depend on the current directory, not on where the CLI itself lives. When they fail, detection falls through to the default branch ("Assume global npm"), which returns npm install -g @google/gemini-cli@latest as the update command.
Minimal check: getInstallationInfo(process.cwd(), true), as the real caller passes it, with process.argv[1] set to <clone>/bundle/gemini.js:
| Current directory | Result |
|---|---|
| Inside the gemini-cli clone | Running from a local git clone. Please update with "git pull". |
| A folder that is not a git repository | auto-update: npm install -g @google/gemini-cli@latest |
| Another git repository | auto-update: npm install -g @google/gemini-cli@latest |
The current-directory check dates back to when auto-update was added (#4686). It likely explains #5853, which was closed after the behavior seemed to go away: whether it happens depends only on the current directory. The unit tests mock process.cwd() to return projectRoot, so they never cover running from a different directory.
What did you expect to happen?
A source checkout should always be detected as "Running from a local git clone", whatever the current directory is, and auto-update should never run npm install -g for it.
Suggested fix
Detect the clone from the CLI's own location instead of the current directory, for example !realPath.includes('/node_modules/') && isGitRepository(path.dirname(realPath)). Keeping the node_modules exclusion leaves global, local and package-manager installs unaffected. A test should cover running a checkout from another directory. With npm link, the linked checkout is currently classified the same way, so an auto-update would likely replace the link with the published package. Workaround: set "general": { "enableAutoUpdate": false }.
Client information
- Gemini CLI built from source on current
main(62bab5b23);installationInfo.tsis unchanged there - Node.js 20.19.6, macOS 27.2
Anything else we need to know?
I have this fix ready locally with regression tests: the new test fails on main and passes with the fix. Happy to open a PR if this is open for a community contribution.
Edited shortly after posting to correct the root cause and suggested fix: projectRoot is also the current directory, so the original suggestion (isGitRepository(projectRoot)) would not have helped.
- Lingua principale
- TypeScript
- Stelle
- 109k
- Fork
- 14.9k
- Merge medio
- 1g 2h
- PR unite (30g)
- 111
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di google-gemini/gemini-cli
-
status/need-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
google-gemini/gemini-cli#30328 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Padded function-call name is answered under the trimmed name, so the next request fails with 400 INVALID_ARGUMENTForse già presa @arifrhm l’ha presa 3 giorni fa. Apertaarea/agent status/need-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
google-gemini/gemini-cli#30256 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
status/need-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
google-gemini/gemini-cli#30242 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
status/need-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
google-gemini/gemini-cli#30127 ·
I maintainer di solito rispondono entro 1 giorno
-
web_fetch keeps a trailing comma on URLs in a comma-separated listForse di nuovo libera @tneemo l’ha presa 24 giorni fa e non c’è nessuna pull request aperta. Apertaarea/agent status/need-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
google-gemini/gemini-cli#29896 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di google-gemini/gemini-cli
Issue simili
-
[hooks] SessionStart injects the knowledge-update frontmatter on a CRLF checkoutForse già presa @abhiramshaji-cyber l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
vercel/vercel-plugin#429 ·
I maintainer di solito rispondono entro 1 giorno
-
severity:medium triage:confirmed triage:in-progress triage:reproduced
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
Cotal-AI/Cotal#7231 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
boxlite-ai/boxlite#2777 ·
I maintainer di solito rispondono entro 1 giorno
-
bug P3
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 87/100
I maintainer di solito rispondono entro 1 giorno