question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Installing extensions from command line

See original GitHub issue

It would be great to be able to script the installation of extensions, e.g. after starting code-server in a new container.

A feature similar to VScode’s code --install-extension would be very helpful. See the example here.

Or am I missing another way to install extensions to code-server from the command line?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:16
  • Comments:19 (5 by maintainers)

github_iconTop GitHub Comments

12reactions
faustomoralescommented, Mar 17, 2019

@ThorbenJensen I think you can do this by just extending the Dockerfile as @jeasonstudio suggests.

For example, the following installs the Preview extension. I needed it because I couldn’t get the built-in Preview functions to work out-of-the-box and also it comes with Mermaid diagram support, which the built-in previewer does not.

RUN apt-get update && apt install -y bsdtar curl
RUN mkdir -p /root/.local/share/code-server/extensions
RUN curl -JL https://marketplace.visualstudio.com/_apis/public/gallery/publishers/searKing/vsextensions/preview-vscode/2.0.3/vspackage | bsdtar -xvf - extension
RUN mv extension /root/.local/share/code-server/extensions/searKing.preview-vscode-2.0.3

The lines above do the following.

  1. Install bsdtar and curl. We install bsdtar because gnutar, which ships with Ubuntu and Debian, doesn’t function properly with the archives we get from the Visual Studio web site.
  2. Create an extensions subdirectory for the code-server data directory. The data directory path above (/root/.local/share/code-server/) is the default from what I can tell. You can look at the logs to verify that it’s the same with your configuration. You’ll see something like INFO Initializing {"data-dir":"/root/.local/share/code-server","working-dir": ...,"log-dir": ...} when starting the container.
  3. Download and extract the extension file from the Visual Studio web site. The URL follows the form https://marketplace.visualstudio.com/_apis/public/gallery/publishers/<PUBLISHER>/vsextensions/<EXTENSION-NAME>/<VERSION>/vspackage. We only extract the extension folder.
  4. Move the extension folder to a properly named folder of the form <PUBLISHER>.<EXTENSION-NAME>-<VERSION> in the extensions subdirectory.

If all goes well, you should be able to get the following.

Screen Shot 2019-03-17 at 1 05 41 PM

Hope this helps!

9reactions
deansheathercommented, Aug 2, 2019

@jagraj The recommended way to install extensions now is to use code-server --install-extension <value>. You can give it the path to a .vsix file or the ID (looks like organization.extension-name).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing Extensions in Visual Studio Code
You can browse and install extensions from within VS Code. Bring up the Extensions view by clicking on the Extensions icon in the...
Read more >
cmd - How to install Visual Studio Code extensions from ...
To make it easier to automate and configure VS Code, it is possible to list, install, and uninstall extensions from the command line....
Read more >
How to install and manage Azure CLI extensions
Install extensions manually ... Once you have found an extension to install, use az extension add to get it. If the extension is...
Read more >
Install extension - vscode-docs
You can manually install an VS Code extension packaged in a .vsix file. Simply install using the VS Code command line providing the...
Read more >
How to Install Visual Studio Code Extensions
Find an extension and install it from the editor (GUI method) · Alternate method: Install extensions using the terminal.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found