NomarCub / obsidian-open-vscode

Open vault in VSCode button for Obsidian.md
MIT License
97 stars 5 forks source link

Plugin doesn't open my vault in VS Code #3

Closed kenanmike closed 3 years ago

kenanmike commented 3 years ago

I've downloaded and enabled the plugin, but when I either click the ribbon or select command from the command palette, Obsidian freezes for a couple of seconds then nothing happens. I'm on MacOS Big Sur 11.4, using the latest version of Obsidian and the latest version of the plugin. VS Code itself works fine for me.

NomarCub commented 3 years ago

I don't have a mac to test on, so please help me out here.

Have you tried the URL option? What happens when you use a shell outside of Obsidian to launch VSCode with the vault (code {{vault path}})? If you open the developer view in Obsidian (Ctrl + Shift + I on Windows), do you see an error log?

kenanmike commented 3 years ago

Yes, URL works! Thanks. As far I’m concerned there’s no issue now. But to answer you directly, after putting the vault path, using the shell doesn’t work, and there’s no errors in my error log strangely. As I said, though, URL works great, and on Mac first time you can even not to get asked again whether to open it, so it works lightning fast now.

On 9 Aug 2021, at 11:31, NomarCub @.***> wrote:

I don't have a mac to test on, so please help me out here.

Have you tried the URL option? What happens when you use a shell outside of Obsidian to launch VSCode with the vault (code {{vault path}})? If you open the developer view in Obsidian (Ctrl + Shift + I on Windows), do you see an error log?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FNomarCub%2Fobsidian-open-vscode%2Fissues%2F3%23issuecomment-895115836&data=04%7C01%7C%7C81f59575227f4acd1c5708d95b20d652%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637641018866985970%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=gtpg68QDH3T7ZGg4q38tCaz1SoEBuDbF%2F2oHFwWlGXA%3D&reserved=0, or unsubscribe https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAULLIMIWDXQZ5FRTFKO56LDT36U7XANCNFSM5BZUFZSA&data=04%7C01%7C%7C81f59575227f4acd1c5708d95b20d652%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637641018866995919%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=VUqjv1bTOaHEL4bsSrCswOnqp%2BfwKpc71GtNVwxxN4c%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOS https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7C81f59575227f4acd1c5708d95b20d652%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637641018866995919%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=SQvEJS8RDWZrI4%2BrkhULMFyAL9b2G3k%2BrC0xE2bDbPw%3D&reserved=0 or Android https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26utm_campaign%3Dnotification-email&data=04%7C01%7C%7C81f59575227f4acd1c5708d95b20d652%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637641018867005882%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=CIKfbIqy%2BPfg%2FQ3U6QdWtuJGq6q42SkHBpZWZ1rQmT4%3D&reserved=0.

NomarCub commented 3 years ago

Glad it works now! If more people have this issue, I'll probably update the readme to make things clearer, and set the URL method as default.

andynameistaken commented 3 years ago

Yeah, bumped at this issue too. If you are working on Linux you can always check sosumi for mac testing

NomarCub commented 3 years ago

Thanks for the recommendation. Did you have the same issue, and resolved it with the URL method too?

huyz commented 3 years ago

I have the same problem with macOS 11.5. But I can't switch to the URL method because I'm trying to open a Dendron workspace, which requires that I use the command: code "{{vaultpath}}/../dendron.code-workspace" to work.

And there are no errors in the Obsidian Developer Console.

NomarCub commented 3 years ago

Does the command (with vaultpath substituted) work in a normal shell?

If not I could make some modifications with more logging to send you.

huyz commented 3 years ago

The command in the shell does work. I go to the vault and run: code "$PWD/../dendron.code-workspace"

Sure, I can take your mods

NomarCub commented 3 years ago

Here's a modified main.js with more logging.

This plugin uses Node.js child_process to execute, which I know nothing about, so I may not be able to offer a timely solution or any.

main.zip

huyz commented 3 years ago

Thanks, that extra logging didn't help but you pointed me to the code where I could add my own logging. It turns out that we needed the full path of code.

So this worked: /usr/local/bin/code "{{vaultpath}}/../dendron.code-workspace" I don't know why /usr/local/bin isn't in the $PATH for Obsidian on macOS.

Btw, this is the debugging code that helped me figure it out, which you may want to add to your code:

              const execResult = exec(command, (error, stdout, stderr) => {
                if (error) {
                  console.error(`exec error: ${error}`);
                  return;
                }
              });
NomarCub commented 3 years ago

I'm glad it works, and thanks for the tip! I made a new release adding this, I hope it can help others in the future as well.