2

I currently try to develop a Visual Studio Code extension for extension deployment. What my extension should do is install another extension from the Marktplace.

The obvious way to do that (at least i thought it is) is to create a child process and execute

code --install-extension publisher.extension_name

This command usually works fine, but when it gets executed from within the plugin it returns: "Error: Command failed: bad option: --install-extension".

The first thing i thought is that the extension wouldn't execute the command in the right way, so i tried running "dir C:\Users" just as a test and that worked perfectly fine. After that i tried to run

code --list-extensions

but it returned with the same error. So it looks like I am unable to run any command from within the plugin which uses visual studio code itself. Can someone explain this behaviour ? Does anyone know if there is a better way to install an extension from an extension ?

2
  • 1
    if you depend on that extension you can name it in the package.json Commented Nov 17, 2020 at 12:09
  • Try not assuming that code will resolve to the VS Code executable. Commented Nov 17, 2020 at 12:49

2 Answers 2

2

So i found a solution: Instead of launching a child process (which doesn't work for whatever reason as described above), I used the vscode API and run my command with:

vscode.window.createTerminal().sendText("code --install-extension your.extension");

I still don't understand why my first idea doesn't work, but this one does. What i should have probably stressed in my question is that the whole purpose of the plugin is to deploy other plugins from the marktplace. The plugin itself is not dependent on another one, so using the package.json as proposed in the comments wasn't possible.

Sign up to request clarification or add additional context in comments.

Comments

0

i got same problem, use powershell.exe salve the problem

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.