VS Code command "workbench.extensions.installExtension" Not installing extensions - visual-studio-code

So I'm developing an extension for saving settings and extension profiles in VS Code, but have hit another bit of weirdness. When I'm loading a profile I pass a list of extension ID's from the profile to be loaded to a function to install:
/**
* Attempts to install the extensions by the ID's provided in the passed
* extension ID list.
*
* #param extensionIds - List of extension ID's for extensions to install
*/
public async installExtensions(extensionIds: Array<string>) {
// Iterate over extension ID's
for (const extensionId of extensionIds) {
// Call vscode built-in command to install the extension
await commands.executeCommand("workbench.extensions.installExtension", extensionId);
}
}
It doesn't come up with a prompt asking me whether to install or not (like it should), just starts installing
Even shows in the logs it installed successfully
But just goes back to not being installed after
For reference, I'm debugging this extension in remotes on a local docker container. Am I doing something wrong? or does the command not work on remotes? However if I try to install an extension that installs companion extension like formulahendry.auto-close-tag, which installs another extension formulahendry.auto-rename-tag with it, it comes up with the prompt
and actually installs.
Link to repo - https://github.com/SLGShark6/vscode-profile-manager/tree/development
Link to function that loads the profile - loadProfile()
Link to function that installs extensions - installExtensions()
N.B. you probably won't be able to use the dockerfile in the repo ATM, I need to fix that.

Related

custom vscode extension not working over ssh

I created a vscode extension for the first time..I used LSP(language server protocol) and having both client and server bundled as one extension.
The extension has highlighting and autocomplete features for a custom file type. I packaged it using vsce I got a VSIX file. I installed the extension in my vscode using the .vsix file.
The extension works when i am working on local files.
However, i connected to a remote VM using the ms-vscode-remote.remote-ssh extension such that I can view the remote files in vscode, but here my created extension is not working. I can't even see the file type i created.
Any help is appreciated. Is there some specific setting I need to put in my package.json
For your extension to properly work remotely, either installed on host or on the remote, you have to follow a few guidelines, and yes, there are some settings that you may take care of on package.json.
The first and more complete source of information is Supporting Remote Development and GitHub Codespaces API documentation. It describes the architecture, settings, how to debug, common problems and so on. There is also the Extension Host page, where it describes the Preferred extension location topic, which tells you how to configure your extension to work on the correct location.
Based on your description (a LSP related extension) I understand your extension should be a Workspace Extension. This means that you should have this on your package.json:
"extensionKind": [
"workspace"
]
The Commons Problem section describes how you can evaluate and fix Incorrect execution location. To debug using SSH follow these instructions.
Also, remember that while working with remotes, you rely on local paths anymore. Instead you must always deal with Uri, whenever possible.
I guess after reviewing your settings, based on the docs related above, you should be able to detect what is happening on your extension and fix it. Give debug a try, it will be much easier to detect issues than installing the vsix and look for erros in Console.
Hope this helps

how to add my own h5p interactive video in h5p in moodle

I tried to find the solution to my question everywhere without a result.
Let me explain the problem. I have a moodle docker. We can install H5P there by following these steps in: https://github.com/h5p/moodle-mod_hvp
Now we can manually install the H5P libraries like Interactive Video, Quiz, etc. from the moodle running. We just have to Create a new course>H5p Interactive Content>Get and Install any library.
There are separate GitHub repos for these libraries. Now, for my own work, I have made some forked and made some changes to some of these repos of these libraries. Now I want to install my H5P libraries in my moodle without making to Pull request to the original H5P interactive video GitHub page.
I found that we can make some changes in the renderer.php as stated in: https://github.com/h5p/h5pmods-moodle-plugin
I have git cloned H5P along with my x.js file in moodle/mod. So the folder structure is moodle/mod/hvp/{all the files from H5P Interactive Video + my x.js}
Following the steps from https://github.com/h5p/h5pmods-moodle-plugin, I am doing:
/**
* Add scripts when an H5P is displayed.
*
* #param object $scripts Scripts that will be applied.
* #param array $libraries Libraries that will be displayed.
* #param string $embedType How the H5P is displayed.
*/
public function hvp_alter_scripts(&$scripts, $libraries, $embedType) {
console.log(process.cwd());
global $CFG;
$scripts[] = (object) array(
'path' => 'x.js',
'version' => '?ver=0.0.1',
);
}
However, it is not working. I have already checked (without docker exec) that all the files are in the moodle/mod/hvp. I wonder if this strategy at all will work for something other than some styling css.
Can someone help me out here?

vscode extension development: svelte content not loading in webview after building the vscode extension

I am building a vscode extension by using svelte for webview. I am following https://youtu.be/a5DX5pQ9p5M. But the deployment of extension is not mentioned in the tutorial .
So i am following https://code.visualstudio.com/api/working-with-extensions/publishing-extension.
So after packaging the extension with vsce package and installing the extension the extension doesn't load svelte content but when running in developer mode everything works fine.
I tried creating the package extension multiple Times but still didn't work.
Check if all necessarily files are included via:
vsce ls
(You can also open packaged extensions, they are just ZIP-archives with a different extension.)
If they are not (e.g. src is excluded by default), you probably can create a .vscodeignore file and manually specify what to exclude.
Running extension problems can be inspected via Help > Toggle Developer Tools, usually you will find some errors in the console.
I do not know if debugging forces the extension to load, but if so, make sure you have set the correct activationEvents.

In visual studio code how to download a zip file when user install the extension

Right now my extension needs a package to work. Due to some reasons, I cannot ship this in the vsix. So when a user installs the extension and clicks on any function the call comes to the activate function for the first time then I download the package(zip) file. But I want to download the zip file when a user clicks on the install extension itself.
Is it possible to download a zip file when the user clicks on the install button in the visual studio code?
please let me know if you need any further info.
Thanks,
Akhil

How does an extension for VS Code get the install path of VS Code?

I'm developing an extension for VS code(Using javascript). Now I need the path where VS Code installed.
There is a way for windows:
var child = require('child_process');
child.exec('reg query HKEY_CLASSES_ROOT\\*\\shell\\VSCode /v Icon', function (error, strOut, strError) {
//some code...
})
But it works while user installed VS Code correctly only. If this folder was copied from other machine (it means nothing of VS Code in Registry), this function will fail.
On the other hand, it couldn't work at all on Linux or OS X.
I wonder if there are APIs which can be helpful(I found nothing), or other ways can get that path.
I don't know why are you need directory of VSCODE but I needed the directory where are my extesion.
And it can be accessed as follows:
var myExtDir = vscode.extensions.getExtension ("publisher.name").extensionPath;
Where publisher and name are in package.json
VSCode is written and uses node.js, therefore you can access both the computer, user and node environment variables.
To get the used install path of VSCode you can use the following;
process.env.VSCODE_CWD
For instance, if the first thing my extension did was;
console.log(process.env.VSCODE_CWD) it would print out the following in the debug console C:\Program Files\Microsoft VS Code (This is where I have installed VSCode to).
You can now use
const vscodeInstallPath = vscode.env.appRoot;
I thought I'd add the answer that you found yourself in case other people come looking for the same thing.
path.dirname(require.main.filename);
in Ubuntu returns (for me)
/usr/share/code/resources/app/out
and in Windows, returns
c:\Program Files\Microsoft VS Code\resources\app\out
It should return something appropriate for OSX too.
This is the folder containing bootstrap.js, which is enough to determine where the application is installed (the default locations in this instance).
In my case, I wanted the path to one of the node modules (vscode-ripgrep) which is built as part of vscode, so I have to process the path a bit more, but it does the job.