Page MenuHomePhabricator

librsvg2-bin missing in docker image
Open, Needs TriagePublic


We tried to set up mediawiki with docker, using the official docker image mediawiki. We uploaded some SVG file into the mediawiki. However, the preview of the image showed an error string instead of the image. It turned out that installing librsvg2-bin fixed the problem.

It would be nice if librsvg2-bin was integrated in the official docker image. If you think it makes the image too large, you should at least explicitly mention in the documentation on Docker Hub that one has to install this package to support SVG.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 29 2019, 12:30 PM

Is librsvg2-bin a requirement for the bundled MediaWiki? or is this for an extension?

I dindn't install any extensions. Here is what I just did to reproduce the bug with a minimal example:

I started the wiki with

docker run --name wiki --rm -p 8080:80 -d mediawiki:1.32.0

I went to http://localhost:8080 and clicked through the installation dialog. I chose to use SQLite. I downloaded the LocalSettings.php, changed $wgEnableUploads to true and added the following lines:

$wgFileExtensions = array('png','svg');
$wgAllowTitlesInSVG = true;
$wgSVGConverter = 'ImageMagick';

This resulted in the following LocalSettings.php, that I copied into the container:

# This file was automatically generated by the MediaWiki 1.32.0
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
# See includes/DefaultSettings.php for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.
# Further documentation for configuration settings may be found at:

# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {

## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;

$wgSitename = "Test Wiki";
$wgMetaNamespace = "Test_Wiki";

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
$wgScriptPath = "";

## The protocol and server name to use in fully-qualified URLs
$wgServer = "http://localhost:8080";

## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;

## The URL path to the logo.  Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogo = "$wgResourceBasePath/resources/assets/wiki.png";

## UPO means: this is also a user preference option

$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO

$wgEmergencyContact = "apache@localhost";
$wgPasswordSender = "apache@localhost";

$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEmailAuthentication = true;

## Database settings
$wgDBtype = "sqlite";
$wgDBserver = "";
$wgDBname = "my_wiki";
$wgDBuser = "";
$wgDBpassword = "";

# SQLite-specific settings
$wgSQLiteDataDir = "/var/www/data";
$wgObjectCaches[CACHE_DB] = [
	'class' => SqlBagOStuff::class,
	'loggroup' => 'SQLBagOStuff',
	'server' => [
		'type' => 'sqlite',
		'dbname' => 'wikicache',
		'tablePrefix' => '',
		'dbDirectory' => $wgSQLiteDataDir,
		'flags' => 0
$wgLocalisationCacheConf['storeServer'] = [
	'type' => 'sqlite',
	'dbname' => "{$wgDBname}_l10n_cache",
	'tablePrefix' => '',
	'dbDirectory' => $wgSQLiteDataDir,
	'flags' => 0

## Shared memory settings
$wgMainCacheType = CACHE_NONE;
$wgMemCachedServers = [];

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";

# InstantCommons allows wiki to use images from
$wgUseInstantCommons = false;

# Periodically send a pingback to with basic data
# about this MediaWiki instance. The Wikimedia Foundation shares this data
# with MediaWiki developers to help guide future development efforts.
$wgPingback = true;

## If you use ImageMagick (or any other shell command) on a
## Linux server, this will need to be set to the name of an
## available UTF-8 locale
$wgShellLocale = "C.UTF-8";

## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publically accessible from the web.
#$wgCacheDirectory = "$IP/cache";

# Site language code, should be one of the list in ./languages/data/Names.php
$wgLanguageCode = "de";

$wgSecretKey = "f81bda5fc9b9e401b7eee3ecb033d9c3b17c9addef0cbfc03cb092c2bbe5100b";

# Changing this will log out all existing sessions.
$wgAuthenticationTokenVersion = "1";

# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "7b9af8e91705dbff";

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";

# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";

## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'vector', 'monobook':
$wgDefaultSkin = "vector";

# Enabled skins.
# The following skins were automatically enabled:
wfLoadSkin( 'MonoBook' );
wfLoadSkin( 'Timeless' );
wfLoadSkin( 'Vector' );

# End of automatically generated settings.
# Add more configuration options below.

$wgFileExtensions = array('png','svg');
$wgAllowTitlesInSVG = true;
$wgSVGConverter = 'ImageMagick';

After that I switched to my webbrowser and logged in into the wiki. I uploaded some svg file. After uploading, the upload dialog redirects to the new file page as expected. But instead of the preview of the svg, the following Text is shown:

Fehler beim Erstellen des Vorschaubildes: convert-im6.q16: delegate failed `'rsvg-convert' -o '%o' '%i'' @ error/delegate.c/InvokeDelegate/1919. convert-im6.q16: unable to open file `/tmp/magick-555JDTmUq2c6YLa': No such file or directory @ error/constitute.c/ReadImage/544. convert-im6.q16: no images defined `PNG:/tmp/transform_9af474fe35cf.png' @ error/convert.c/ConvertImageCommand/3258.

Going back into the docker container and running

apt-get update
apt-get install -y --no-install-recommends librsvg2-bin

fixes the problem.

This seems like a bug in MediaWiki or something, looking at $wgSVGConverters it looks like the command that is executed is defined in config and $wgSVGConverter specifies which one to use (the default being ImageMagick which is what you have). MediaWiki should not be using rsvg at all. I'm not sure what the issue is, but I don't think adding this dependency is the right thing to do since (as far as I can tell) it should be working without it.

Or is ImageMagick delegating the svg conversion to rsvg? In that case it's a dependency of ImageMagick and we should add it.

I guess that ImageMagick delegates the rasterisation to rsvg. At least that would explain the behaviour I observed. But I don't know it.

However, I found some documentation that sounds like rsvg is an alternative to ImageMagick:$wgSVGConverters