zola icon indicating copy to clipboard operation
zola copied to clipboard

Custom site root doesn't work on Windows

Open southerntofu opened this issue 4 years ago • 5 comments

From the forums

Windows 10, zola 0.13.0

It appears the -r flag is broken on Windows, at least with absolute links, like so:

zola.exe -r "D:\Dev\Zola\zola-clean-blog" build

southerntofu avatar Feb 18 '21 11:02 southerntofu

This feels like https://github.com/getzola/zola/blob/master/src/main.rs#L15-L20 should work 🤔

Keats avatar Feb 22 '21 20:02 Keats

Is it still happening with 0.14?

Keats avatar Jul 19 '21 19:07 Keats

I had the same problem on master branch [0] and did a little analysis. It appears to me that (at least in my case) the problem might be that the windows canonical path looks like this:

root_dir: \?\C:\Users\user\my_site

My guess is the questionmark in the prefix will later be interpreted as a globbing character. Tera::parse will create no matches then.

I kinda confirmed this by removing the "canonicalize" call in the root_dir assignment, which fixed the problem for me.

let root_dir = match matches.value_of("root").unwrap() {
    "." => env::current_dir().unwrap(),
    path => PathBuf::from(path)
        .canonicalize()
        .unwrap_or_else(|_| panic!("Cannot find root directory: {}", path)),
}; 

[0] commit 9946506e1c363a35f097a7b220c613f77a989c43 (HEAD -> master, origin/master, origin/HEAD)

warsus avatar Sep 21 '21 06:09 warsus

@warsus thanks for digging! I can't remember why we're canonicalizing it to be honest. If you can do a PR with that change on the next branch, I'll test on macos.

Keats avatar Sep 21 '21 07:09 Keats

@Keats Sure i will try to do a PR later today. Also i think my assumption about the questionmark was not completly right. But i still think it's something about the \? prefix, might do some further digging in the tera lib afterwards.

warsus avatar Sep 21 '21 07:09 warsus