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

Fix POSIX only detection of absolute paths in config #10406

Closed
wants to merge 2 commits into from

Conversation

rarila
Copy link
Contributor

@rarila rarila commented Nov 23, 2023

With #10370 a bug in FileFilter was revealed where the check for absolute paths works only on POSIX filesystems.

You'll end up with paths like C:\basedir\C:\basedir\path\to\source instead of C:\basedir\path\to\source on Windows which then triggers Could not resolve config path to ….

This is just a fast emergency fix to get Psalm with passing a source dir running on Windows again.

I guess in the long run all incoming paths should be run through Path::normalize() to prevent other possible problems on Windows like

// Strip meaningless trailing recursive wildcard like "path/**/" or "path/**"
$prospective_directory_path = preg_replace('#(\/\*\*)+\/?$#', '/', $prospective_directory_path);
// Split by /**/, allow duplicated wildcards like "path/**/**/path" and any leading dir separator.
/** @var non-empty-list<non-empty-string> $path_parts */
$path_parts = preg_split('#(\/|\\\)(\*\*\/)+#', $prospective_directory_path);
$globs = self::recursiveGlob($path_parts, true);

where only the POSIX directory separator is considered. But would take quite some time and go into another PR.

@orklah
Copy link
Collaborator

orklah commented Nov 25, 2023

Hey! If I understood correctly, without thix fix, last release is crashing, right?

If it is, you should target 5.x branch instead so this can be released soon

@rarila
Copy link
Contributor Author

rarila commented Nov 25, 2023

@orklah Not crashing. It just stops with that error message. And that only when you supply a source path on the commandline. So using the path from psalm.xml file like

"C:/php.exe" ./vendor/bin/psalm

works, but specifiying it on the commandline like

"C:/php.exe" ./vendor/bin/psalm .\src

fails with

Problem parsing C:\foo\bar\psalm.xml:
Could not resolve config path to C:\foo\bar\C:\foo\bar\src

@rarila rarila changed the base branch from master to 5.x November 25, 2023 12:33
@rarila rarila changed the base branch from 5.x to master November 25, 2023 12:34
@rarila
Copy link
Contributor Author

rarila commented Nov 25, 2023

I guess that didn’t work :-)

@rarila
Copy link
Contributor Author

rarila commented Dec 1, 2023

@orklah Created a new one (#10441) closing this one

@rarila rarila closed this Dec 1, 2023
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 this pull request may close these issues.

None yet

2 participants