notesmd-cli icon indicating copy to clipboard operation
notesmd-cli copied to clipboard

Cannot set-default Vault in WSL

Open hGriff0n opened this issue 10 months ago • 14 comments

Describe the bug I have setup WSL and installed obsidian-cli inside of an Ubuntu environment. I have an existing Obsidian install in standard Windows 11 which has the vault I'm trying to default. These files are accessible from within WSL via /mnt/c/Users/%USER%/%PATH_TO_VAULT%.

However, everytime I try to run obsidian-cli set-default $vault I get an error complaining about a missing config file - Failed to read Obsidian config file. Please ensure vault has been set up in Obsidian. Unfortunately, simply running the cli natively in windows is not an option for various reasons.

To Reproduce Steps to reproduce the behaviour:

  1. Which command?
wsl -u username
obsidian-cli set-default "my-vault"
  1. What version obsidian-cli --version version v0.2.2
  2. Vault state? Exists and is completely accessible from Windows

Expected behaviour It sets the default-vault to my-vault

Additional context Specifically, I'm trying to set this up with clawdbot/moltbot and the installation process for that setup requires using WSL on Windows.

hGriff0n avatar Jan 27 '26 21:01 hGriff0n

obsidian-cli set-default "obsidian" export OBSIDIAN_VAULT_PATH="/data/obsidian"

@hGriff0n

tangyoha avatar Jan 28 '26 04:01 tangyoha

@tangyoha so your saying I need to set the environment variable to the obsidian vault directory before running the command? I'll try that and report back on if it works

hGriff0n avatar Jan 28 '26 12:01 hGriff0n

Hmm, get the same error when I try that.

export OBSIDIAN_VAULT_PATH="/mnt/c/Users/ghoop/Desktop/my-vault"
obsidian-cli set-default "my-vault"

hGriff0n avatar Jan 28 '26 12:01 hGriff0n

Hello, I am sorry I don't know of a way to make this work in WSL (I cannot experiment as I do not use Windows). My guess would be that it is not possible as obsidian-cli uses the Obsidian config file, which is only populated when the GUI application opens.

Maybe another Windows WSL user might know more so I will leave this issue open

Yakitrak avatar Jan 28 '26 20:01 Yakitrak

The windows file system is still accessible from WSL and I was hoping it would grab it from there. But I guess because of the linux shim that is WSL, it's expecting it to be somewhere else. Theoretically, we just need to redirect that search, but not sure if it'll be an ugly solution.

hGriff0n avatar Jan 30 '26 02:01 hGriff0n

I'm not too used to Go, but I cant find any code reference to OBSIDIAN_VAULT_PATH. Either way assuming it wouldn't matter here because obsidian.json isnt isn't in the {Vault}/.obsidian dir, but in %APPDATA%\obsidian.

I think the problem traces to https://github.com/Yakitrak/obsidian-cli/blob/f6d1fcbf3dd0e6334b15a166b31c9a338526fc8d/pkg/config/cli_path.go#L9 . Because it's running inside wsl, that's would be ~/.config/obsidian instead of Window's %APPDATA%\obsidian. Allowing folks to override that manually to the mounted mnt/c/users/ghoop/AppData/Roadming/obsidian (or wherever their IRL config is located) should be all it takes.

Image

justlevine avatar Jan 31 '26 14:01 justlevine

This is a blocker for those of us running openclaw on windows and using WSL. I can see the mount and the files in /mnt but the CLI doesn't see them.

sedetweiler avatar Feb 01 '26 17:02 sedetweiler

I have submitted a PR for linux (https://github.com/Yakitrak/obsidian-cli/pull/76) that deals with a similar issue if Obsidian was installed via flatpak instead of the deb. Someone with a windows box could use the same method to "fix" this problem for Windows+WSL.

mikesale avatar Feb 04 '26 01:02 mikesale

Okay I have a PR ready in a local branch once #76 is merged in.

/proc/sys/fs/binfmt_misc/WSLInterop allows for checking that we are in WSL. The tricky part is resolving to the mounted appdata directory - eventually settled on cmd.exe /c echo %APPDATA%

hGriff0n avatar Feb 08 '26 17:02 hGriff0n

Okay I have validated that this does work. Also had to modify vault_path.go because the obsidian config for a windows-based obsidian install stores paths as windows file paths. My solution only recognizes C: drives at the moment - not sure of a safe, general way to extend that to other drives. I'll need to fork the repo in order to actually push the pull request though.

I'm now also wondering if this is actually a good idea - the official WSL docs recommend to not write across the windows-linux boundary. Need to double-check if that's a hard rule or just a warning about apps not handling the line endings.

hGriff0n avatar Feb 10 '26 01:02 hGriff0n

Hello @hGriff0n - I am in the same boat as you - Claude Code on Ubuntu (WSL) and Obsidian installed on Windows. From the above it looks like you've done a fix (thank you). When do you do submit the PR and if you remember - would you mind letting me know here so that I can wait for the merge of your solution?

michellepace avatar Feb 12 '26 00:02 michellepace

I had been considering dropping it given the official obsidain cli. Created a PR: https://github.com/Yakitrak/notesmd-cli/pull/84 @michellepace

hGriff0n avatar Feb 13 '26 19:02 hGriff0n

Hello @hGriff0n thank you very much! Who knows how long the offcial CLI will take to be available for free. I’m very happy for yours, thank you 🙂.

michellepace avatar Feb 13 '26 21:02 michellepace

Thanks @hGriff0n, its merged! I plan to add some more functionality soon, and then will do a release which will include this change. In the mean time feel free to build from source code.

Yakitrak avatar Feb 13 '26 22:02 Yakitrak