diff --git a/packages/cli/src/utils/installationInfo.test.ts b/packages/cli/src/utils/installationInfo.test.ts index fbebec8bf7..ad55efda32 100644 --- a/packages/cli/src/utils/installationInfo.test.ts +++ b/packages/cli/src/utils/installationInfo.test.ts @@ -352,6 +352,30 @@ describe('getInstallationInfo', () => { expect(infoDisabled.updateMessage).toContain('Please run npm install'); }); + it('should detect Volta installation (Unix-style)', () => { + const voltaPath = + '/Users/test/.volta/tools/image/node/20.0.0/lib/node_modules/@google/gemini-cli/dist/index.js'; + process.argv[1] = voltaPath; + mockedRealPathSync.mockReturnValue(voltaPath); + + const info = getInstallationInfo(projectRoot, true); + + expect(info.packageManager).toBe(PackageManager.VOLTA); + expect(info.updateCommand).toBe('volta install @google/gemini-cli@latest'); + }); + + it('should detect Volta installation (Windows-style)', () => { + const voltaPath = + 'C:\\Users\\test\\AppData\\Local\\Volta\\tools\\image\\node\\20.0.0\\node_modules\\@google/gemini-cli\\dist\\index.js'; + process.argv[1] = voltaPath; + mockedRealPathSync.mockReturnValue(voltaPath); + + const info = getInstallationInfo(projectRoot, true); + + expect(info.packageManager).toBe(PackageManager.VOLTA); + expect(info.updateCommand).toBe('volta install @google/gemini-cli@latest'); + }); + it('should NOT detect Homebrew if gemini-cli is installed in brew but running from npm location', () => { Object.defineProperty(process, 'platform', { value: 'darwin', diff --git a/packages/cli/src/utils/installationInfo.ts b/packages/cli/src/utils/installationInfo.ts index 20625a7491..3db736d8d5 100644 --- a/packages/cli/src/utils/installationInfo.ts +++ b/packages/cli/src/utils/installationInfo.ts @@ -22,6 +22,7 @@ export enum PackageManager { HOMEBREW = 'homebrew', NPX = 'npx', BINARY = 'binary', + VOLTA = 'volta', UNKNOWN = 'unknown', } @@ -116,6 +117,19 @@ export function getInstallationInfo( } } + // Check for Volta + if (realPath.includes('/.volta/') || realPath.includes('/Volta/')) { + const updateCommand = 'volta install @google/gemini-cli@latest'; + return { + packageManager: PackageManager.VOLTA, + isGlobal: true, + updateCommand, + updateMessage: isAutoUpdateEnabled + ? 'Installed with Volta. Attempting to automatically update now...' + : `Please run ${updateCommand} to update`, + }; + } + // Check for pnpm if ( realPath.includes('/.pnpm/global') ||