Unresolved directive in Mock vs Stub vs Spy.adoc - include::"What is mock.adoc"[]
- User
Unresolved directive in Mock vs Stub vs Spy.adoc - include::"What is mock.adoc"[]
Assistant
The error message "Unresolved directive" typically means that Asciidoctor cannot find the file you're trying to include. Here's a step-by-step guide to troubleshoot and fix this issue:
1. Verify the File Exists
Ensure the file
"What is mock.adoc"exists in the correct location.Example Directory Structure:
docs/ ├── Mock vs Stub vs Spy.adoc └── What is mock.adocIncorrect Path Example: If the file is actually named
what-is-mock.adoc(without spaces), use:include::what-is-mock.adoc[]Correct Path with Spaces: If the file is indeed
"What is mock.adoc", ensure the include directive uses quotes:include::"What is mock.adoc"[]
2. Check File Permissions
Ensure the file is readable by the user running the Asciidoctor process.
3. Verify Relative Paths
AsciiDoc includes are relative to the current document's location, not the project root.
Example: If
Mock vs Stub vs Spy.adocis in a subdirectory:docs/ └── concepts/ ├── Mock vs Stub vs Spy.adoc └── What is mock.adocThe include should be:
include::What is mock.adoc[]If
What is mock.adocis in a parent directory:docs/ ├── What is mock.adoc └── concepts/ └── Mock vs Stub vs Spy.adocUse:
include::../What is mock.adoc[]
4. Check for Hidden Characters
Sometimes filenames contain invisible characters. Verify the filename is exactly as expected:
- On macOS: Use
ls -lOto check for hidden flags. - On Linux: Use
ls -land check for unusual characters. - On Windows: Use PowerShell's
Get-ChildItem -Forceto list all files.
5. Test with Absolute Paths
As a temporary test, use an absolute path to confirm the file is accessible:
include::/full/path/to/docs/What is mock.adoc[]Note: Avoid using absolute paths in production, as they break portability.
6. Check Asciidoctor Version
Ensure you're using a modern version of Asciidoctor (>= 2.0). Older versions might handle includes differently.
Check Version:
asciidoctor --versionUpdate Asciidoctor:
# For Ruby gem update asciidoctor # For npm npm install -g asciidoctor.js # For Python pip install asciidoctor
7. Debugging Tips
Enable Debug Output:
Run Asciidoctor with the
-v(verbose) flag:asciidoctor -v Mock vs Stub vs Spy.adocThis will show detailed information about include processing.
Check for Typos:
Ensure there are no typos in the filename or path. Filenames are case-sensitive on Linux/macOS.
8. Example Fix
Assuming the correct structure:
docs/ ├── Mock vs Stub vs Spy.adoc └── What is mock.adocCorrect Include:
= Mock vs Stub vs Spy include::"What is mock.adoc"[]If in a subdirectory:
docs/ └── testing/ ├── Mock vs Stub vs Spy.adoc └── What is mock.adocCorrect Include:
include::What is mock.adoc[]
9. Alternative: Use Attributes for Paths
If you have many includes, define a path attribute:
:definitions-dir: ./ include::{definitions-dir}What is mock.adoc[]
10. Common Mistakes
Mistake Correct include::What is mock.adoc[](no quotes)include::"What is mock.adoc"[]include::./What is mock.adoc[](unnecessary./)include::"What is mock.adoc"[]include::../What is mock.adoc[](wrong relative path)Check actual directory structure
Final Checklist
- Is the file in the correct directory?
- Are quotes used around the filename?
- Is the path relative to the current document?
- Are there hidden characters in the filename?
- Is the file readable by the user?
- Is Asciidoctor up to date?
If all else fails, temporarily rename the file to remove spaces (e.g.,
what-is-mock.adoc) to confirm the include mechanism is working. Once confirmed, restore the original filename and ensure quotes are used.- On macOS: Use
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.