silverstripe / silverstripe-upgrader

A tool to help upgrade your code to handle API changes in packages you used.
BSD 3-Clause "New" or "Revised" License
40 stars 21 forks source link

Fatal error removing Git object files on a required dependency #187

Open Amenel opened 4 years ago

Amenel commented 4 years ago

I am getting the error detailed below on the first runs of the upgrader.

This is the contents of composer.json:

    "require" : {
        "silverstripe/cms" : "3.6.5",
        "silverstripe/blog" : "2.5.2",
        "silverstripe/comments" : "2.1.6",
        "symbiote/silverstripe-memberprofiles" : "1.4.1",
        "silverstripe/recaptcha" : "2.0.3",
        "silverstripe/translatable" : "2.2.1",
        "undefinedoffset/sortablegridfield" : "1.0.1"
    }

It looks like the dependencies are downloaded to a temporary location and then removed. In that process, the removal of files used by git fails and the upgrader is interrupted. This behavior is very strange: these are files that did not exist before the upgrader command was launched. The files are created by running the upgrader, and I would guess that they are owned by the current user (i.e. me). I can't fathom why these files show up in the file explorer as read-only, which is probably why the removal fails, even when in an administrator-mode command line window.

Here are the relevant lines in the command line window:

********************************************************************************
*                                                                              *
*  STEP 1 - RUNNING RECOMPOSE                                                  *
*                                                                              *
********************************************************************************

Upgrading PHP constraint
========================

 Done.

Rebuilding dependencies
=======================

 ! [NOTE] Trying to re-require all packages

 * Requiring php:">=5.6" ................................ ✔
�
 * Requiring silverstripe/recipe-core:"4.5.1" ................................................................ ✔
�
 * Requiring silverstripe/recipe-cms:"*" ............................................................................... ✔
�
 * Requiring silverstripe/blog:"*" .............................................................................................. ✔
�
 * Requiring silverstripe/comments:"*" .............................................................................................. ✔
�
 * Requiring silverstripe/translatable:"*" ..................................................................................................... ✔
�

In Filesystem.php line 184:

  Failed to remove file "G:\TEMP\ss-upgrader-5e63fa891dde4/vendor\silverstripe\translatable\.git\objects\pack\pack-f54b55d35c34d52002d9d728577e1f4727e2a8e4.pack": unlink(G:\TEMP\ss-upgrader-5e63fa891d
  de4/vendor\silverstripe\translatable\.git\objects\pack\pack-f54b55d35c34d52002d9d728577e1f4727e2a8e4.pack): Permission denied.

all [-d|--root-dir ROOT-DIR] [-S|--strict] [-R|--recipe-core-constraint [RECIPE-CORE-CONSTRAINT]] [--cwp-constraint [CWP-CONSTRAINT]] [-P|--composer-path [COMPOSER-PATH]] [--skip-add-namespace] [-N|--nam
espace [NAMESPACE]] [--skip-reorganise] [--skip-webroot] [-p|--psr4]

Fatal error: Uncaught Symfony\Component\Filesystem\Exception\IOException: Failed to remove file "G:\TEMP\ss-upgrader-5e63fa891dde4\vendor\silverstripe\translatable\.git\objects\pack\pack-f54b55d35c34d520
02d9d728577e1f4727e2a8e4.pack": unlink(G:\TEMP\ss-upgrader-5e63fa891dde4\vendor\silverstripe\translatable\.git\objects\pack\pack-f54b55d35c34d52002d9d728577e1f4727e2a8e4.pack): Permission denied. in phar
://D:/Programs/SilverStripe-upgrader/upgrade-code-1.4.3.phar/vendor/symfony/filesystem/Filesystem.php:184
Stack trace:
#0 phar://D:/Programs/SilverStripe-upgrader/upgrade-code-1.4.3.phar/vendor/symfony/filesystem/Filesystem.php(178): Symfony\Component\Filesystem\Filesystem->remove(Array)
#1 phar://D:/Programs/SilverStripe-upgrader/upgrade-code-1.4.3.phar/vendor/symfony/filesystem/Filesystem.php(178): Symfony\Component\Filesystem\Filesystem->remove(Array)
#2 phar://D:/Programs/SilverStripe-upgrader/upgrade-code-1.4.3.phar/vendor/symfony/filesystem/Filesystem.php(178): Symfony\Component\Filesystem\Filesystem->remove(Array)
#3 in phar://D:/Programs/SilverStripe-upgrader/upgrade-code-1.4.3.phar/vendor/symfony/filesystem/Filesystem.php on line 184
maxime-rainville commented 4 years ago

It sounds like Git will create readonly files for some reason. https://stackoverflow.com/questions/6867336/why-is-git-creating-read-only-444-files

We could try adding a step to chmod all the files before clearing out the temp files. That might solve this problem.

zemiacsik commented 4 years ago

@Amenel have you found some workaround for this so far, please?

mangotonk commented 3 years ago

also having problems here