BLT with Lando mostly just works™ but to get a better integration add the following to your .lando.yml file and rebuild the containers:
tooling:
blt:
service: appserver
cmd: /app/vendor/bin/blt
You can also update your blt config (blt/blt.yml) with the lando hostname syntax:
project:
machine_name: abc
prefix: ABC
human_name: 'A website'
profile:
name: standard
local:
protocol: http
hostname: ${project.machine_name}.lndo.site
There are a couple tricky bits that you need to watch out for.
When running lando blt tests:behat
, depending on your Lando recipe you may get an error about a missing Chrome driver. If that happens, you'll need to add the driver installation to your Lando recipe.
If you get timeout errors, try running the blt command with the -vvv option to get more output: lando blt -vvv tests:behat
. If you get errors like the ones below then the issue is with the permissions on your container.
[Filesystem\FilesystemStack] mkdir ["/app/reports"]
[info] Killing running google-chrome processes...
[info] Killing all processes on port '9222'...
[info] Launching headless chrome...
[Robo\Common\ProcessExecutor] Running 'google-chrome' --headless --disable-web-security --remote-debugging-port=9222 http://localhost in /app
[info] Waiting for response from http://localhost:9222...
[debug] cURL error 7: Failed to connect to localhost port 9222: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
...
[info] Killing running google-chrome processes...
[info] Killing all processes on port '9222'...
[error] Timed out.
12.412s total time elapsed.
If you ssh into lando and run the google-chrome command directly, you'll see:
$ google-chrome --headless --disable-web-security --remote-debugging-port=9222 http://localhost
Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
Failed to generate minidump.Illegal instruction
The solution to this is to invoke the chrome command with the --no-sandbox
option. To do that, you'll need to patch your BLT installation to add that option to the launchChrome() function in the Behat command.
See the Patches documentation for tips on applying patches to packages via Composer.
Unresolved
When running many BLT or drush commands through Lando when ACSF has been initialized, notices like the one below appear. It appears the $_SERVER['HTTP_HOST]
and $_SERVER['argv']
variables are not being populated in Lando. Beyond warnings/notices displayed to the screen, it's unclear what the impact of this is.
example output
<em class="placeholder">Notice</em>: Undefined index: HTTP_HOST in <em class="placeholder">require()</em> (line <em class="placeholder">119</em> of <em class="placeholder">/app/vendor/acquia/blt/settings/blt.settings.php</em>). <pre class="backtrace">require('/app/vendor/acquia/blt/settings/blt.settings.php') (Line: 797)
require('/app/docroot/sites/default/settings.php') (Line: 122)
Drupal\Core\Site\Settings::initialize('/app/docroot', 'sites/default', Object) (Line: 1056)
Drupal\Core\DrupalKernel->initializeSettings(Object) (Line: 271)
Drupal\Core\DrupalKernel::createFromRequest(Object, Object, 'prod', 1) (Line: 172)
Drush\Boot\DrupalBoot8->bootstrapDrupalConfiguration(NULL) (Line: 295)
Drush\Boot\BootstrapManager->doBootstrap(3, 6, NULL) (Line: 504)
Drush\Boot\BootstrapManager->bootstrapMax() (Line: 224)
Drush\Application->bootstrapAndFind('csex') (Line: 191)
Drush\Application->find('csex') (Line: 229)
Symfony\Component\Console\Application->doRun(Object, Object) (Line: 148)
Symfony\Component\Console\Application->run(Object, Object) (Line: 112)
Drush\Runtime\Runtime->doRun(Array) (Line: 41)
Drush\Runtime\Runtime->run(Array) (Line: 66)
require('/app/vendor/drush/drush/drush.php') (Line: 17)
drush_main() (Line: 141)
require('phar:///usr/local/bin/drush/bin/drush.php') (Line: 10)
</pre>
Notice: Undefined index: argv in Symfony\Component\Console\Input\ArgvInput->__construct() (line 53 of /app/vendor/symfony/console/Input/ArgvInput.php).
Symfony\Component\Console\Input\ArgvInput->__construct(NULL) (Line: 113)
require('/app/vendor/acquia/blt/settings/blt.settings.php') (Line: 797)
require('/app/docroot/sites/default/settings.php') (Line: 122)
Drupal\Core\Site\Settings::initialize('/app/docroot', 'sites/default', Object) (Line: 1056)
Drupal\Core\DrupalKernel->initializeSettings(Object) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)