Export - Fatal Error

We are unable to export our book files. When I go to export a book, the following error message appears -
" Fatal error : Uncaught Error: Call to undefined function Pressbooks\Utility\exec() in /home/pressbooks/public_html/wp-content/plugins/pressbooks/inc/utility/namespace.php:348 Stack trace: #0 /home/pressbooks/public_html/wp-content/plugins/pressbooks/inc/modules/export/odt/class-odt.php(406): Pressbooks\Utility\check_saxonhe_install() #1 /home/pressbooks/public_html/wp-content/plugins/pressbooks/inc/modules/export/namespace.php(47): Pressbooks\Modules\Export\Odt\Odt::hasDependencies() #2 /home/pressbooks/public_html/wp-content/plugins/pressbooks/inc/modules/export/namespace.php(295): Pressbooks\Modules\Export\dependency_errors() #3 /home/pressbooks/public_html/wp-content/plugins/pressbooks/inc/admin/laf/namespace.php(660): Pressbooks\Modules\Export\template_data() #4 /home/pressbooks/public_html/wp-includes/class-wp-hook.php(308): Pressbooks\Admin\Laf\display_export(‘’) #5 /home/pressbooks/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(‘’, Array) #6 /home/pressbooks/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #7 /home/pressbooks/public_html/wp-admin/admin.php(259): do_action(‘toplevel_page_p…’) #8 {main} thrown in /home/pressbooks/public_html/wp-content/plugins/pressbooks/inc/utility/namespace.php on line 348

There has been a critical error on this website.

Our web developer has tried numerous things; even setting up a new pressbooks from scratch to test and export still doesn’t work.

Any advice on how to troubleshoot this issue?

Hi @Karen_Bjork – is this a self-hosted open source instance of Pressbooks? If so, can you provide the details of the diagnostics page for your network? You should be able to find it if you log in as an admin user and look at the page footer, or by navigating directly to https://YOURNETWORK.URL/wp-admin/options.php?page=pressbooks_diagnostics

I can’t say for certain, but the stack trace looks like the problem is occurring within a function that checks to see that you have the Saxon-HE 9.7.0-10 dependency installed on the server. This is a third-party dependency that is used by Pressbooks to generate ODT export files.

The function that’s throwing the error is here: https://github.com/pressbooks/pressbooks/blob/38578b75b367ca5309db8522b040041cd1c7a5db/inc/utility/namespace.php#L341C1-L348C62. In this case, the stack trace is saying that the exec() function is undefined – I suspect it’s because the PB_SAXON_COMMAND environment variable either hasn’t been set correctly or the saxon-he.jar isn’t in the expected place on the server.

To define the PB_SAXON_COMMAND variable, you should have a block in your wp-config.php file that looks like this:

define( 'PB_PRINCE_COMMAND', '/usr/bin/prince' ); 
define( 'PB_EPUBCHECK_COMMAND', '/usr/bin/java -jar /home/example/bin/epubcheck/epubcheck.jar' ); 
define( 'PB_XMLLINT_COMMAND', '/usr/bin/xmllint' ); 
define( 'PB_SAXON_COMMAND', '/usr/bin/java -jar home/example/bin/saxon-he/saxon-he.jar' );

The last line is the one which defines the PB_SAXON_COMMAND path on your server. Hope that helps?

Hi, I’m the web developer helping Karen with this issue. We do run the open source version with a hosting company. The issue with providing the details on the diagnostics page is also an issue as since an update (I forget which one) we’ve been throwing an error on that Diagnostics page:

Fatal error: Uncaught Error: Call to undefined function Pressbooks\Utility\exec() in /home/pressbooks/public_html/wp-content/plugins/pressbooks/inc/utility/namespace.php:271 Stack trace: #0 /home/pressbooks/public_html/wp-content/plugins/pressbooks/inc/admin/diagnostics/namespace.php(100): Pressbooks\Utility\check_epubcheck_install() #1 /home/pressbooks/public_html/wp-includes/class-wp-hook.php(308): Pressbooks\Admin\Diagnostics\render_page(‘’) #2 /home/pressbooks/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(‘’, Array) #3 /home/pressbooks/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /home/pressbooks/public_html/wp-admin/admin.php(259): do_action(‘admin_page_pres…’) #5 /home/pressbooks/public_html/wp-admin/options.php(19): require_once(‘/home/pressbook…’) #6 {main} thrown in /home/pressbooks/public_html/wp-content/plugins/pressbooks/inc/utility/namespace.php on line 271
There has been a critical error on this website.

But your point about the undefined variables seems like the right path. Currently the wp-config.php file has this:

define( 'PB_PRINCE_COMMAND', '/usr/local/bin/prince' ); // Only required if you are using Prince on your server
define( 'PB_KINDLEGEN_COMMAND', '/usr/local/bin/kindlegen' );
define( 'PB_EPUBCHECK_COMMAND', '/usr/bin/java -jar /opt/epubcheck/epubcheck.jar' );
define( 'PB_XMLLINT_COMMAND', '/usr/bin/xmllint' );
define( 'PB_SAXON_COMMAND', '/usr/bin/java -jar /opt/saxon-he/saxon-he.jar' );
define( 'PB_MATHJAX_URL', 'http://localhost:3000/' );

Unfortunately, I can’t see with my permissions either the /usr/bin or the /opt folders to see what’s where. I will see if the hosting company look into it and see if those paths contain the necessary files. Thanks for your insight.