lando / pantheon

The Official Lando Pantheon plugin.
https://docs.lando.dev/pantheon
GNU General Public License v3.0
11 stars 18 forks source link

Cannot find pantheon.users table in prepend.php #139

Closed jlicht closed 1 year ago

jlicht commented 2 years ago

I am receiving the following error when trying to load any Lando site using the Pantheon recipe:

Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'pantheon.users' doesn't exist in /srv/includes/prepend.php:93 Stack trace: #0 /srv/includes/prepend.php(93): PDO->exec('SELECT count(*)...') #1 {main} thrown in /srv/includes/prepend.php on line 93

I have uninstalled and reinstalled Lando (v3.6.5), deleted the ~/.lando file, deleted and Lando containers, and run lando rebuild on the affected sites. This is affecting all my sites using the Pantheon recipe, but no others.

The error in prepend.php implies that the database connection is failing, but I am able to connect to the database from the command line within the container using the same credentials; and drush commands can also connect to the database.

GuyPaddock commented 1 year ago

I am seeing this now as well, with:

GuyPaddock commented 1 year ago

Actually... I believe https://github.com/lando/pantheon/pull/144 or https://github.com/lando/pantheon/pull/146 would resolve this.

GuyPaddock commented 1 year ago

Until either of the issues above are merged, I am working around it with a .lando.yml file that looks like this:

name: my_project
recipe: pantheon
config:
  framework: drupal9
  site: my-site
  id: my-site-uuid
services:
  appserver:
    run_as_root:
      # Patch prepend.php to work around this issue:
      # https://github.com/lando/pantheon/issues/139
      - curl https://github.com/lando/pantheon/commit/a7691bc19283a72b34f99ac482f6c8c2fb040bd8.patch -o /tmp/prepend.patch
      - cp /srv/includes/prepend.php /tmp/prepend.php
      - cd /tmp && patch -p3 </tmp/prepend.patch
      - cp /tmp/prepend.php /srv/includes/prepend.php

https://github.com/lando/pantheon/commit/a7691bc19283a72b34f99ac482f6c8c2fb040bd8.patch is the patch from https://github.com/lando/pantheon/pull/144.

In case you're wondering why I didn't just patch ~/.lando/config/pantheon/prepend.php and leave it at that, it's because this file gets refreshed every time you do a lando rebuild. I tried just mounting my patched copy over /srv/includes/prepend.php but it got silently ignored, presumably because the pantheon recipe runs after the base config and replaces the mount with the default one that mounts from ${options.confDest}/prepend.php.

If there's a saner way to patch prepend.php or fork the recipe, please let me know! This workaround feels like a kludge but at least I can share it with my team through Git.