Skip to content

Commit

Permalink
Fixes #1874: sync:files fails due to non-interactive shell. (#1880)
Browse files Browse the repository at this point in the history
* Fixes #1874: sync:files fails due to non-interactive shell.

* Removing reliance on vagrant exec plug-in.

* Removing more vagrant exec stuff.

* Removing references to DRUPALVM_CONFIG_KEY.
  • Loading branch information
grasmash authored Aug 4, 2017
1 parent c971dd0 commit 3daf558
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 22 deletions.
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ If you'd like to create a [Drupal VM](https://www.drupalvm.com/) with BLT, you w

brew tap caskroom/cask
brew cask install virtualbox vagrant
vagrant plugin install vagrant-hostsupdater vagrant-exec
vagrant plugin install vagrant-hostsupdater

The minimum required versions are VirtualBox 5.1.x and Vagrant 1.8.6.

Expand Down
9 changes: 1 addition & 8 deletions scripts/drupal-vm/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,4 @@ ENV['DRUPALVM_CONFIG_DIR'] = "${drupalvm.config.dir}"
ENV['DRUPALVM_DIR'] = "vendor/geerlingguy/drupal-vm"

# Load the real Vagrantfile
load "#{__dir__}/#{ENV['DRUPALVM_DIR']}/Vagrantfile"

# Set up vagrant exec for BLT.
Vagrant.configure('2') do |config|
if Vagrant.has_plugin?('vagrant-exec')
config.exec.commands '*', directory: "/var/www/${project.machine_name}"
end
end
load "#{__dir__}/#{ENV['DRUPALVM_DIR']}/Vagrantfile"
5 changes: 3 additions & 2 deletions src/Robo/BltTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Yaml;

/**
* Base class for BLT Robo commands.
Expand Down Expand Up @@ -190,9 +191,9 @@ protected function installVagrantPlugin($plugin) {
*/
protected function executeCommandInDrupalVm($command) {
$this->say("Executing command <comment>$command</comment> inside of Drupal VM...");
$this->installVagrantPlugin('vagrant-exec');
$vm_config = Yaml::parse(file_get_contents($this->getConfigValue('vm.config')));
$result = $this->taskExecStack()
->exec("vagrant exec --tty '$command'")
->exec("vagrant ssh --command 'cd {$vm_config['ssh_home']}; $command'")
->dir($this->getConfigValue('repo.root'))
->detectInteractive()
->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
Expand Down
3 changes: 1 addition & 2 deletions src/Robo/Commands/Blt/DoctorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Acquia\Blt\Robo\Commands\Blt;

use Acquia\Blt\Robo\BltTasks;
use Acquia\Blt\Robo\Commands\Vm\VmCommand;
use Acquia\Blt\Robo\Exceptions\BltException;
use Robo\Contract\VerbosityThresholdInterface;
use Symfony\Component\Yaml\Yaml;
Expand Down Expand Up @@ -68,7 +67,7 @@ public function doctor() {
* @throws \Exception
*/
protected function executeDoctorInsideVm() {
$drupal_vm_config_filepath = $this->getConfigValue(VmCommand::DRUPALVM_CONFIG_KEY);
$drupal_vm_config_filepath = $this->getConfigValue('vm.config');
$drupal_vm_config = Yaml::parse(file_get_contents($drupal_vm_config_filepath));
$repo_root = $drupal_vm_config['drupal_core_path'] . '/..';
if (strstr($repo_root, '{{')) {
Expand Down
1 change: 0 additions & 1 deletion src/Robo/Commands/Setup/DrupalCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function ($string) {
->option('account-name', $username, '=')
->option('account-mail', $this->getConfigValue('drupal.account.mail'))
->option('locale', $this->getConfigValue('drupal.locale'))
->assume(TRUE)
->printOutput(TRUE);

$config_strategy = $this->getConfigValue('cm.strategy');
Expand Down
2 changes: 1 addition & 1 deletion src/Robo/Commands/Sync/RefreshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RefreshCommand extends BltTasks {
*
* @command sync:refresh:all
*
* This command does not use @executeInDrupalVm because it would require
* This command does not use @executeInDrupalVm because it would require
* SSH forwarding.
*
* @see https://github.com/acquia/blt/issues/1875
Expand Down
6 changes: 1 addition & 5 deletions src/Robo/Commands/Vm/VmCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
* Defines commands in the "vm" namespace.
*/
class VmCommand extends BltTasks {

const DRUPALVM_CONFIG_KEY = 'vm.config';

protected $drupalVmAlias;
protected $drupalVmVersionConstraint;
protected $defaultDrupalVmDrushAliasesFile;
Expand Down Expand Up @@ -41,7 +38,7 @@ public function initialize() {
$this->defaultDrushAliasesFile = $this->getConfigValue('blt.root') . '/template/drush/site-aliases/aliases.drushrc.php';
$this->projectDrushAliasesFile = $this->getConfigValue('repo.root') . '/drush/site-aliases/aliases.drushrc.php';
$this->projectDrupalVmVagrantfile = $this->getConfigValue('repo.root') . '/Vagrantfile';
$this->projectDrupalVmConfigFile = $this->getConfigValue(self::DRUPALVM_CONFIG_KEY);
$this->projectDrupalVmConfigFile = $this->getConfigValue('vm.config');
$this->vmDir = dirname($this->projectDrupalVmConfigFile);
$this->vmConfigDir = str_replace($this->getConfigValue('repo.root') . DIRECTORY_SEPARATOR, '', $this->vmDir);
$this->vmConfigFile = array_pop((explode(DIRECTORY_SEPARATOR, $this->projectDrupalVmConfigFile)));
Expand Down Expand Up @@ -267,7 +264,6 @@ protected function checkRequirements() {
}
else {
$this->installVagrantPlugin('vagrant-hostsupdater');
$this->installVagrantPlugin('vagrant-exec');
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/Robo/Inspector/Inspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Acquia\Blt\Robo\Config\YamlConfigProcessor;
use Acquia\Blt\Robo\Exceptions\BltException;
use Acquia\Blt\Robo\Commands\Vm\VmCommand;
use League\Container\ContainerAwareInterface;
use League\Container\ContainerAwareTrait;
use Consolidation\Config\Loader\YamlConfigLoader;
Expand Down Expand Up @@ -329,7 +328,7 @@ public function isDrupalVmConfigValid() {
}
}

$file_path = $this->getConfigValue(VmCommand::DRUPALVM_CONFIG_KEY);
$file_path = $this->getConfigValue('vm.config');
if (!file_exists($file_path)) {
$this->logger->error("$file_path is missing. Please re-run `blt vm`.");
$valid = FALSE;
Expand Down
3 changes: 3 additions & 0 deletions src/Robo/Tasks/DrushTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ protected function init() {
if (!isset($this->assume) && $this->input->hasOption('yes') && $this->input->getOption('yes')) {
$this->assume(TRUE);
}
elseif (!isset($this->assume) && !$this->input->isInteractive()) {
$this->assume(TRUE);
}

$this->defaultsInitialized = TRUE;
}
Expand Down

0 comments on commit 3daf558

Please sign in to comment.