Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission Denied During BLT Sync #2641

Closed
mikemadison13 opened this issue Mar 14, 2018 · 20 comments
Closed

Permission Denied During BLT Sync #2641

mikemadison13 opened this issue Mar 14, 2018 · 20 comments
Labels
Support A support request

Comments

@mikemadison13
Copy link
Contributor

My system information:

  • Operating system type: [replace]
  • Operating system version: [replace]
  • BLT version: 9.0.3

Output of blt doctor:

blt doctor
+---------------------------+------------------------------------------------------------+
| Property                  | Value                                                      |
+---------------------------+------------------------------------------------------------+
| %paths.%root              | /var/www/capitalcamp/docroot                               |
| %paths.%site              | sites/default                                              |
| %paths.%modules           | sites/all/modules                                          |
| %paths.%themes            | sites/all/themes                                           |
| %paths.%config-sync       | /var/www/capitalcamp/config/default                        |
| alias-searchpaths.0       | /var/www/capitalcamp/drush/sites                           |
| blt-version               | 9.0.3                                                      |
| composer-version          | Composer version 1.6.3 2018-01-31 16:28:17                 |
| config-sync               | /var/www/capitalcamp/config/default                        |
| db-driver                 | mysql                                                      |
| db-hostname               | localhost                                                  |
| db-name                   | drupal                                                     |
| db-password               | drupal                                                     |
| db-port                   | 3306                                                       |
| db-username               | drupal                                                     |
| drupal-settings-file      | sites/default/settings.php                                 |
| drupal-version            | 8.5.0                                                      |
| drush-alias-files.0       | /var/www/capitalcamp/drush/sites/capitalcamp.site.yml      |
| drush-alias-files.1       | /var/www/capitalcamp/drush/sites/example.acsf.site.yml     |
| drush-alias-files.2       | /var/www/capitalcamp/drush/sites/example.local.site.yml    |
| drush-conf.0              | /var/www/capitalcamp/vendor/drush/drush/drush.yml          |
| drush-conf.1              | /var/www/capitalcamp/drush/drush.yml                       |
| drush-conf.2              | /var/www/capitalcamp/docroot/sites/default/local.drush.yml |
| drush-script              | /var/www/capitalcamp/vendor/bin/drush                      |
| drush-temp                | /tmp                                                       |
| drush-version             | 9.2.1                                                      |
| modules                   | sites/all/modules                                          |
| php-bin                   | /usr/bin/php7.1                                            |
| php-conf.0                | /etc/php/7.1/cli/php.ini                                   |
| php-os                    | Linux                                                      |
| root                      | /var/www/capitalcamp/docroot                               |
| site                      | sites/default                                              |
| stacks.drupal-vm.inited   | true                                                       |
| stacks.dev-desktop.inited | false                                                      |
| themes                    | sites/all/themes                                           |
| uri                       | http://local.capitalcamp.com                               |
+---------------------------+------------------------------------------------------------+
+------------------------------------------+-----------------------------------------------------+
| Check                                    | Problem                                             |
+------------------------------------------+-----------------------------------------------------+
| DrupalCheck:checkDrupalBootstrapped      | Could not bootstrap Drupal via drush without alias. |
| DrupalCheck:checkDrupalInstalled         | Drupal is not installed.                            |
|                                          |                                                     |
|                                          | Run `blt drupal:install` to install Drupal locally. |
| FileSystemCheck:checkFileSystem:%files   | Public files directory is not set.                  |
| FileSystemCheck:checkFileSystem:%private | Private files directory is not set.                 |
| FileSystemCheck:checkFileSystem:%temp    | Temporary files directory is not set.               |
| NodeCheck:checkNodeVersionFileExists     | .node-version file exists                           |
+------------------------------------------+-----------------------------------------------------+
[error]  BLT Doctor discovered one or more critical issues. 

When I run this command:

blt sync

I get the following output:

blt sync -vvv
> source:build:composer
[Exec] Running export COMPOSER_EXIT_ON_PATCH_FAILURE=1; composer install --ansi --no-interaction in /var/www/capitalcamp
Warning: The value for extra.installer-paths in composer.json differs from BLT's recommended values.
See /var/www/capitalcamp/vendor/acquia/blt/template/composer.json
Gathering patches for root package.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> PhantomInstaller\Installer::installPhantomJS
   - PhantomJS v2.1.1 is already installed. Skipping the installation.
[Exec] Done in 5.057s
> blt:init:settings
[Filesystem\FilesystemStack] _chmod ["/var/www/capitalcamp/docroot/sites/default",511]
[Filesystem\FilesystemStack] _chmod ["/var/www/capitalcamp/docroot/sites/default/settings.php",511]
[File\Write] Writing to /var/www/capitalcamp/docroot/sites/default/settings.php.
[Filesystem\FilesystemStack] _chmod ["/var/www/capitalcamp/docroot/sites/default/settings.php",420]
> drupal:sync:db
[Acquia\Blt\Robo\Tasks\DrushTask] Running /var/www/capitalcamp/vendor/bin/drush cache-clear drush --no-interaction --ansi &&
 /var/www/capitalcamp/vendor/bin/drush sql-drop --no-interaction --ansi &&
 /var/www/capitalcamp/vendor/bin/drush sql-sync @capitalcamp.test @self --structure-tables-key=lightweight --create-db --no-interaction --ansi &&
 /var/www/capitalcamp/vendor/bin/drush sql-sanitize --no-interaction --ansi &&
 /var/www/capitalcamp/vendor/bin/drush cache-clear drush --no-interaction --ansi &&
 /var/www/capitalcamp/vendor/bin/drush sqlq "TRUNCATE cache_entity" --no-interaction --ansi in /var/www/capitalcamp/docroot
 [success] 'drush' cache was cleared.
You will destroy data in drupal and replace with data from staging-7892.prod.hosting.acquia.com/capitalcampstg.
 [notice] Starting to create database on target.
Creating database drupal. Any existing database will be dropped!

 // Do you really want to continue?: yes.                                       

 [notice] Starting to dump database on source.
sh: 1: cannot create auto.gz: Permission denied
mysqldump: Got errno 32 on write
 [error]  Database dump failed 
 [notice] Command dispatch complete
 [error]  sql-dump failed. 
[Acquia\Blt\Robo\Tasks\DrushTask]  Exit code 1  Time 11.305s
[error]   
[error]  Command `drupal:sync:db ` exited with code 1. 

And I expected this to happen:
The database to sync.

I'm executing these commands inside of a newly created VM (nuked the old one and re-created after updating to BLT 9 / Drush 9).

I am using self as the alias.

Setup executes without incident.

I have confirmed that my /tmp directory is modded 777 and tried changing owner from root to vagrant without any success.

@malikkotob ran into a similar issue, he may have additional information to contribute.

cc @geerlingguy

@geerlingguy
Copy link
Contributor

If this is syncing from a remote server to the local environment, it looks like the remote dump is failing, and it doesn’t have anything to do with the local environment. Can you verify the remote Server has a writeable temp dir for whatever user you’re ssh’ing as?

Also I’ve never seen cannot create auto.gz; I wonder what “auto.gz” is?

@mikemadison13
Copy link
Contributor Author

It's worth noting that this behavior isn't occurring with the previous version of Drush / BLT / etc. It's only been introduced after this update. Having said that, I wasn't trying to do the sync from inside the vm itself, i always did it from outside with the remote execution.

The tmp folder on the remote server would appear to be set to 777?

ls -lah
drwxrwxrwt  25 root root 4.0K Mar 14 22:28 tmp

@grasmash
Copy link
Contributor

Can you execute the drush command directly and see if it works?

@malikkotob
Copy link
Contributor

I encountered this same issue. I was running blt sync:db within the VM. Also ran the drush command directly with the same error.

@geerlingguy
Copy link
Contributor

@mikemadison13
Copy link
Contributor Author

@grasmash i did try and run the command directly with drush and I experienced the same failure.

@grasmash grasmash added the Support A support request label Mar 15, 2018
@geerlingguy
Copy link
Contributor

Can you also try with drush -vvvv and drop the verbose output in here? Maybe it's an alias issue?

@grasmash
Copy link
Contributor

Ok, so that means to me that this is likely a Drush bug. This is suspiciously similar to drush-ops/drush#3417, the fix for which contained: drush-ops/drush@997f8d3#diff-fb2c277772bf5979ffd2cd9676de3c88R139

It looks like 'auto' is being incorrectly used as the file name. This might prevent the dumped file from being downloaded.

@grasmash
Copy link
Contributor

Pinging @weitzman and @greg-1-anderson for visibility.

@grasmash
Copy link
Contributor

The root issue here seems to be that drush is not correctly determining the filepath for the dump file. On Acquia Cloud, this means it attempts to dump `auto.gz' to a non-writable directory, hence:

sh: 1: cannot create auto.gz: Permission denied

I'm not sure what part of drush is meant to read the auto value?

@weitzman
Copy link

I added a release note about this https://github.com/drush-ops/drush/releases/tag/9.2.1

@grasmash
Copy link
Contributor

grasmash commented Mar 15, 2018

Looks like @mikemadison13 is using 9.2.1 though?

@mikemadison13 can you confirm this is the version of Drush on both local and remote?

@grasmash
Copy link
Contributor

grasmash commented Mar 15, 2018

Actually, we know that Drush 9.2.1 is at vendor/bin/drush, and any call to drush on either system should redispatch to that, so something else is going on here.

@weitzman
Copy link

weitzman commented Mar 15, 2018

Sometimes a Drush update happens on a lower environment but has not made it to the upper environment and thus a sql:sync can give this error. If both codebases are on 9.2.1 then we have more digging to do.

@grasmash
Copy link
Contributor

@lcatlett has a suggested workaround @mikemadison13. Define the absolute path to drush and to the root dir it your drush alias:

dev:
  root: /var/www/html/capitalcamp/docroot
  paths:
    drush-script: /var/www/html/capitalcamp/vendor/bin/drush

@mikemadison13
Copy link
Contributor Author

will try the above shortly @grasmash

thanks @lcatlett !

@mikemadison13
Copy link
Contributor Author

mikemadison13 commented Mar 15, 2018

@weitzman i am pretty sure based on the status calls i've done that the cloud environment is still running drush 8.1.15.

drush @capitalcamp.test status
 Drupal version                  :  8.4.2                                                                                                                                             
 Site URI                        :                                                                                                              
 Database driver                 :  mysql                                                                                                                                             
 Database hostname               :                                                                                                                                       
 Database port                   :                                                                                                                                               
 Database username               :                                                                                                                                              
 Database name                   :                                                                                                                                     
 Database                        :  Connected                                                                                                                                         
 Drupal bootstrap                :  Successful                                                                                                                                        
 Drupal user                     :                                                                                                                                                    
 Default theme                   :                                                                                                                                     
 Administration theme            :  seven                                                                                                                                             
 PHP executable                  :  /usr/local/php5.6/bin/php                                                                                                                         
 PHP configuration               :  /usr/local/php5.6/etc/cli/php.ini                                                                                                                 
 PHP OS                          :  Linux                                                                                                                                             
 Drush script                    : /vendor/drush/drush/drush.php                                                                                         
 Drush version                   :  8.1.15                                                                                                                                            
 Drush temp directory            :  /tmp/capitalcampstg                                                                                                                           
 Drush configuration             :  /drush/drushrc.php /etc/drush/drushrc.php                                                                             
 Drush alias files               :  /capitalcamp.aliases.drushrc.php /docroot/../drush/site-aliases/capitalcamp.aliases.drushrc.php 
                                    /docroot/../drush/site-aliases/aliases.drushrc.php                                                                    
 Install profile                 :  lightning                                                                                                                                         
 Drupal root                     :  /docroot                                                                                                              
 Drupal Settings File            :  sites/default/settings.php                                                                                                                        
 Site path                       :  sites/default                                                                                                                                     
 File directory path             :  sites/default/files                                                                                                                               
 Private file directory path     :  /files/capitalcamp.test/files-private                                                                                                         
 Temporary file directory path   :  /tmp/capitalcampstg                                                                                                                           
 Sync config path                :  /www/html/capitalcampstg/config/default 

@grasmash
Copy link
Contributor

Great. Everything makes sense. Thanks for your time @weitzman.

@mikemadison13 I'm going to close this issue. It seems like the resolution is to deploy Drush 9.2.0 to your remote env. In the mean time, I'm committing a workaround: #2642

It seems like there is also another that @lcatlett and @malikkotob encountered that has to do with Drush alias discovery and Drupal root settings. Let's address that in a separate issue once the issue can be described.

@brooke-heaton
Copy link
Contributor

brooke-heaton commented Apr 2, 2018

FWIW I have updated BOTH local and cloud (test) to drush 9.2.1 and simply have

dev:
  root: /var/www/html/mysite/docroot
  paths:
    drush-script: drush9

This is working for me. I didn't need an absolute path.

@christopher-hopper
Copy link
Contributor

If you're updating Drush locally, and haven't deployed that remotely, you can also avoid this problem by setting the following in your drush/drush.yml

# This section is for setting command-specific options.
command:
  sql:
    sync:
      options:
        source-dump: /tmp/tmp.sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support A support request
Projects
None yet
Development

No branches or pull requests

7 participants