aws / aws-toolkit-visual-studio

AWS Toolkit for Visual Studio - a plugin to interact with AWS
https://aws.amazon.com/visualstudio/
Apache License 2.0
107 stars 29 forks source link

Error installing Amazon Q Language Server #453

Closed kmillerdevx3 closed 1 week ago

kmillerdevx3 commented 1 month ago

Describe the bug

With latest version(s) of AWS Toolkit, attempting to start Q/CodeWhisperer suggestions results in the error shown in title. The Amazon Web Services output window shows:

AWS Toolkit for Visual Studio Toolkit Version: 1.55.2.0 Visual Studio: VS Enterprise 2022, Version: 17.10.4

Initializing: Amazon Q Language Client AWS Toolkit was unable to find a compatible version of Amazon Q Language Server. Error installing Amazon Q Language Server. Amazon Q functionality is unavailable. See AWS Toolkit logs for details.

Relevant AWS Toolkit logs are included below.

This behavior started to exhibit with the release that added Amazon Q to the existing CodeWhisperer functionality.

To Reproduce

  1. Open Visual Studio (with or without an open solution)
  2. Extensions > AWS Toolkit > Getting Started
  3. Verify that the Getting Started window shows "Amazon Q enabled and connected to IAM Identity Center ([AWS profile name])"
  4. Click "Try Amazon Q with examples"
  5. Example code window will open, followed by the error sequence mentioned above

Expected behavior

Language server should be downloaded and initialized, and begin serving suggestions.

Toolkit Logs

Relevant section of AWSToolkit logs:

2024-07-22 14:04:57,628 [67] INFO Amazon.AwsToolkit.AmazonQ.Common.Lsp.Clients.ToolkitLspClient - Starting set up for language server: Amazon Q Language Client 2024-07-22 14:04:57,707 [15] INFO Amazon.AWSToolkit.ResourceFetchers.FileResourceFetcher - Loading resource: C:\Users\\<redacted>\AppData\Local/AWSToolkit\lsp\manifest\Amazon Q\0\manifest.json 2024-07-22 14:04:57,895 [92] INFO Amazon.AwsToolkit.AmazonQ.Common.Lsp.Manifest.VersionManifestFetcher - Version manifest cache has the latest contents 2024-07-22 14:04:57,915 [92] INFO Amazon.AWSToolkit.ResourceFetchers.HttpResourceFetcher - Loading resource: https://aws-language-servers.us-east-1.amazonaws.com/a8dafbc7-b928-4ca5-82b4-c261f51dd39f/servers.zip 2024-07-22 14:04:57,917 [92] INFO Amazon.AWSToolkit.ResourceFetchers.HttpResourceFetcher - Loading resource: https://aws-language-servers.us-east-1.amazonaws.com/a8dafbc7-b928-4ca5-82b4-c261f51dd39f/clients.zip 2024-07-22 14:04:59,027 [8] ERROR Amazon.AWSToolkit.ResourceFetchers.CallbackResourceFetcher - Failed to get resource: https://aws-language-servers.us-east-1.amazonaws.com/a8dafbc7-b928-4ca5-82b4-c261f51dd39f/clients.zip System.NullReferenceException: Object reference not set to an instance of an object. at Amazon.AWSToolkit.ResourceFetchers.CachingResourceFetcher.<>cDisplayClass6_0.<b0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.AWSToolkit.ResourceFetchers.CallbackResourceFetcher.d5.MoveNext() 2024-07-22 14:05:04,373 [8] ERROR Amazon.AWSToolkit.ResourceFetchers.CallbackResourceFetcher - Failed to get resource: https://aws-language-servers.us-east-1.amazonaws.com/a8dafbc7-b928-4ca5-82b4-c261f51dd39f/servers.zip System.NullReferenceException: Object reference not set to an instance of an object. at Amazon.AWSToolkit.ResourceFetchers.CachingResourceFetcher.<>c__DisplayClass6_0.<b0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.AWSToolkit.ResourceFetchers.CallbackResourceFetcher.d__5.MoveNext() 2024-07-22 14:05:04,374 [8] INFO Amazon.AwsToolkit.AmazonQ.Common.Lsp.Install.LspManager - Unable to download Amazon Q language server version v2.0.0. Attempting to fetch from fallback location 2024-07-22 14:05:04,377 [8] INFO Amazon.AwsToolkit.AmazonQ.Common.Lsp.Install.LspManager - AWS Toolkit was unable to find a compatible version of Amazon Q Language Server. 2024-07-22 14:05:04,377 [8] ERROR Amazon.AwsToolkit.AmazonQ.Common.Lsp.Install.LspManager - Error installing Amazon Q language server. The AWS Toolkit may have trouble accessing the Amazon Q service.

