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

BUG: Windows 10 - Composer post-update-cmd fails #3087

Closed
1 task done
icpb opened this issue Jun 6, 2023 · 3 comments · Fixed by #3088
Closed
1 task done

BUG: Windows 10 - Composer post-update-cmd fails #3087

icpb opened this issue Jun 6, 2023 · 3 comments · Fixed by #3088
Labels

Comments

@icpb
Copy link

icpb commented Jun 6, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Windows 10 with Neos 8: "composer update" fails with "No composer manifest file found at ..." during the execution of the flow post update/install scripts. This is caused by wrong pathes for certain packages generated in ComposerUtility and PackageFactory: these wrong pathes are of the form: "X:\project\packages\X:\Project\packages\Application\packageY."

Expected Behavior

Normal executaion.

Steps To Reproduce

No response

Environment

- Flow:8.*
- Neos:8.*
- PHP:8.1

Anything else?

The problem is caused by the method collectPackageManifestData of packageManager. It returns

return array_map(function ($packageState) {
           return ComposerUtility::getComposerManifest(Files::getNormalizedPath(Files::concatenatePaths([$this->packagesBasePath, $packageState['packagePath']])));
       },

On the problematic system both $this->packagesBasePath and $packageState['packagePath'] are correct absulute pathes (but using different delimiters / and \), concatenatition then leads to the exception. I didn't look up how the pathes are set. After adjusting the function above "composer update" worked as usual.

@icpb icpb added the Bug label Jun 6, 2023
@eartahhj
Copy link

eartahhj commented Jun 7, 2023

I am glad someone else reported it because I was going crazy. I have tried to investigate this for hours but am still looking for a solution.

I use Windows 11 with Laragon 6, Neos (latest) and I am unable to install Neos.

After hours of debug and testing, this is my conclusion.
scanAvailablePackages calls findComposerPackagesInPath and this is using DirectoryIterator.

protected function findComposerPackagesInPath(string $startingDirectory): \Generator
    {
        $directories = new \DirectoryIterator($startingDirectory);
        print_r($directories);

Result:

DirectoryIterator Object
(
    [pathName:SplFileInfo:private] => C:/Programs/laragon/www/neos/Packages\.
    [fileName:SplFileInfo:private] => .
    [glob:DirectoryIterator:private] => 
    [subPathName:RecursiveDirectoryIterator:private] => 
)
DirectoryIterator Object
(
    [pathName:SplFileInfo:private] => C:/Programs/laragon/www/neos/Packages\Application\.
    [fileName:SplFileInfo:private] => .
    [glob:DirectoryIterator:private] => 
    [subPathName:RecursiveDirectoryIterator:private] => 
)
[...]

Now, the pathName here are absolute paths, is this expected by Neos? This is the path that is given to concatenatePaths() afterwards, and it gets joined with $this->packagesBasePath and this could cause the issue.

  1. Wouldn't it be better to use the constant DIRECTORY_SEPARATOR instead of appending slashes '/' which could be wrong on different systems?
    https://www.php.net/manual/en/dir.constants.php
    https://stackoverflow.com/questions/26881333/when-to-use-directory-separator-in-php-code

  2. In the case we wanted to check if the package path is absolute and/or already contains the base path of packages, we could change findComposerPackagesInPath():
    $potentialPackageDirectory = $fileInfo->getPathname() . '/';
    into:
    $potentialPackageDirectory = $fileInfo->getPathname() . DIRECTORY_SEPARATOR;

This could also be done in other places, maybe even in Bootstrap.php, but I'm not sure this would be the right solution in all places.

  1. Eventually, we could check if the packagesBasePath is already contained inside pathName, if that is the case, we remove it. I just started looking at Neos so I have no idea if this is a good solution or a very bad one, but it could be a starting point.

Now I'll go to sleep 😂😂 I will think about it more

@mhsdesign
Copy link
Member

Hi @eartahhj and @icpb it great to see you’re not giving up easily ❤️

Windows is in some cases sadly a bit special and always a little burden to maintain ^^ But nevertheless I’d like to help you out. I know the method you’re talking about. Maybe we can arrange a call and pair debug it a bit ;)

you can also reach me on the neos slack @ Marc Henry Schultz ;)

@mhsdesign mhsdesign transferred this issue from neos/neos-development-collection Jun 16, 2023
@mhsdesign mhsdesign linked a pull request Jun 16, 2023 that will close this issue
6 tasks
@mhsdesign
Copy link
Member

mhsdesign commented Jun 16, 2023

We actually found a fix in #3088

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

Successfully merging a pull request may close this issue.

3 participants