Seif A.
Seif A.

Reputation: 674

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?

Upvotes: 21

Views: 66928

Answers (12)

Anusha Syeda
Anusha Syeda

Reputation: 1

Same issue i have faced today. i was unable to install Prettier extension in vs code then i found this .VSIX file that helped me to solve the problem easily. following are the steps.

  1. Go to this link (https://www.vsixhub.com/vsix/47/)
  2. Download this .VSIX file from above link.
  3. after installation of .VSIX file in your local pc, open VS code
  4. open "Extensions" or [ctrl+shift+x]
  5. type "Prettier" in search bar.
  6. click on three dots as highlighted in image in VS code
  7. At the bottom - click on (Install from VSIX...) and select your .VSIX file which you have previously downloaded ["prettier-vscode-10.1.0_vsixhub.com.vsix"]
  8. your "Prettier" extension will be installed successfully.

Upvotes: 0

linzwelch
linzwelch

Reputation: 41

For windows

    cd "C:\Users\<user>\Appdata\Local\Programs\Microsoft VS Code"
    code.exe --ignore-certificate-errors

Upvotes: 4

chill appreciator
chill appreciator

Reputation: 422

In my case I was need to disable work VPN to download extension

Upvotes: -1

S.ahmed
S.ahmed

Reputation: 31

The solution

  1. clear DNS cache using command on Windows cmd: ipconfig /flushdns

  2. change the default DNS servers in your router settings to Google's:

    8.8.8.8 , 8.8.4.4 >> for IPv4

    2001:4860:4860::8888 , 2001:4860:4860::8844 >> for IPv6

    This link will guide you how to change the DNS server in windows and mac: https://www.ionos.com/digitalguide/server/configuration/how-to-change-dns-server/

  3. restart VSCode and try installing extensions.

Upvotes: 3

Seif A.
Seif A.

Reputation: 674

It happens that, this is a problem with the Egyptian ISPs' default DNS servers, which are most probably blocking some of Microsoft servers.

The solution (in case you live in Egypt):

  1. clear DNS cache using ipconfig /flushdns command on Windows cmd (For Other OS).
  2. change the default DNS servers in your router settings to Google's 8.8.8.8 & 8.8.4.4 (or Cloudflare's 1.1.1.1 or any other DNS server you trust).
  3. restart VSCode and try installing extensions.

Hopefully, everything will work fine by now.

Check this Github issue for more insight.

Upvotes: 36

A Hagrasi
A Hagrasi

Reputation: 25

I faced the same problem while adding new extension in vs code. I Recognized the problem within the ISP in Egypt, so I changed the DNS in My router to Google DNS Providers , and it works perfectly

Upvotes: 1

Abdelrahman Tareq
Abdelrahman Tareq

Reputation: 2297

Just install a VPN like betternet or any other VPN software and change the country to the USA or try other countries.

Upvotes: 0

Jeremy Thompson
Jeremy Thompson

Reputation: 65534

If you're in a corporate network and it's locked down the one last resort is to manually download the VSIX from the website on a domain that will allow it and then copy over the VSIX and install it.

Upvotes: 2

Bravo Yeung
Bravo Yeung

Reputation: 9840

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.

Upvotes: 8

Eslam Magdy
Eslam Magdy

Reputation: 11

referring to @Seif A. answer

The solution (in case you live in Egypt)

clear DNS cache using command on Windows cmd:

ipconfig /flushdns

change the default DNS servers in your router settings to Google's:

8.8.8.8 , 8.8.4.4  >> for IPv4
2001:4860:4860::8888 , 2001:4860:4860::8844  >> for IPv6

restart VSCode and try installing extensions.

Upvotes: 1

YMH
YMH

Reputation: 3093

I got this "XHR failed" error in Visual Studio Code.

So I changed my network settings to use Google Public DNS (instructions)

Finally following instructions (by mohamed-mokhtar) solved for me:

  • Go to : Control Panel\Network and Internet\Network Connections
  • Choose your connection network and ( right click on it then choose properties )
  • Select " Internet Protocol Version 4 (TCP/IPv4) and then click on properties in the bottom of this section
  • At General section click on " Use the following DNS Server address : "
  • Make " Preferred DNS server : 8.8.8.8 " (if you face a problem check this)
  • Make " Alternate DNS server : 8.8.4.4 "
  • Restart VS code

Upvotes: 1

mohamed elshazly
mohamed elshazly

Reputation: 548

in ubuntu go to settings -> wifi -> click on gear icon -> IP4 -> dns input and put

8.8.8.8,8.8.4.4

and click apply, to DNS Resolver Cache open terminal and type:-

sudo systemd-resolve --flush-caches
sudo systemctl restart systemd-resolved

restart your device

Upvotes: 4

Related Questions