View Single Post
Old 05-23-2025, 09:47 PM   #1
howens
Junior Member
howens began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Mar 2025
Device: Kindle Paperwhite
Exclamation URGENT: Calibre Config Lost + Template Functions Fail (Formatter Expected 'then' in P

Hello Calibre Developers and Community,

I am experiencing an extremely unusual and persistent problem with Calibre on my macOS system, which has progressed from template functions not working to fundamental configuration instability. I've exhausted all standard troubleshooting steps and need your expert assistance. Keep in mind I'm a super noob. I'm banging my head and hands against the wall at this point.

My System Details:

macOS Version: [Sequoia 15.5]
Calibre Version: [8.4.0]
Security Software: None

Full debug log is attached.txt


My primary issue began with Calibre's template language functions consistently failing. For example, a simple custom column using {if(1, '✅', '❌')} or {if(1, 'TRUE', 'FALSE')} would return an error like:
"unknown field if..." or "unknown function if".
Basic field substitutions like {title} do work.

Here is what I have done so far:

Multiple Clean Reinstalls:
Exited Calibre.
Dragged calibre.app to Trash.
Manually deleted any calibre folders found in ~/Library/Application Support/ and ~/Library/Preferences/.
Emptied Trash.
Downloaded a fresh installer from calibre-ebook.com and reinstalled.
Outcome: Problem persisted.

macOS Update:
Updated macOS to the latest available version.
Outcome: No change.

Testing in a New macOS User Account:
Created a completely new, standard macOS user account ("Calibre Test User").
Installed a fresh copy of Calibre in this new account and created a new, empty library.
Initial Outcome: The calibre configuration folder was initially created in the incorrect location (~/Library/Preferences/calibre/) instead of ~/Library/Application Support/calibre/. The template function issue remained.


After that didn't work, I manually deleted calibre folders from both ~/Library/Application Support/ and ~/Library/Preferences/.

Then, I launched Calibre from Terminal using the CALIBRE_CONFIG_DIRECTORY environment variable to explicitly force the correct path: CALIBRE_CONFIG_DIRECTORY="/Users/Calibre Test User/Library/Application Support/calibre" "/Applications/calibre.app/Contents/MacOS/calibre"

Outcome: This successfully created and populated the calibre configuration folder in ~/Library/Application Support/calibre/.

Template Test After This:
A complex template (e.g., {#pages:|Pages: |}{#genre_without_top_level:subitems(0,1)| - |}) then returned "TEMPLATE ERROR Value: unknown field #pages". This told me some parsing was occurring, which seemed like progress to me.
However, when reverting to {if(1, 'SUCCESS', 'FAILURE')}, the error changed to "unknown field if...".

After the above steps, when I tried to restart Calibre normally (not from Terminal via the environment variable), one of two things happened:

The Calibre Startup Wizard appeared, indicating Calibre had completely lost its configuration.
The calibre configuration folder was now present in BOTH ~/Library/Application Support/
AND ~/Library/Preferences/.

Is Calibre confused??

AND THEN when attempting to define a custom Python template function (field_exists) in Preferences → Advanced → Template functions I got this error:

"EXCEPTION: Formatter: if statement: expected 'then', found 'is' near 'mi' on line 2"


Man, maybe all of this is my fault?? I don't actually know but I would be really really grateful for some feedback or help.
Attached Files
File Type: txt full_debug_log.txt (324.2 KB, 35 views)
howens is offline   Reply With Quote