I am able to retrieve the specified clients.zip in a browser by pasting the above URL, so it appears to be an issue in the class mentioned in the stack trace.

Development System (please complete the following information):

Additional context

Possibly relevant: my user profile that I run Visual Studio under does not have admin rights to add/remove software or extensions. I have a separate admin profile that I can log into to perform these steps, but that profile does not have a license to run Visual Studio.

The path mentioned above, in the log excerpt, is for my standard user profile.

shruti0085 commented 1 month ago

Hi @kmillerdevx3, Can you try closing all instances of Visual Studio, delete the contents of this folder %UserProfile%\%LOCALAPPDATA%\aws\toolkits\language-servers\AmazonQ\2.0.0\, restart VS and try again?

You mentioned you have been having issues since the release that added Amazon Q chat support. Have you been seeing issues since v1.54.x.x or only with the latest version 1.55.2.0? Was there a version of the toolkit that worked successfully for you?

kmillerdevx3 commented 1 month ago

I have no 2.0.0 folder inside the AmazonQ folder.

Yes, this issue has persisted since v1.54 - assuming that's when AmazonQ was added. I don't know the toolkit version numbers prior to that, and they don't appear in the release list here on GitHub; the versions with only CodeWhisperer worked (as of CodeWhisperer 1.0.0), it was just with the release of AmazonQ that it stopped working.

awschristou commented 1 month ago

Hi @kmillerdevx3 , can you try going to these urls from a browser on the same system? This will help rule out that something like a firewall would prevent the successful downloading of these files:

You can delete the files after they are downloaded.

kmillerdevx3 commented 1 month ago

@awschristou As mentioned in the original post, I am able to download the files in a browser.

shruti0085 commented 1 month ago

Hi @kmillerdevx3, Can you check if the following environment variables match the listed expected values from when you use Visual Studio from your standard user profile?

kmillerdevx3 commented 1 month ago

@shruti0085 I had the first two (TMP and TEMP) already set correctly. I did not have USERPROFILE, but adding it made no difference - same error.

shruti0085 commented 1 month ago

Thanks for confirming. Can you try a couple more things:

kmillerdevx3 commented 1 month ago

@shruti0085 Cleared the \0\ and \Local\Temp folders, with no change.

shruti0085 commented 1 month ago

Can you please share your latest toolkit log file after redacting any sensitive information? Out of curiousity, I am interested to know what version folders are listed for you in this location?

C:\Users\%username%\AppData\Local\aws\toolkits\language-servers\CodeWhisperer\ C:\Users\%username%\AppData\Local\aws\toolkits\language-servers\AmazonQ : this will likely be empty

kmillerdevx3 commented 1 month ago

@shruti0085: Current log - I think I got any sensitive data.

I have no language-servers\CodeWhisperer\ folder any longer - when working through the issue where the AWS Toolkit didn't appear in the Visual Studio extensions list I uninstalled the toolkit and removed all artifacts.

The AmazonQ folder is empty. When the toolkit is trying to install the language server, I do see a 2.0.0 folder appear here, but it gets deleted right away - too fast for me to see if anything got placed there.

Unrelated (I think) - the full log includes an error related to the default profile. I haven't bothered to mention it previously because I also get this error in VSCode (in which Amazon Q works just fine) and we use SSO profiles - which the toolkit Getting Started screen reports as logged in - rather than the default profile so I've never really thought about it.

kmillerdevx3 commented 1 month ago

@shruti0085 Also, as mentioned in my previous comment, the Toolkit keeps disappearing from the list of installed extensions (even though it is still installed) - I keep going through the steps in the linked ticket, it reappears in the list for some undefined amount of time, then disappears again. I just noticed that it's gone again.

shruti0085 commented 1 month ago

@kmillerdevx3 we have released v1.56.0.0 of the Toolkit which adds logging to help us better understand and troubleshoot this issue. Can you please install that version and share your logs?

the Toolkit keeps disappearing from the list of installed extensions (even though it is still installed)

Have you already attempted the guidance listed in #452 and #451?

kmillerdevx3 commented 1 month ago

@shruti0085 Yes, as mentioned, I've gone through those steps every time it disappeared.

With 1.56.0.0, here is the updated section of the logs, possible sensitive data obfuscated:

2024-08-05 16:16:07,588 [15] INFO Amazon.AWSToolkit.ResourceFetchers.FileResourceFetcher - Loading resource: C:\Users[userprofile]\AppData\Local/AWSToolkit\lsp\manifest\Amazon Q\0\manifest.json 2024-08-05 16:16:07,848 [111] INFO Amazon.AwsToolkit.AmazonQ.Common.Lsp.Manifest.VersionManifestFetcher - Version manifest cache has the latest contents 2024-08-05 16:16:07,871 [111] INFO Amazon.AWSToolkit.ResourceFetchers.HttpResourceFetcher - Loading resource: https://aws-language-servers.us-east-1.amazonaws.com/a8dafbc7-b928-4ca5-82b4-c261f51dd39f/servers.zip 2024-08-05 16:16:07,874 [111] INFO Amazon.AWSToolkit.ResourceFetchers.HttpResourceFetcher - Loading resource: https://aws-language-servers.us-east-1.amazonaws.com/a8dafbc7-b928-4ca5-82b4-c261f51dd39f/clients.zip 2024-08-05 16:16:09,064 [61] ERROR Amazon.AwsToolkit.AmazonQ.Common.Lsp.Install.LspManager - Computed hash [hash1] does not match expected [hash2] for clients.zip 2024-08-05 16:16:09,066 [61] INFO Amazon.AWSToolkit.ResourceFetchers.CallbackResourceFetcher - No contents fetched for https://aws-language-servers.us-east-1.amazonaws.com/a8dafbc7-b928-4ca5-82b4-c261f51dd39f/clients.zip using ConditionalResourceFetcher. 2024-08-05 16:16:15,395 [61] ERROR Amazon.AwsToolkit.AmazonQ.Common.Lsp.Install.LspManager - Computed hash [hash3] does not match expected [hash4] for servers.zip 2024-08-05 16:16:15,399 [61] INFO Amazon.AWSToolkit.ResourceFetchers.CallbackResourceFetcher - No contents fetched for https://aws-language-servers.us-east-1.amazonaws.com/a8dafbc7-b928-4ca5-82b4-c261f51dd39f/servers.zip using ConditionalResourceFetcher.

Not sure what his Github handle is, but I was able to work with Aniket Braganza (AWS) to get the toolkit running locally using the Amazon Q settings block in Visual Studio. That obviously isn't the ideal long-term solution, but will work short-term until we can figure out the issue logged above. I think the current working theory is that it might be related to Bitlocker, or possibly some other security software running on our corporate laptops.

shruti0085 commented 1 month ago

Thanks for verifying and for sharing your logs. Yes, we were able to work with Aniket(AWS) to provide a workaround for now. We are currently investigating this and are looking into the reasons for the discrepancy in the hash computation.

kmillerdevx3 commented 1 week ago

I never provided an update, but this was ultimately tracked down to a conflict with NetSkope, our ZTN provider. Our IT NetSec department deployed a fix that resolved the issue - something in NetSkope was causing the hashes not to match. (Not on that team so I don't know the details - sorry.)

After this update, the Q language server installs and works as expected without workarounds.

shruti0085 commented 1 week ago

Thank you for providing an update and sharing the source of the issue. Glad after the fix, it is working as expected.