SyntaxHighlight_GeSHI extension 'ProcessBuilder not found' issue after upgrading to MediaWiki 1.26.2 (or above)

SyntaxHighlight_GeSHI extension 'ProcessBuilder not found' issue after upgrading to MediaWiki 1.26.2 (or above)

One of the biggest update introduced with MediaWiki build 1.26.2 and above is the extensive use of Composer, a dependency manager for PHP: in short words, Composer is something very close to what NPM is for Node.js, meaning that it can be used to automatically fetch, update and mantain the package dependencies for your project, keeping them up-to-date. However, instead of storing them within a global folder, it will manage the packages on a per-project basis, installing them in a directory (e.g. vendor) that will be added to each specific project. This is the perfect cup of tea for any seasoned Linux system administrator, yet it can be quite hard to understand for those used to work on Windows servers.

We'll talk more about the interactions between Composer and the latest MediaWiki builds in an upcoming article: for now we'll address a very specific issue regarding how we can use Compose to fix a bug with the SyntaxHighlight extension, formerly known as SyntaxHighlight_GeSHI  (click here for more info) that will often happen after upgrading a MediaWiki installation to 1.26.2 or above (including 1.27).

The Problem

If you've stumbled upon this post it most likely means that your MediaWiki installation is broken, showing the following error:

Fatal error: Class 'Symfony\Component\Process\ProcessBuilder' not found in /app/mediawiki/mw/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php on line 283

Disabling the extension in the MediaWiki's LocalSettings.php file fixes it, but if you do that you will lose the Syntax Highlighting features of your Wiki.

The Fix

Luckily enough, the issue is quite easy to fix. You basically need to update your SyntaxHighlighter extension to the latest release matching your MediaWiki build and then update its dependencies using Composer.

Update SyntaxHighlighter

This can be easily done by downloading the latest snapshot from the official MediaWiki's ExtensionDistributor page. Ensure to select the snapshot matching your MediaWiki build, then unpack it and replace your outdated version with the contained files. Technically you can just unpack the new build over your previous one, however it's strongly suggested to move the existing ones into a backup folder (and delete them afterwards), so you will be able to recover them in case something goes wrong - or get rid of the deleted files if everything goes ok.

Update dependencies with Composer

As soon as you installed the SyntaxHighlighter updated build, open a Command Prompt with administrative priviledges (or a Linux shell if you're on Linux), navigate through the extension root folder and execute the following commands, one after another:

This will tell Composer to process the composer.json file shipped with the extension and update its dependencies accordingly. Needless to say, in order to do this you'll need to have Composer installed and properly configured in your PATH environment variable. If you need advices on how to do that, leave a comment explaining your issue and I'll try to help with a separate post.

As soon as you do that, you should be able to re-enable the SyntaxHighlight extension in your MediaWiki's LocalSettings.php file: the above error should be gone for good.

However, if you check a page containing code, you could experience the fact that the SyntaxHighlight extension, while apparently working without issues, doesn't actually "highlight" your code anymore. If you experience that, you will most likely need to read the following paragraph as well.

Installing Pygmentize

If the SyntaxHighlight extension ceased to work after upgrading it, it can be due to the fact that you haven't Pygmentize installed. As you might already know, Pygmentize is a Phyton general purpose syntax highlighter library package: the MediaWiki SyntaxHighlight extension switched from GeSHi to Pygmentize since June 2015, meaning that if you want to use a post-june 2015 build you need to have Pygmentize installed on the web server hosting your wiki. Needless to say, since it's a Phyton library, you need to install Phyton as well.

I know what you're thinking: Why should I do that? GeSHi didn't require anything like that! Well, that's right: GeSHi was a stand-alone PHP package, so it could be shipped across third-party applications - including MediaWiki extensions - without having to manually install it. On the other hand, Pygmentize is faster and more powerful, so it's well worth the additional work we need to do to set it up.

Here's what you need to do:

  • Install Python 2.7 from the official download page (3.5.2 won't be compatible with Pygmentize's current build).
  • Open a Command Prompt with administrative priviledges, navigate into the /Python27/Scripts folder and type the following:
    This will install the latest version of pygmentize using pip, the Python package manager (which comes shipped with Python since 2.7.9).
  • Open the MediaWiki's LocalSettings.php page and add the following line right after the wfLoadExtension  command to install the SyntaxHighlight extension:
    Replace c:\\python27  with your Python installation folder if needed.

As soon as you do that, the SyntaxHighlight extension should start highlighting your code again.

That's it for now: happy syntax highlightning!

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

One Comment on “SyntaxHighlight_GeSHI extension 'ProcessBuilder not found' issue after upgrading to MediaWiki 1.26.2 (or above)”

  1. Pingback: How to import Wikipedia Templates into your own MediaWiki

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.