Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit d1fa371

Browse files
authored
Fixes #2938: Support running BLT outside of a VM. (#3613)
1 parent 9cc6346 commit d1fa371

File tree

7 files changed

+7
-25
lines changed

7 files changed

+7
-25
lines changed

config/build.yml

+4
Original file line numberDiff line numberDiff line change
@@ -264,5 +264,9 @@ validate:
264264
vm:
265265
enable: false
266266
config: ${repo.root}/box/config.yml
267+
# By default, BLT should only be run from inside a VM, if it exists. You can
268+
# choose to run it on the host instead by setting this to false, and changing
269+
# drush.aliases.local to an alias that can SSH into the VM.
270+
blt-in-vm: true
267271
vagrant:
268272
hostname: ${project.local.hostname}

src/Robo/Commands/Setup/BuildCommand.php

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class BuildCommand extends BltTasks {
2222
* @interactGenerateSettingsFiles
2323
*
2424
* @validateDrushConfig
25-
* @validateMySqlAvailable
2625
* @validateDocrootIsPresent
2726
* @executeInVm
2827
*

src/Robo/Commands/Setup/DrupalCommand.php

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class DrupalCommand extends BltTasks {
1616
*
1717
* @command internal:drupal:install
1818
*
19-
* @validateMySqlAvailable
2019
* @validateDrushConfig
2120
* @hidden
2221
*

src/Robo/Commands/Tests/BehatCommand.php

-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public function initialize() {
4444
* @interactGenerateSettingsFiles
4545
* @interactInstallDrupal
4646
* @interactConfigureBehat
47-
* @validateMySqlAvailable
4847
* @validateDrupalIsInstalled
4948
* @validateBehatIsConfigured
5049
* @validateVmConfig
@@ -78,7 +77,6 @@ public function behat() {
7877
*
7978
* @aliases tbd tests:behat:definitions
8079
*
81-
* @validateMySqlAvailable
8280
* @executeInVm
8381
*/
8482
public function behatDefinitions($options = ['mode' => 'l']) {

src/Robo/Commands/Tests/DrupalTestCommand.php

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public function run() {
9696
*
9797
* @interactGenerateSettingsFiles
9898
* @interactInstallDrupal
99-
* @validateMySqlAvailable
10099
* @validateDrupalIsInstalled
101100
* @validateVmConfig
102101
* @launchWebServer

src/Robo/Hooks/DrupalVmHook.php

+3-9
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
namespace Acquia\Blt\Robo\Hooks;
44

55
use Acquia\Blt\Robo\BltTasks;
6-
use Consolidation\AnnotatedCommand\AnnotationData;
7-
use Symfony\Component\Console\Input\InputInterface;
8-
use Symfony\Component\Console\Output\OutputInterface;
96
use Acquia\Blt\Robo\Exceptions\BltException;
107

118
/**
@@ -17,13 +14,10 @@ class DrupalVmHook extends BltTasks {
1714
* Ask whether user would like to execute on host machine.
1815
*
1916
* @hook interact @executeInVm
17+
* @throws BltException
2018
*/
21-
public function interactExecuteOnHost(
22-
InputInterface $input,
23-
OutputInterface $output,
24-
AnnotationData $annotationData
25-
) {
26-
if (!$this->getInspector()->isVmCli() && $this->getInspector()->isDrupalVmLocallyInitialized()) {
19+
public function interactExecuteOnHost() {
20+
if (!$this->getInspector()->isVmCli() && $this->getInspector()->isDrupalVmLocallyInitialized() && $this->getConfigValue('vm.blt-in-vm')) {
2721
$this->logger->warning("Drupal VM is locally initialized, but you are not inside the VM.");
2822
$this->logger->warning("You should execute all BLT commands from within Drupal VM.");
2923
$this->logger->warning("Use <comment>vagrant ssh</comment> to enter the VM.");

src/Robo/Hooks/ValidateHook.php

-11
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,6 @@ public function validateBehatIsConfigured(CommandData $commandData) {
9494
}
9595
}
9696

97-
/**
98-
* Validates that MySQL is available.
99-
*
100-
* @hook validate @validateMySqlAvailable
101-
*/
102-
public function validateMySqlAvailable() {
103-
if (!$this->getInspector()->isMySqlAvailable()) {
104-
throw new BltException("MySql is not available. Please run `blt doctor` to diagnose the issue.");
105-
}
106-
}
107-
10897
/**
10998
* Validates that required settings files exist.
11099
*

0 commit comments

Comments
 (0)