Skip to content

Commit 6f4e68c

Browse files
authored
fix: installation error when installing amazon q in remote AND you have the extension locally (#4889)
## Problem - due to a bug in https://github.com/microsoft/vscode/pull/206381/files#diff-efa08c29460835c0ffa740d751c34078033fd6cb6c7b031500fb31f524655de2R360 installExtension will fail on remote environments when the amazon q extension is already installed locally ## Solution - install the amazon q extension using the vscode cli ## Alternatives considered - Installing directly from github releases if they're on a remote environment. Its unclear though if the user will always be able to reach github (vs marketplace which is required to install extensions anyways) ## Drawbacks - If the user doesn't have the vscode cli (though I think it autoinstalls in remotes?) then this won't work
1 parent fa680b5 commit 6f4e68c

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

packages/core/src/codewhisperer/commands/basicCommands.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import { removeDiagnostic } from '../service/diagnosticsProvider'
3939
import { SecurityIssueHoverProvider } from '../service/securityIssueHoverProvider'
4040
import { SecurityIssueCodeActionProvider } from '../service/securityIssueCodeActionProvider'
4141
import { SsoAccessTokenProvider } from '../../auth/sso/ssoAccessTokenProvider'
42+
import { SystemUtilities } from '../../shared/systemUtilities'
43+
import { ToolkitError } from '../../shared/errors'
4244

4345
export const toggleCodeSuggestions = Commands.declare(
4446
{ id: 'aws.amazonq.toggleCodeSuggestion', compositeKey: { 1: 'source' } },
@@ -299,7 +301,32 @@ export const fetchFeatureConfigsCmd = Commands.declare(
299301
export const installAmazonQExtension = Commands.declare(
300302
{ id: 'aws.toolkit.installAmazonQExtension', logging: true },
301303
() => async () => {
304+
if (vscode.env.remoteName === 'ssh-remote') {
305+
/**
306+
* due to a bug in https://github.com/microsoft/vscode/pull/206381/files#diff-efa08c29460835c0ffa740d751c34078033fd6cb6c7b031500fb31f524655de2R360
307+
* installExtension will fail on remote environments when the amazon q extension is already installed locally.
308+
* Until thats fixed we need to manually install the amazon q extension using the cli
309+
*/
310+
const vscPath = await SystemUtilities.getVscodeCliPath()
311+
if (!vscPath) {
312+
throw new ToolkitError('installAmazonQ: Unable to find VSCode CLI path', {
313+
code: 'CodeCLINotFound',
314+
})
315+
}
316+
await vscode.window.withProgress(
317+
{
318+
location: vscode.ProgressLocation.Notification,
319+
cancellable: false,
320+
},
321+
(progress, token) => {
322+
progress.report({ message: 'Installing Amazon Q' })
323+
return SystemUtilities.tryRun(vscPath, ['--install-extension', VSCODE_EXTENSION_ID.amazonq])
324+
}
325+
)
326+
return
327+
}
302328
await vscode.commands.executeCommand('workbench.extensions.installExtension', VSCODE_EXTENSION_ID.amazonq)
329+
303330
// jump to Amazon Q extension view after install.
304331
// this command won't work without a small delay after install
305332
setTimeout(() => {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Installation error when installing amazon q in remote AND you have the extension locally"
4+
}

0 commit comments

Comments
 (0)