Fix require command to allow working on network mounts, fixes #8231
parent
79e4ff4373
commit
33759d02c4
|
@ -26,6 +26,7 @@ use Composer\Plugin\PluginEvents;
|
|||
use Composer\Repository\CompositeRepository;
|
||||
use Composer\Repository\PlatformRepository;
|
||||
use Composer\IO\IOInterface;
|
||||
use Composer\Util\Silencer;
|
||||
|
||||
/**
|
||||
* @author Jérémy Romey <jeremy@free-agent.fr>
|
||||
|
@ -103,11 +104,6 @@ EOT
|
|||
|
||||
return 1;
|
||||
}
|
||||
if (!is_writable($this->file)) {
|
||||
$io->writeError('<error>'.$this->file.' is not writable.</error>');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (filesize($this->file) === 0) {
|
||||
file_put_contents($this->file, "{\n}\n");
|
||||
|
@ -116,6 +112,14 @@ EOT
|
|||
$this->json = new JsonFile($this->file);
|
||||
$this->composerBackup = file_get_contents($this->json->getPath());
|
||||
|
||||
// check for writability by writing to the file as is_writable can not be trusted on network-mounts
|
||||
// see https://github.com/composer/composer/issues/8231 and https://bugs.php.net/bug.php?id=68926
|
||||
if (!is_writable($this->file) && !Silencer::call('file_put_contents', $this->file, $this->composerBackup)) {
|
||||
$io->writeError('<error>'.$this->file.' is not writable.</error>');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
$composer = $this->getComposer(true, $input->getOption('no-plugins'));
|
||||
$repos = $composer->getRepositoryManager()->getRepositories();
|
||||
|
||||
|
|
Loading…
Reference in New Issue