magicbook build cannot find source images
AntonioGHub opened this issue · comments
I am on Windows 10 with magicbook
Whenever I build the book, it can't find the source images returning errors like:
image not found in source folder: chapter10/ch10_14.png
image not found in source folder: chapter10/ch10_15.png
image not found in source folder: chapter10/ch10_ex03a.png
image not found in source folder: chapter10/ch10_16.png
-> HTML build finished
...
and the same goes with the PDF part of the build.
I noticed that this happens only with the images stored in a subfolder (like context\noc_pdf\imgs\chapter10 subfolder), but images in the root are correctly detected: for instance context\noc_pdf\imgs\bella.png
Nevertheless, image folders appear correctly referenced in the magicbook.json file:
"images": {
"files": "context/noc_pdf/imgs/**/*.*"
},
Interestingly, if I move all images to the root (context\noc_pdf\imgs) and replace all references in the html source files accordingly, it works fine.
In the previous version of the book an issue opened for the same problem, at a point seemed to indicate too long names as the cause for the issue.
Build fails · Issue #118 · nature-of-code/noc-book
May this be the cause?
more details:
os: Windows 10
nodejs version: v12.1.0
code commit: 2f9b392 (current commit of branch "source")
magicbook version (current as of today)
magicbook-codesplit@0.1.6
magicbook-katex@0.0.7
magicbook-webpack@0.0.3
@AntonioGHub - Hello! Thanks for posting this issue. I have a feeling that this might have to do with the way that magicbook is handling file/folder paths. I'm not exactly sure, but sometimes there are issues with the way that node.js handles paths between macos and windows. I'll have to take a look to see if this can be easily resolved with something like path.resolve()
in the case that it is not being used (though I to check this).
I think the macos build is working on my end and @shiffman 's end last I checked, so we can look into this for windows.
Thanks for the info + your patience!
Thank you,
if you find it handy to have me check if the change you mention (path.resolve
) fixes the issue, let me know. It doesn't cost me anything to give it one or more tries.
@AntonioGHub - Sure! Quite likely you'll have to dig behind the scenes of magicbook. If this is something comfortable for you, by all means you're welcome to give it a try. If it turns out the change helps, then you can make a PR to magicbook and we can get that merged in for everyone else to use as well :)
Thanks so much!
Fine, I never have messed up with node.js nor npm modules/dependencies but it shouldn't be a problem (I might be slow at the beginning, but it looks like it is not urgent matter anyway).
So, just let me know when/how to proceed!
Ok, I found the problem and fixed it (in a platform-agnostic fashion).
You can find the PR on magicbook: fixes #29; img.src attribute not correctly resolved on Windows.
Cheers!
In the meantime, while the bug still exist on windows 10, anyone can follow my tricks:
- use WSL for Windows 10 (I'm using Ubuntu). Or in my case, I also try to use remote server Ubuntu bash, installed with npm magicbook as global also. But both of them give the following error after
magicbook build
command: Prince XML Error
but consolidated HTML can be made. No PDF file have been made.- Install Prince XML for Windows from here and install.
- Open Prince and open the consolidated.html generated from magicbook in
build
folder. - PDF file found on the same folder.
Looks like this was fixed so I'm going to go ahead and close this issue! Feel free to re-open if there are new ones. (This project is now active again!)