Skip to content

Commit

Permalink
Fix write permissions when running CLI commands
Browse files Browse the repository at this point in the history
Pass the current user's UID when running on linux, as the mounted volumes are _directly_ accessed from the container. Unlike macOs, where the mounted volumes are is a Docker shared filesystem that correctly maps user permissions.

Fixes #183.
  • Loading branch information
joehoyle committed Aug 27, 2020
1 parent 8b5f30b commit 1c9fd33
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion inc/composer/class-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,16 @@ protected function exec( InputInterface $input, OutputInterface $output, ?string
$lines = exec( 'tput lines' );
$has_stdin = ! posix_isatty( STDIN );
$has_stdout = ! posix_isatty( STDOUT );
if ( php_uname( 's' ) === 'Linux' ) {
$user = '$UID';
} else {
$user = 'www-data'
}
$command = sprintf(
'docker exec -e COLUMNS=%d -e LINES=%d -u www-data %s %s %s %s',
'docker exec -e COLUMNS=%d -e LINES=%d -u %s %s %s %s %s',
$columns,
$lines,
$user,
( ! $has_stdin && ! $has_stdout ) && $program === 'wp' ? '-ti' : '', // forward wp-cli's isPiped detection.
$container_id,
$program ?? '',
Expand Down

0 comments on commit 1c9fd33

Please sign in to comment.