getzola/zola

`Should be able to stripe prefix` panic prevents building site with pages on Windows file server

Open

#1,435 opened on Apr 23, 2021

View on GitHub
 (8 comments) (0 reactions) (0 assignees)Rust (15,349 stars) (1,046 forks)batch import
Need Windows helpbughelp wanted

Description

Bug Report

Environment

Zola version: 0.13.0

Expected Behavior

Be able to build the site with pages within a directory in a file server. Built zola from src and used zola build on my machine to build the site, works like a charm!

Current Behavior

Copied the exact same site that worked locally, together with zola.exe to a shared folder located in a shared file server. The specific use case it to allow non-techy colleagues to add markdown files to the shared directory and build from there so that we only have a single version. Upon building from within the directory containing the files, I get the following error:

$ ./zola build
Building site...
`highlight_code` has been moved to a [markdown] section. Top level `highlight_code` and 
`highlight_theme` will stop working in 0.14. 
thread 'main' panicked at 'Should be able to stripe prefix: StripPrefixError(())',
components\library\src\content\page.rs:299:22 note: run with `RUST_BACKTRACE=1` 
environment variable to display a backtrace

Next I tried to check whether I could initiate a new project with zola init and that worked. Next I tried to build the empty project with zola build and that also worked. However, when I tried to add a page (index.md) to the project, I get the error shown above.

I tried removing any pages from the original project and zola build worked. So it appears there seems to be a problem when processing pages. It works fine if the site only contains sections.

Tried to follow the error and checked page.rs:299:22, which points to the following code block. But I am not sure what is causing the problem.

 /// Creates a vectors of asset URLs.
    fn serialize_assets(&self, base_path: &PathBuf) -> Vec<String> {
        self.assets
            .iter()
            .filter_map(|asset| asset.file_name())
            .filter_map(|filename| filename.to_str())
            .map(|filename| {
                let mut path = self.file.path.clone();
                // Popping the index.md from the path since file.parent would be one level too high
                // for our need here
                path.pop();
                path.push(filename);
                path = path
                    .strip_prefix(&base_path.join("content"))
                    .expect("Should be able to stripe prefix")
                    .to_path_buf();
                path
            })
            .map(|path| path.to_string_lossy().to_string())
            .collect()
    }

Step to reproduce

  1. build zola from src (Windows)
  2. build a local project with zola build
  3. check that it works
  4. copy exactly the same project to a directory on a local shared file server
  5. cd into that directory
  6. build project with zola build (zola serve also produced the same issue)

Don't know if anyone has encountered the same issue before. Thanks

Contributor guide