Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is VSCode "Unable to open Extension. An unknown error occurred."?

This is my first time installing and using VSCode, and when I tried installing Prettier extension, it let me peek quickly at the extension page before closing it and displaying this notification (Screenshot attached):

Unable to open 'Extension: Prettier - Code formatter': An unknown error occurred. Please consult the log for more details..

VSCode screenshot: Notification at bottom right

It's doing this with all other extensions. Searched for a solution but found nothing applicable. Why is this happening and how to fix it?

like image 920
Seif A. Avatar asked Apr 13 '20 15:04

Seif A.


People also ask

How do I fix VS Code error?

Use Quick Actions to fix or refactor code Or, when your cursor is on the line with the colored squiggle, press Ctrl+. or select the light bulb, error light bulb, or screwdriver icon in the margin. You'll see a list of possible fixes or refactorings you can apply to that line of code.

How do I enable an extension in VS Code?

You can browse and install extensions from within VS Code. Bring up the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of VS Code or the View: Extensions command (Ctrl+Shift+X). This will show you a list of the most popular VS Code extensions on the VS Code Marketplace.

Why my VS Code extension is not working?

The solution was to go to Windows PowerShell and open Visual Studio Code, then go to the extensions and restart the Remote - WSL extension, and go back to WSL. It then started working immediately.


2 Answers

It probably is because of the certificate check.

Below solution works for me in CentOS 7 (Linux).

Step 1. Change the file /usr/share/applications/code.desktop

Open the file /usr/share/applications/code.desktop, then modify the Exec value with adding --ignore-certificate-errors before %F:

Exec=/usr/share/code/code --unity-launch --ignore-certificate-errors %F

Save the file with typing sudo in the begining.

the file code.desktop

Step 2. Close all windows of vs code instances.

Step 3. Back to the terminal, use below command to open VS code:

code --ignore-certificate-errors

Step 4. Click extension button in the left side bar.

Click any extension like "Ruby" by Peng Lv, if the images in the Details page can be seen successfully, perhaps the issue is solved.

Step 5. Try to continue to install the extensions you need.

Just enjoy! May it be helpful for you.

like image 160
Bravo Yeung Avatar answered Oct 20 '22 04:10

Bravo Yeung


For windows

    cd "C:\Users\<user>\Appdata\Local\Programs\Microsoft VS Code"
    code.exe --ignore-certificate-errors
like image 34
linzwelch Avatar answered Oct 20 '22 03:10

linzwelch