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

Non Descriptive Error Failing apply patch #316

Closed
juanmrad opened this issue Jun 16, 2020 · 2 comments · Fixed by #379
Closed

Non Descriptive Error Failing apply patch #316

juanmrad opened this issue Jun 16, 2020 · 2 comments · Fixed by #379

Comments

@juanmrad
Copy link

Issue:

The Following error is happening:

Could not apply patch! Skipping. The error was: Cannot apply patch patches/symfony/mime/PATCH-PHP-7-4-returns-duplicate-MimeType-for-some-files.patch

My Patch File:

From a0d263d0874788afcbbdedc2061c020017b9d548 Mon Sep 17 00:00:00 2001
From: Juan Mrad <__________>
Date: Tue, 16 Jun 2020 11:24:48 -0500
Subject: [PATCH] as

---
 FileinfoMimeTypeGuesser.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/FileinfoMimeTypeGuesser.php b/FileinfoMimeTypeGuesser.php
index b91a4ff..c135bca 100644
--- a/FileinfoMimeTypeGuesser.php
+++ b/FileinfoMimeTypeGuesser.php
@@ -58,6 +58,13 @@ class FileinfoMimeTypeGuesser implements MimeTypeGuesserInterface
             return null;
         }

-        return $finfo->file($path);
+        $mimeType = $finfo->file($path);
+
+        if ($mimeType) {
+            $mimeStart = substr($mimeType, 0, strlen($mimeType) / 2);
+            $mimeType = substr($mimeType, strlen($mimeType) / 2) === $mimeStart ? $mimeStart : $mimeType;
+        }
+
+        return $mimeType;
     }
 }
--
2.24.1 (Apple Git-126)

My Composer file:


    "extra": {
        "composer-exit-on-patch-failure": true,
        "patches": {
            "symfony/mime": {
                "Bug: PHP 7.4 returns duplicate MimeType for some file types. Check against itself and return non duplicate MimeType": "patches/symfony/mime/PATCH-PHP-7-4-returns-duplicate-MimeType-for-some-files.patch"
            }
        }
    },

There doesn't seem to be any description on why it failed.

After adding $e->getTraceAsString():

 #0 /workdir/vendor/cweagans/composer-patches/src/Patches.php(313): cweagans\Composer\Patches->getAndApplyPatch()
#1 [internal function]: cweagans\Composer\Patches->postInstall()
#2 phar:///workdir/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(164): call_user_func()
#3 phar:///workdir/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(116): Composer\EventDispatcher\EventDispatcher->doDispatch()
#4 phar:///workdir/bin/composer/src/Composer/Installer.php(636): Composer\EventDispatcher\EventDispatcher->dispatchPackageEvent()
#5 phar:///workdir/bin/composer/src/Composer/Installer.php(232): Composer\Installer->doInstall()
#6 phar:///workdir/bin/composer/src/Composer/Command/InstallCommand.php(122): Composer\Installer->run()
#7 phar:///workdir/bin/composer/vendor/symfony/console/Command/Command.php(245): Composer\Command\InstallCommand->execute()
#8 phar:///workdir/bin/composer/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run()
#9 phar:///workdir/bin/composer/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand()
#10 phar:///workdir/bin/composer/src/Composer/Console/Application.php(281): Symfony\Component\Console\Application->doRun()
#11 phar:///workdir/bin/composer/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun()
#12 phar:///workdir/bin/composer/src/Composer/Console/Application.php(113): Symfony\Component\Console\Application->run()
#13 phar:///workdir/bin/composer/bin/composer(61): Composer\Console\Application->run()
#14 /workdir/bin/composer(24): require('phar:///workdir...')
#15 {main}
@ssaaiidd
Copy link

Make sure the Patch package is installed on the system. I had a similar problem, this comment helped. With patch -v you can test whether the package is installed.

@juanmrad
Copy link
Author

@ssaaiidd Yes found out that was the issue. definitively need to be more descriptive with the error :/ also nowhere it said it needed patch to be installed.

afilina added a commit to afilina/composer-patches that referenced this issue Aug 17, 2021
At no point does the documentation mention this dependency, not even in the resulting error message.

Closes cweagans#316
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants