Download Visual Studio Code extensions behind proxy - visual-studio-code

Despite setting the http.proxy setting, I am unable to download extensions (or browse extensions).

I found that if I start the program with --proxy-server=http://myproxy.example.com:3128 then it works.

The code-server used for remote development doesn't support the --proxy-server flag.
The workaround I have found is to manually download the .vsix extension archive for the extension I want to install. e.g. from here: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools there's a "Download Extension" drop down on the right under "Resources" where I can download the extension for the server's platform.
Then, move this archive to the target server. Since I'm using an ssh remote, I just scp it over.
Then, install the extension from the archive:
~/.vscode-server/bin/<id>/bin/code-server --install-extension /path/to/archive.vsix
And this should install the extension. I had to restart the editor a few times before the extension showed as installed in the editor as well.

Related

Installing a local unpackaged VSCode extension

I'm trying to install a custom version of a VSCode extension without packaging it into a .vsix file. I've copied an existing extension in ~/.vscode-server/extensions/original-extension to ~/.vscode-server/extensions/my-custom-extension with my modifications, but VSCode doesn't seem to detect that it's there: it's not in the Extensions sidebar after reloading the window, etc.
I've also tried and failed to install the custom extension locally in case it was something specific to the remote setup (copying into ~/.vscode/extensions and running VSCode locally), so that doesn't seem to be the issue.
From these (possibly outdated) docs, it seems like side-loading by just copying into the extensions folder should work: https://vscode-docs.readthedocs.io/en/stable/extensions/install-extension/#sharing-privately-with-others-side-loading . Is there a way to get VSCode to detect my extensions folder? What am I missing?

rust-analyzer failed to load workspace: "cargo" "--version" failed: program not found

I have Rust installed using WSL2 Ubuntu I have alredy ran basic commands like hello world in rust so cargo is working. I wanted to download the rust-analyzer in VSCODE but I keep getting that error message from the title: rust-analyzer failed to load workspace: "cargo" "--version" failed: program not found
I tried ensuring all paths are correct, all vesions of extension and vscode and rust are up to date. several uninstall re-installs and rustup updates. Toolchain is using stable version. I have reviewed a lot of the other post about this accross all platforms but it seems I can not find the fix. It would be very helpful to get some guidance. Thank you!st
The solution is to open folder as if in WSL.
To do that you need to install this VS code extension called Remote development
Than go to the green symbol in the bottom right corner and then select open WSL folder and open folder with your rust project or just open new WSL window
The last step is to go to extensions and then search for rust-analyzer and hit install
More info regarding the development on WSL can be found here
another good option is open your wsl, move to the project folder and type $ code . or $ code YOUR_PROJECT, then install rust-analyzer extension
Remove the rustc and cargo provide by system package manager (e.g. apt).
Install them from offical rustup script instead.
[note]
I just encounter the same problem when using flatpak version of Lapce.
rust-analyzer failed to load workspace: "cargo" "--version" failed: No such file or directory (os error 2)

VS-Code installing omnisharp error unable to verify the first certificate

When attempting to install the Omnisharp Visual code extensions on my work machine, downloading the package fails and the extension does not install.
VS-Code version: 1.27.2
When I open a c# file the output window displays
Installing C# dependencies...
Platform: win32, x86_64
Downloading package 'OmniSharp for Windows (.NET 4.6 / x64)'... Failded at stage: downloadPackages
Error unable to verify the first certificate
I haven't got a particularly detailed knowledge of my work's network and firewall setup but from reading around it is pointing towards that being the culprit.
The issue was fixed for me by updating my settings.json file.
This file can be edited by following these steps:
File -> Preferences -> Settings (or press 'Ctrl + ,' on a windows setup with default key mappings)
The settings page now appears. Underneath the settings search bar on the right hand side is a little '...' icon. Click that and choose 'Open settings.json'
Once you have the settings.json file open you need to add a new setting, which is this
"http.proxyStrictSSL": false
Now restart VS-code and open up a C# file and the extension should install sucessfully.
I found this information here : https://github.com/Microsoft/vscode-cpptools/issues/605
The original issue was about a different extension but it worked for me

How to install VS code extension manually?

I am not able to download any extension via VS Code on my office system due to the proxy. Is there a way that I can do it manually by downloading and placing the downloaded files at the right place?
Download the extension from VSCode marketplace, it'll be a .vsix file, then do like the image below.
You can also use the command-line to install extensions from VSIX files using the --install-extension parameter.
code --install-extension /path/to/vsix
eg: code --install-extension vscodevim.vim
Just in case u have a same UI as mine. Happy coding!
You can also just drop the extension files into the correct folder. On mac, for example, this is ~/.vscode/extensions/. I'm unsure whether it works for all extensions, but it works just fine for a simple language specification.
Two notes when downloading an extension from VScode marketplace:
Version compatibility
Extensions are updated repeatedly on the marketplace. If you download and transfer it to the target computer, it may not work. One can try to look into version history of the extension and download the older version. But it is not easy to correlate the extension version with VSCode version. You can check the version of the extension on the online computer and try to find a match in the marketplace. But sometimes the older versions are not listed there.
Dependencies
An extension may have dependencies. When installing from within VSCode, VScode installs the dependencies for you. Good example is the Python extension that requires few other extension like Jupyter and pylance.
To handle these two cases easier:
1- Install the same VSCode version on the online (access to internet) computer as the offline (no access to internet) target computer.
2- From within the VSCode, install the desired extension. It will install the right version and all the dependencies.
3- Find the folder where extensions are installed. On windows, it is in: C:\Users\USER_NAME\.vscode\extensions. On Linux, it is ib ~/.vscode/extensions.
4- Copy and transfer the extensions to the target offline computer, in the extensions folder.
5- Restart the VSCode to see the extensions.
The below screenshot shows all the extensions that I transferred to have the python extension available on the target computer:

"No extensions found" when running Visual Studio Code from source

When I try to install any extension in Visual Studio Code (i.e., by pressing Ctrl+P and then running ext install RustyCode), I get a message that No extensions found.
However, this only happens when I run VS Code directly from source repository. I.e., after:
git clone https://github.com/Microsoft/vscode.git
cd vscode
git checkout 1.0.0
scripts/code.sh
But, if I run VS Code from official builds, then I'm able to install extensions.
So, how can I enable downloading and installing extensions from Visual Studio Marketplace when I run VS Code directly from source repository? (Is Visual Studio Marketplace integration bundled separately in official builds?)
I'm on Ubuntu/Linux.
This can be fixed by adding following to product.json:
"extensionsGallery": {
"serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
"cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
"itemUrl": "https://marketplace.visualstudio.com/items"
}
(This is can also be fixed by copying product.json from an official build (in the .zip archvie, product.json is under resources/app) which contains above lines).
More information: https://github.com/Microsoft/vscode/issues/1557
You can use code-marketplace extension in AUR to add microsoft marketplace registery in code OSS. This extension will installs a pacman hook that patches the file on every package update.
If you want to do the same for archlinux, have a look here => https://wiki.archlinux.org/index.php/Visual_Studio_Code , you have various possible options to solve the problem.
For Arch linux you could access the product.json file under this path - /usr/lib/code/product.json.
Just edit on the file the extensionsGallery with the following-
"extensionsGallery": {
"serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
"cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
"itemUrl": "https://marketplace.visualstudio.com/items"
}
like #Vikrant Chaudhary said.
Extending the answer from #Vikrant Chaudhary. If anyone wanted to do the same thing on Windows, the path to product.json is here:
Windows path for VSCodium: C:\Program Files\VSCodium\resources\app\product.json