-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Error on Windows #810
Comments
@AnirudhSingal91 sorry to hear. Unfortunately this library is not tested under Windows. I have no Windows machine myself so it was never practical to add support for it and no one really stepped up to help out there. A few issues have occasionally been fixed for it, so maybe it works, maybe not. I unfortunately cannot help out much there without any sort of reproducer. You might also want to checkout #303 which talks to length about the WP use case. |
Probably noob question, but If I use something like WSL2, will it work? |
no idea, I've never used it myself so can't say |
Just wanted to mention I ran into the same thing (on Windows 10, PHP 8.1). Upgraded to 0.18 to be able to fix a different issue, and I get the same kind of error (v0.15/PHP 7.4 and 0.17/PHP 8.0, which I used up until a minute ago, did not suffer from this). |
If I comment out line 95 in Symfony's filesystem/Filesystem.php, I (obviously) get a new error:
Look like the "to" path is wrong. Instead of |
I know it's super hacky, but if I essentially undo #806 by replacing ConsoleScoper.php and functions.php with the version from just before, it again works. |
I am encountering the same issue with https://github.com/humbug/php-scoper/releases/tag/0.18.3. I have traced it back to this PR: https://github.com/humbug/php-scoper/pull/806/files In my case, there are two different separators used for Normalizing the paths can help address this issue. I have tested the code on v0.17.5, and it works. However, I want to utilize v0.18.3 due to Symfony patches and other enhancements. |
Looks like Symfony's Can we not also run |
// Fix path.
$outputDir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $outputDir);
$commonDirectoryPath = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $commonDirectoryPath); Using this just before: https://github.com/humbug/php-scoper/blob/0.18.3/src/Console/ConsoleScoper.php#L182 fixes it for me. Additionally $commonDirectoryPath = Path::getLongestCommonBasePath(
...array_map(
static fn (string $path) => Path::getDirectory($path),
array_keys($filesWithContent),
),
...array_map(
static fn (string $path) => Path::getDirectory($path),
array_keys($excludedFilesWithContents),
),
); produces path I would rather prefer Also when I use // Example of collecting files to include in the scoped build but to not scope
// leveraging the isolated finder.
$excludedFiles = array_map(
static fn( SplFileInfo $fileInfo ) => $fileInfo->getPathName(),
iterator_to_array(
Finder::create()->files()->in( __DIR__ ),
false
)
); it instead of excluding the files, include these files (which are infact config files |
This is a really frustrating issue. I think the problem can be solved by normalizing all paths to use consistent slashes. One possible solution would be to check the path of the original vendor directory, check what kind of slashes it contains, and normalize all paths to use that kind of slash. |
AFAIK all the user defined paths are actually normalized. At least that is one part of the process that was done at some point to bring compatibility with Windows. As mentioned elsewhere though, I don't have a Windows machine so trying to keep track is not worth it, as if the CI fails I still have no way to really debug this locally. I think the root of the issue in this case though is switching from Webmozart's PathUtil to the Symfony Path. And ideally this could be fixed by patching it (this could be tested by here first to validate the issue). |
I am willing to test any changes you make, but there is no need to switch libraries. Original code: $mapFiles = static fn (array $inputFileTuple) => [
$inputFileTuple[0],
$inputFileTuple[1],
$outputDir.str_replace($commonDirectoryPath, '', $inputFileTuple[0]),
]; New code with normalized input files: $mapFiles = static fn (array $inputFileTuple) => [
Path::canonicalize($inputFileTuple[0]),
$inputFileTuple[1],
$outputDir.str_replace($commonDirectoryPath, '', Path::canonicalize($inputFileTuple[0])),
]; I'm not familiar with your codebase and I might be wrong, but as far as I can tell you normalize only the path and the output-dir. This includes |
Bug report
| Question | Answer
| Getting error while running the php-scoper add-prefix command
I came across php-scoper because I was experiencing dependency hell in my custom wordpress plugin. I just want to prefix one package(guzzlehttp). I found implementing php-scoper to be extremely hard and i'm probably doing it all wrong.
I get the following error while running the php-scoper add-prefix command
In Filesystem.php line 95:
Failed to create "C:/Users/singa/source/repos/WIP/woocommerce-xero-integration/woocommerce-xero-integration/woocommerce-xero-integration/dependencies/vendorC:\Users\singa\source\repos\WIP\woocommerce-xero-integration\woocommerce-xero-integration\woocommerce-xero-integration\vendor\guzzlehttp\guzzle\src": mkdir(): No such file or directory
| ---------------
| PHP-Scoper version | x.y.z 0.18
| PHP version | x.y.z 8.1
| Platform with version | e.g. Ubuntu/Windows/MacOS Windows
| Github Repo | -
scoper.inc.php
Output
The text was updated successfully, but these errors were encountered: