Pierrad / obsidian-github-copilot

A bridge between Obsidian and Github Copilot
Apache License 2.0
55 stars 5 forks source link

Extension doesn't work on Flatpak installation #6

Closed timo-x30xe closed 1 month ago

timo-x30xe commented 1 month ago

Hello i went through the manual installation and the settings/ the button to enable and disable at the bottom appeared as expected. I added my node path "/usr/bin/node" but im still not getting any completion suggestions.

when opening the Console it shows an error being thrown at startup (Uncaught Error: write EPIPE) obsidian.md-1715152018123.log

I also never received the ready to use notice stated in step 4 of the installation.

Any guidance on what to try from here?

Pierrad commented 1 month ago

Hi @timo-x30xe, thanks for your interest!

From your log, it seems that the node process is not running as expected when we try to communicate with it. This possibly comes from a problem with your node path or your node version. Can you give more information about your node version?

If you installed the plugin by cloning the project, can you enabled the debugging mode (turn the setDebug to true l.30 in the main.ts file), it will give use more detail about the child process crash.

Pierrad commented 1 month ago

@timo-x30xe I've updated the code to add a "Test the path" button near the node path input in the plugin settings. It will check for you if the node path is accessible, executable and if the node version is correct.

You can get this update by pulling the last commit or downloading the last released files in the Release 1.0.0.

timo-x30xe commented 1 month ago

Hi, thanks for the update. I am using just the release file instead of building it from source.

Using the "Test the Path"-Button throws an error but nothing pops up in the Obsidian log (see Screenshot) image

The path is the same that is being returned by "which node" and the version is 20.12.0 image

There also now appears to be a "Copilot has stopped" notification popping up when enabling the extension.

timo-x30xe commented 1 month ago

I just realised it might have to do with Obsidian being a flatpak installation for me. so i tried adding "/var/run/host/" in front of my path which gives me a different error image

Pierrad commented 1 month ago

@timo-x30xe The errors you had indicates that the plugin cannot locate the node command and execute it.

I tried to replicate your setup using a VM and obsidian installed with flatpak and I had the same issue. Based on the documentation (https://docs.flatpak.org/en/latest/sandbox-permissions.html), every app installed with flatpak is sandboxed for security reason, it seems that it's possible to allow access to some files in the filesystem but /usr is restricted and blacklisted.

I managed to get access to a node binary by installing NVM on the VM (https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating), it will allow you to manage node version and install it under a folder accessible by flatpak sandbox (something like /home/<username>/.nvm/versions/node/v20.13.0/bin/node).

But I'm afraid you will have problem when accessing the copilot subscription stored on your host. Normally, it should be automatic but because of the sandbox context, it's possible that the child process will not be able to access your subscription on the host machine. If that's the case, please tell me and I will try to implement the sign-in process in the plugin.

Pierrad commented 1 month ago

@timo-x30xe I've implemented the sign-in process in case you need it. You can download the files from the release 1.0.0.

If you're not signed in, a popup will appear with instruction to follow.

Don't hesitate to tell me if it works for you or not

timo-x30xe commented 1 month ago

@Pierrad Thank you! The Method you described worked flawlessly. Didn't expect you to go through that trouble reproducing it with a VM for such a niche issue. I also used the Sign-in Process as it popped up and it worked without any issues Thanks for the fast response and the great work on the plugin!