diff --git a/.github/workflows/TestBinaryInstaller.yml b/.github/workflows/TestBinaryInstaller.yml index daba5db0f..7eba557e4 100644 --- a/.github/workflows/TestBinaryInstaller.yml +++ b/.github/workflows/TestBinaryInstaller.yml @@ -54,3 +54,16 @@ jobs: run: | ddev exec touch /var/www/html/composer-cache/files/lullabot/drainpipe/bin/task/3.28.0/task_linux_amd64.tar ddev composer install + + - name: Test installing without composer cache + run: | + ddev composer install --no-cache + test -x vendor/bin/task + ddev composer install + test -x vendor/bin/task + rm -rf vendor + ddev composer install + test -x vendor/bin/task + rm -rf vendor + ddev composer install --no-cache + test -x vendor/bin/task diff --git a/src/BinaryInstaller.php b/src/BinaryInstaller.php index 371f63f6e..98238261b 100644 --- a/src/BinaryInstaller.php +++ b/src/BinaryInstaller.php @@ -196,10 +196,15 @@ protected function installBinary($binary, $version, $url, $sha, $hashalgo = 'sha $httpDownloader = Factory::createHttpDownloader($this->io, $this->config); $parts = explode('/', $url); $fileName = array_pop($parts); - $cacheFolder = $this->cache->getRoot().$binary.\DIRECTORY_SEPARATOR.$version; - $cacheDestination = $cacheFolder.\DIRECTORY_SEPARATOR.$fileName; - $cacheExtractedBinary = $cacheFolder.\DIRECTORY_SEPARATOR.$binary; - $binDestination = $bin.\DIRECTORY_SEPARATOR.$binary; + if ($this->cache->isEnabled()) { + $cacheFolder = $this->cache->getRoot() . $binary . \DIRECTORY_SEPARATOR . $version; + } + else { + $cacheFolder = sys_get_temp_dir() . \DIRECTORY_SEPARATOR . $binary . \DIRECTORY_SEPARATOR . $version; + } + $cacheDestination = $cacheFolder . \DIRECTORY_SEPARATOR . $fileName; + $cacheExtractedBinary = $cacheFolder . \DIRECTORY_SEPARATOR . $binary; + $binDestination = $bin . \DIRECTORY_SEPARATOR . $binary; // Check the cache. $fs->ensureDirectoryExists($cacheFolder);