-
Notifications
You must be signed in to change notification settings - Fork 972
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
Should be able to stripe prefix
panic prevents building site with pages on Windows file server
#1435
Comments
You can debug by adding a line I believe. From: path = path
.strip_prefix(&base_path.join("content"))
.expect("Should be able to stripe prefix")
.to_path_buf(); to let new_path = println!("{:?} joined with {:?} = {:?}", path, base_path.join("content"), path.strip_prefix(&base_path.join("content")));
path = path
.strip_prefix(&base_path.join("content"))
.expect("Should be able to stripe prefix")
.to_path_buf(); so we can see the actual error. |
Thanks I tried adding the logging line and get the following results. Current project with colocated pdfsLog for working local buildBuilding site...
`highlight_code` has been moved to a [markdown] section. Top level `highlight_code` and `highlight_theme` will stop working in 0.14.
"C:/Users/Admin/Desktop/zola/content/my_content\\blog\\colocated_file.pdf" joined with "C:\\Users\\Admin\\Desktop\\zola\\content" = Ok("my_content\\blog\\colocated_file.pdf") Log for non-working build on file serverBuilding site...
`highlight_code` has been moved to a [markdown] section. Top level `highlight_code` and `highlight_theme` will stop working in 0.14.
"//server/maindirectory/subdirectory/subdirectorytwo/myfolder/zola/content/my_content\\blog\\colocated_file.pdf" joined with "\\\\server\\maindirectory\\subdirectory\\subdirectorytwo\\myfolder\\zola\\content" = Err(StripPrefixError(()))
thread 'main' panicked at 'Should be able to stripe prefix: StripPrefixError(())', components\library\src\content\page.rs:300:22note: run with ` I am not sure why, but maybe the Sample using the starter templateI also tried doing the same with the starter project with only a single page (first.md based on the getting started zola example) Log for working local buildBuilding site...
-> Creating 1 pages (0 orphan), 1 sections, and processing 0 images
Done in 105ms. Log for non-working build on file serverBuilding site...
-> Creating 1 pages (0 orphan), 1 sections, and processing 0 images
Failed to build the site
Error: Failed to render page '//server/maindirectory/subdirectory/subdirectorytwo/myfolder/test/zola_starter/content/blog\first.md'
Reason: Tried to render `blog-page.html` but the template wasn't found Note: If i remove all colocated assets from my project, I get more or less the same error as above. I am not sure if they are related or a completely different issues. Thank you |
Tried something out to see if it works in this specific case. Basically in 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);
// Added this, pretty naive but just for testing purposes
let base_path_string = &base_path.display().to_string();
let base_path_new = PathBuf::from(&base_path_string[1..]);
path = path
// Replaced base_path with base_path_new, which is basically base_path less the two "\\"
//.strip_prefix(&base_path.join("content"))
.strip_prefix(&base_path_new.join("content"))
.expect("Should be able to stripe prefix")
.to_path_buf();
path
})
.map(|path| path.to_string_lossy().to_string())
.collect()
}
// This works and get the Ok from strip_prefix This works and the assets are properly transferred to the build directory BUT... I am now getting a different problem. Zola says it cannot find the templates. To simplify testing, I used the Zola starter and tried to build the project. I get the following error: Building site...
-> Creating 1 pages (0 orphan), 1 sections, and processing 0 images
Failed to build the site
Error: Failed to render page '//server/maindirectory/subdirectory/subdirectorytwo/myfolder/test/zola_starter/content/blog\first.md'
Reason: Tried to render `blog-page.html` but the template wasn't found Also tried this with just the section template +++
title = "List of blog posts"
sort_by = "date"
template = "blog.html"
+++ But get a similar error, Is there are way to pass a Really like Zola! Hope there's a way around this. |
Hm that seems like a lot of path issues, weird that no one ran into them... Are you using some specific systems like WSL or something? |
If I inspect the directory properties, it says "Windows Server", so probably the usual Windows file server? I've tried copying the project to a thumb drive and executing the binary from within the thumb drive, aside from the slightly slower build speed it works perfectly. Wondering maybe it has something to do with the file server not starting with a "letter" drive (like C:)? the thumb drive on windows starts with a letter as well. Hmmm Is there a way to print the path that Zola is using to look for the templates? |
It would be super helpful if we had another Windows user that could try to reproduce.
It should be path of directory of config.toml + templates, joined by whatever is the OS separator. Are you able to write a test that fails? |
Yeah, would be great if someone else on Windows could reproduce the issue. My guess at the moment is that it is a similar problem related to the initial issue. Probably for some reason std::path is prefixing the path with an additional "\" on Windows volumes without a letter drive, which is an invalid path. I am not familiar with the entire codebase, but am I right to assume that most of the path related functionality is based on std::path? Perhaps this might be an edge case not yet fully explored. I will try to investigate a little bit more. |
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 usedzola 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 andbuild
from there so that we only have a single version. Upon building from within the directory containing the files, I get the following error: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 withzola 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.Step to reproduce
src
(Windows)zola build
cd
into that directoryzola build
(zola serve
also produced the same issue)Don't know if anyone has encountered the same issue before. Thanks
The text was updated successfully, but these errors were encountered: