Why is Moodle not finding path to Ghostscript?
Is your path to Ghostscript not working on Moodle even though you can confirm that Ghostscript is installed, able to queried its version and can confirm that it is in fact in the correct path on the server and not an alias. Here is why Moodle is unable to ‘find’ Ghostscript even though the path is correct and GS is installed on the server.
The Problem
Moodle is not recognising ghost script causing online assignment marking via Annotate PDF to not work. In fact, Annotate PDF option isn’t even available under Feedback types in Assignment settings.
Login as Administrator then go to Site administration > Server > System paths. Under Path to Ghostscript you will see the default path /usr/bin/gs and a red cross [x]
Test Ghostscript Path – Returns An Error
Login as Administrator then go to Site administration > Plugins > Activity modules > Annotate PDF. (image below)
There, under Path to Ghostscript click Test Ghostscript path. This returns the following error (image below):
“The Ghostscript path points to a non-existent file”
To Confirm that Ghostscript is Installed
This assumes that you are running a Linux server. It will require that you have root access to the server.
Terminal to the server using a root or administrator account and password via SSH.
Search for gs using the following command
whereis gs
From the result, go to the location where gs lives (usr/bin/gs) and execute the following command
ghostscript -v
This will return the version number indicating that Ghostscript is installed.
If ghostscript is not install, look to install this using commands suitable for your variant of Linux server. Once installed, check the version using step above to confirm.
Solution
PHP open_basedir setting prevented access to the path. Check PHP info to see if this was set. If on Plesk, you can go straight to the PHP settings page and look under open_basedir to confirm
Add the path (e.g. usr/bin/gs) to your PHP settings under open_basedir and Apply changes. Files in the specified directories can be accessed by PHP scripts.
You just need to add this folder to your entry to grant access to it: e.g. in Plesk the entry may become something like:
{WEBSPACEROOT}{/}{:}{TMP}{/}{:}/usr/bin/gs
(Using {:} as the divider in Plesk)
Ghostscript is Working as Expected
Once applied, test the Ghostscript path again using steps in Testing Ghostscript Path. This should return the following smiley face
System Path to GS is Recognised
Go to Site administration > Server > System paths then scroll down to Path to ghostsript, there should now be a green tick next to the default path.
Annotate PDF option now Available
Once enabled, you can go to an Assignment settings, expand Feedback types accordion and you will find Annotate PDF as a feedback type. Place a tick on the check box to enable this option.