Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kenanmike opened this issue Aug 9, 2021 · 11 comments
Closed

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

kenanmike opened this issue Aug 9, 2021 · 11 comments

Comments

@kenanmike
Copy link

@kenanmike kenanmike commented Aug 9, 2021

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
Copy link
Owner

@NomarCub NomarCub commented Aug 9, 2021

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
Copy link
Author

@kenanmike kenanmike commented Aug 9, 2021

@NomarCub
Copy link
Owner

@NomarCub NomarCub commented Aug 9, 2021

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.

@NomarCub NomarCub closed this Aug 9, 2021
@NomarCub NomarCub pinned this issue Aug 9, 2021
@andynameistaken
Copy link

@andynameistaken andynameistaken commented Aug 16, 2021

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

@NomarCub
Copy link
Owner

@NomarCub NomarCub commented Aug 17, 2021

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

@huyz
Copy link

@huyz huyz commented Oct 5, 2021

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
Copy link
Owner

@NomarCub NomarCub commented Oct 5, 2021

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
Copy link

@huyz huyz commented Oct 5, 2021

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
Copy link
Owner

@NomarCub NomarCub commented Oct 5, 2021

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
Copy link

@huyz huyz commented Oct 5, 2021

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 added a commit that referenced this issue Oct 5, 2021
@NomarCub
Copy link
Owner

@NomarCub NomarCub commented Oct 5, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants