Page MenuHomePhabricator

PHP Notice: Writing to /.config/psysh is not allowed
Open, Needs TriagePublic


Steps to reproduce: run docker-compose exec mediawiki maintenance/shell.php

PHP Notice:  Writing to /.config/psysh is not allowed. in /var/www/html/vendor/psy/psysh/src/ConfigPaths.php on line 228
PHP Stack trace:
PHP   1. {main}() /var/www/html/maintenance/shell.php:0
PHP   2. require_once() /var/www/html/maintenance/shell.php:104
PHP   3. MediaWikiShell->execute() /var/www/html/maintenance/doMaintenance.php:99
PHP   4. Psy\Shell->__construct() /var/www/html/maintenance/shell.php:76
PHP   5. Psy\Configuration->getReadline() /var/www/html/vendor/psy/psysh/src/Shell.php:89
PHP   6. Psy\Configuration->getHistoryFile() /var/www/html/vendor/psy/psysh/src/Configuration.php:542
PHP   7. Psy\Configuration->setHistoryFile() /var/www/html/vendor/psy/psysh/src/Configuration.php:405
PHP   8. Psy\ConfigPaths::touchFileWithMkdir() /var/www/html/vendor/psy/psysh/src/Configuration.php:376
PHP   9. trigger_error() /var/www/html/vendor/psy/psysh/src/ConfigPaths.php:228
Psy Shell v0.9.12 (PHP 7.2.26-1+0~20191218.33+debian9~1.gbpb5a340+wmf1 — cli) by Justin Hileman

The shell works normally, but the error is triggered because $XDG_CONFIG_HOME is not set in the container, and neither is $HOME, because (on Linux hosts anyway) we are mapping external UID/GID to the container.

As a workaround we could bake XDG_CONFIG_HOME=/tmp into the image, but I'm not sure if that would have some other weird implications. Or maybe we could create a fake home directory like /home/docker and set HOME and XDG_CONFIG_HOME to that.

Event Timeline

In the context of a similar issue with wikimedia/fresh, @Niedzielski pointed out that the docker-wine project creates the user account in its entrypoint, we could consider doing something like that as well. @brennen @Jdforrester-WMF any thoughts on that?

tmp would work except you'd probably lose your files periodically. A fake home directory would work best IMO. (Or you can just disable persisting shell history. It's a nice feature though.)

Noting that this actually shows up pretty routinely in production logs as well. Makes sense to fix it in the container, but also seems like it might be a condition that the shell itself should handle without throwing the warning?

Addshore added a subscriber: Addshore.

This also currently happens in the golang mwdd port

The production issue is harder to fix because the script is used with sudo, and users probably should not share their PsySH config and command history. See T228041: Using shell.php in production sends warnings to Logstash.