Closed khaos-codi closed 3 months ago
After examining the build logs, we identified the root cause of the build failure. The issue was a permission problem with the script files in the Docker container environment:
./build.sh: line 7: /__w/actual-intelligence/actual-intelligence/tools/scripts/build.sh: Permission denied
./build.sh: line 7: exec: /__w/actual-intelligence/actual-intelligence/tools/scripts/build.sh: cannot execute: Permission denied
PR #46 addresses this by adding script permissions to all .sh
files before running the build:
# Fix permissions on script files
chmod +x build.sh
find tools/scripts -name "*.sh" -exec chmod +x {} \;
When the repository is checked out in the GitHub Actions Docker container, the script files lose their executable permissions. This is a common issue when working with Docker containers and shell scripts.
The fix ensures that all shell scripts in the project (especially in the modular tools/scripts/
directory) have the proper executable permissions (+x) before they're run.
The workflow will now:
We're waiting for the workflow to complete to confirm this fix resolves the issue.
Great news! We've successfully restored the English book build and now we're re-enabling support for all languages.
build/es
, build/es/images
) creation./build.sh --lang=en
to ./build.sh --all-languages
The build should now produce both English and Spanish versions of the book. We'll keep monitoring to ensure both languages build successfully.
We'll close this issue once we confirm all languages are building properly.
We've identified and fixed another issue related to images not appearing in the EPUB files. The problem was in the generate-epub.sh
script.
eval
with the cover image option, which was causing issues with proper command executionI've updated the generate-epub.sh
script with the following improvements:
eval
usage and split the commands into two clear conditional blocksThis fix should restore image inclusion in the EPUB files while maintaining the modular build system. The changes match the approach that was working in the original monolithic script.
The next build run should produce EPUB files with all images properly included.
After closer examination of the working build (commit 6c0dad49), I found several critical differences in how images are handled. I've implemented a comprehensive fix for EPUB image inclusion:
set -e
exit-on-error flag in the EPUB generation script was stopping further processing when one command failedI've implemented several changes to ensure images are correctly included:
Updated generate-epub.sh script:
set +e
to handle errors manually rather than exitingImproved setup.sh script:
These changes should restore the EPUB file size to the expected ~12MB range that was seen with commit 6c0dad49, indicating proper image inclusion.
The most critical issue appears to be in how pandoc handles image paths. The previous implementation was using eval
with string concatenation for options, which was problematic. I've replaced this with clean conditional blocks and explicit path handling.
I've also added image path fallback strategies to handle different image reference formats in the markdown files.
The updated script now checks the file size of the generated EPUB to verify that images are likely included. We'll confirm the fix when the workflow runs.
After extensive research on how Pandoc handles image paths in EPUB files, I've completely rewritten the EPUB generation script with a fundamentally different approach:
--self-contained
option is critical for ensuring images are bundled properlyMy new solution creates a self-contained working environment for EPUB generation:
images
subdirectory and copies all images from every possible source locationimages/
directory--self-contained
flag to ensure all assets are bundled--extract-media
if the first attempt failsThis approach eliminates path resolution issues by ensuring Pandoc runs with all resources directly accessible from its working directory. The script also includes detailed debugging output showing all files available, which should make it easier to diagnose any issues.
We'll know this approach works when we see EPUB files with sizes around 12MB, indicating successful image inclusion.
After analyzing the build logs, I've identified that the workflow runs in a Docker container (iksnae/book-builder
). This is critical information that affects how our solution needs to be implemented.
I've created another revision of the EPUB generation script with a Docker-compatible approach:
Path Simplification: Avoided complex directory hierarchy manipulations that might not work well in Docker containers
Fixed Image Paths: Modified the Markdown file to explicitly reference images from a predictable location (build/images/
)
Multi-Attempt Strategy: Implemented a three-step fallback process:
--self-contained
flag with verbose output--embed-resources
flag if the first failsEnhanced Logging: Added detailed logging to help debug any issues, capturing pandoc output to build/pandoc-output.log
Size Verification: Added file size checks after each attempt to verify image inclusion
The script is now much more robust for running in a containerized environment and provides multiple fallback mechanisms. This approach follows best practices for dealing with path resolution issues in Docker containers.
We'll know if this is successful when the EPUB file sizes are significantly larger (~12MB), indicating that images are properly included.
I've made one final refinement to the EPUB generation script to ensure it works in the Docker environment:
Absolute Path Handling: The script now tries using absolute paths for image references, which is often necessary in Docker containers
Individual File Copy: Using find
with exec
to ensure all image files are properly copied to the build directory
Full Working Directory Capture: Gets and uses the absolute path to the working directory
Triple-Fallback Strategy: Now tries three different approaches in sequence:
--self-contained
flag--embed-resources
flagDiagnostic Archive: Saves a timestamped copy of any successfully generated EPUB for debugging purposes
The script now implements a comprehensive "try everything" approach that should work regardless of the specific Docker container configuration. One of these methods should successfully include images in the EPUB files.
This is the most robust solution for ensuring image inclusion in a containerized environment where the exact path resolution rules might vary.
After examining the Docker container configuration in the iksnae/book-builder
repository, I've implemented a much simpler approach that follows the conventions used in your container's existing build scripts.
I've rewritten the EPUB generation script to be simpler and more aligned with your container's conventions:
--metadata-file
option to properly set metadata in a YAML format--self-contained
flag if neededThis simplified approach is more likely to work in your Docker environment because it follows the same patterns that are already being used in the container's existing scripts.
The script still implements file size checks to verify image inclusion, and includes appropriate debugging information.
Since we're still facing issues with image inclusion in the Docker environment, I've created a comprehensive diagnostic toolkit to help isolate and resolve the problem:
I've added tools/debug/test-epub-images.sh
- a standalone script that tests 9 different Pandoc approaches for EPUB image inclusion using a simple test document. This script will help identify exactly which combination of options works in your specific Docker container.
I've recreated the approach from the working commit (f5b41647) in tools/debug/old-working-approach.sh
to allow direct comparison with the current environment.
I've created tools/debug/TROUBLESHOOTING.md
with comprehensive steps to diagnose and fix the issue, including:
When you run your next workflow, you can add these steps to help diagnose the issue:
- name: Run EPUB image diagnostic tests
run: |
chmod +x tools/debug/test-epub-images.sh
./tools/debug/test-epub-images.sh
echo "Test results:"
du -k test-epub/*.epub
Alternatively, you can run these scripts directly in your Docker container:
docker run -v $(pwd):/workspace iksnae/book-builder /bin/bash -c "cd /workspace && chmod +x tools/debug/test-epub-images.sh && ./tools/debug/test-epub-images.sh"
These diagnostic tools will help identify the specific Pandoc command that works in your Docker environment, which we can then incorporate into the main build process.
I completely agree that Docker should be encapsulating this complexity rather than requiring constant script adjustments. To that end, I've implemented a more sustainable solution by updating the Docker container itself:
iksnae/book-builder
Container:generate-epub
utility - A robust script that consistently handles image inclusion in EPUBsThe generate-epub
utility specifically addresses the image inclusion issues by:
Once the updated container is built and pushed, you can update your build-language.sh script to use this utility:
# Instead of direct pandoc call
generate-epub \
--title "$BOOK_TITLE" \
--author "Open Source Community" \
--publisher "Khaos Studios" \
--language "$LANGUAGE" \
--cover "$COVER_IMAGE" \
--resource-path "$RESOURCE_PATHS" \
--verbose \
"$MARKDOWN_PATH" "$EPUB_PATH"
This approach better fulfills Docker's promise of encapsulating complexity while maintaining consistent functionality across environments.
Issue Description
After refactoring the build scripts into modular components, the book build is succeeding but not producing any output files. At commit f5b41647482d6446ca40a9db9d7c71bb423c2b02, the English version of the book was building correctly, but the Spanish version wasn't.
Root Cause
The recently refactored build system (which moved from a monolithic
build.sh
to modular scripts intools/scripts/
) appears to have issues with the handling of multiple languages. When trying to build all languages with the--all-languages
flag, no output files are being produced.Fix Implemented
PR #45 implements a temporary fix to restore the English build functionality:
.github/workflows/build-book.yml
) to focus only on the English version./build.sh --all-languages
to./build.sh --lang=en
Future Work
Once the English build is confirmed working, we should:
combine-markdown.sh
script to ensure proper handling of language-specific pathsbook/es/
matches what scripts expect--lang=es
flag specifically to isolate Spanish build issuesRelated Commits