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

Panic in library::content::page::Page::serialize_assets on Windows #1939

Closed
tollyx opened this issue Jul 23, 2022 · 4 comments · Fixed by #1941
Closed

Panic in library::content::page::Page::serialize_assets on Windows #1939

tollyx opened this issue Jul 23, 2022 · 4 comments · Fixed by #1941
Labels
bug done in pr Already done in a PR Need Windows help We need someone using Windows to help us with this issue

Comments

@tollyx
Copy link

tollyx commented Jul 23, 2022

Bug Report

Environment

Zola version: v0.16
Windows 10.

Expected Behavior

My site builds successfully

Current Behavior

I get a panic while building/serving my site at this line.

$ zola build
Building site...
thread 'main' panicked at 'Should be able to stripe prefix: StripPrefixError(())', components\content\src\page.rs:282:22
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\core\src\panicking.rs:142
   2: core::result::unwrap_failed
             at /rustc/a8314ef7d0ec7b75c336af2c9857bfaf43002bfc/library\core\src\result.rs:1785
   3: core::result::Result<T,E>::expect
   4: content::page::Page::serialize_assets::{{closure}}
   5: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
   6: core::option::Option<T>::map
   7: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
   8: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
   9: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
  10: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  11: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
  12: core::iter::traits::iterator::Iterator::collect
  13: content::page::Page::serialize_assets
  14: content::page::Page::from_file
  15: site::Site::load
  16: zola::cmd::build::build
  17: alloc::collections::vec_deque::ring_slices::RingSlices::ring_slices
  18: core::ops::function::FnOnce::call_once

Ran git bisect, first bad commit is 0f23a40

Doing some println! debugging on my end, the bug comes from that there's a mismatch between forward and backwards slashes in the self.file.path and the base_path. E.g. self.file.path: "//?/C:/Users/tollyx/dev/tollyx.gitlab.io/content/old\\a-rat-betwixt\\index.md" vs base_path: "\\\\?\\C:\\Users\\tollyx\\dev\\tollyx.gitlab.io".

I was able to fix it locally by moving the .replace('\\', "/") at the start of Site::load to the start of Site::new, so that the modified path with forward slashes is what gets stored as the base path inside the site struct. But I do not know if that's the solution we'd want for this.

Step to reproduce

Clone https://gitlab.com/tollyx/tollyx.gitlab.io and run zola build or zola serve on windows.

@Keats Keats added bug Need Windows help We need someone using Windows to help us with this issue labels Jul 23, 2022
@Keats
Copy link
Collaborator

Keats commented Jul 23, 2022

Argh another Windows issue.

But I do not know if that's the solution we'd want for this.

It could be.
I'll set up a Windows machine next week to debug all of that

@swiftcoder
Copy link
Contributor

Just updated to 0.16.0 and ran into this issue as well.

The problem appears to be here: https://github.com/getzola/zola/blob/master/components/site/src/lib.rs#L165

For some reason the code takes in a canonicalized Path object, does a string-based find/replace to convert to unix path separators, and then proceeds to use string manipulations instead of the path API for the rest of the function.

I don't know why it does this, but at least on Windows it seem to work fine if I just get rid of this and use the path API directly

@Keats
Copy link
Collaborator

Keats commented Jul 25, 2022

Thanks @swiftcoder ! Do you have time/want to have a look at #1935 as well? I'm going to look at it myself as soon as I get libsass to work on my Windows machine.

@Keats Keats added the done in pr Already done in a PR label Jul 25, 2022
@tollyx
Copy link
Author

tollyx commented Jul 25, 2022

Built and tested with #1941 and I can confirm that it solved the issue on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug done in pr Already done in a PR Need Windows help We need someone using Windows to help us with this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants