View Issue Details

IDProjectCategoryView StatusLast Update
0001964XdebugStep Debuggingpublic2025-11-25 14:22
ReporterZobo Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status feedbackResolutionopen 
PlatformWindowsOSWindowsOS Version10
Product Version3.0.4 
Target Version3.6dev 
Summary0001964: WSL UNC paths don't have needed prefix
Description

I just ran into an issue where Xdebug is presenting a UNC path in such way I cannot map it back to original.

I executed a script from an UNC path \WSL$\UBUNTU\home\zobo\php\test1.php

Looking at phpinfo() output, php is OK with it:

...
$_SERVER['PHP_SELF'] => \\wsl$\Ubuntu\home\zobo\php\test1.php
$_SERVER['SCRIPT_NAME'] => \\wsl$\Ubuntu\home\zobo\php\test1.php
$_SERVER['SCRIPT_FILENAME'] => \\wsl$\Ubuntu\home\zobo\php\test1.php
$_SERVER['PATH_TRANSLATED'] => \\wsl$\Ubuntu\home\zobo\php\test1.php
...
$_SERVER['argv'] => Array
(
    [0] => \\wsl$\Ubuntu\home\zobo\php\test1.php
)
...

However Xdebug presents the files as:

[50452] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file://WSL%24/UBUNTU/home/zobo/php/test1.php" language="PHP" xdebug:language_version="8.0.4RC1" protocol_version="1.0" appid="50452"><engine version="3.0.4"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2021 by Derick Rethans]]></copyright></init>

Also true for stack:

[50452] [Step Debug] <- stack_get -i 4
[50452] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="4"><stack where="{main}" level="0" type="file" filename="file://WSL%24/UBUNTU/home/zobo/php/test1.php" lineno="3"></stack></response> 

I am not sure if this is true in case of network mapped UNC paths, but I have a strong suspicion it is. See: https://github.com/xdebug/vscode-php-debug/issues/546

In case it's a normal "windows path" the url becomes file:///C:/.... So in theory I could infer that it should be prefixed with \\, but I'd rather not...

Was this already encountered?

TagsNo tags attached.
Operating System
PHP Version8.0.0-8.0.4

Relationships

has duplicate 0001939 closedderick Breakpoints unresolved and skipped when web site root is a UNC path in internet information service (8.5) 

Activities

Zobo

2021-04-12 20:09

reporter   ~0005825

I read this https://en.wikipedia.org/wiki/File_URI_scheme and am considering this os actually correct...

Zobo

2021-04-14 08:36

reporter   ~0005826

Upon further debugging I did find other strange things:

First the case is strange:
PHP sees: $_SERVER['PHP_SELF'] => \wsl$\Ubuntu\home\zobo\php\test1.php
Xdebug sees: file://WSL%24/UBUNTU/home/zobo/php/test1.php

If I try to set a breakpoint:
[50420] [Step Debug] <- breakpoint_set -i 2 -t line -f file://WSL%24/UBUNTU/home/zobo/php/test1.php -n 4
[50420] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="504200001"></response>

[50420] [Step Debug] <- breakpoint_list -i 3
[50420] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="3"><breakpoint type="line" filename="file://C:/local_disk/zobo/Projects/vscode-php-debug/vscode-php-debug/testproject/WSL$/UBUNTU/home/zobo/php/test1.php" lineno="4" state="enabled" hit_count="0" hit_value="0" id="504200001"></breakpoint></response>

It's treated as relative path... This should not be valid in URL context.

So in case of windows UNCs I think the syntax should really be encoded as file:////host/path....

I guess this is a far more complex issue than I hoped for... However not being able to set a breakpoint for a UNC path is IMO a bug.

derick

2021-04-16 16:18

administrator   ~0005851

Last edited: 2021-04-16 16:18

Xdebug handles UNC paths, and prefixes them with file:// : https://github.com/xdebug/xdebug/blob/master/src/lib/usefulstuff.c#L310-L313

This is an implementation of a specification on the MSFT website: https://docs.microsoft.com/en-us/archive/blogs/ie/file-uris-in-windows

Which says:


Proper Syntax

For the UNC Windows file path
\laptop\My Documents\FileSchemeURIs.doc

The corresponding valid file URI in Windows is the following:
file://laptop/My%20Documents/FileSchemeURIs.doc

For the local Windows file path
C:\Documents and Settings\davris\FileSchemeURIs.doc

The corresponding valid file URI in Windows is:
file:///C:/Documents%20and%20Settings/davris/FileSchemeURIs.doc

And this is exactly what Xdebug does. So I also don't think there is a bug here.

derick

2021-08-07 10:10

administrator   ~0005968

I still don't know what to do here... either break "Proper Syntax" that Windows and Wikipedia explain, or ignore it and suggest people mount their drive with a drive letter.

AnrDaemon

2021-08-27 17:38

reporter   ~0005995

While "WSL$" has correct casing, I wonder, what was the correct casing for "Ubuntu"?

As for PHP's output, it uses what was passed to it.
So, if you start script with "\WSL$\…" instead of "\wsl$\…", PHP will output that.

dwade3

2022-07-19 12:15

reporter   ~0006348

Hi derick,

the problem is that a unc path is requested and at a single point in log file this address is interpreted as local windows file path.

requested: file://139.138.58.141/phpinfo.php
response: file:///139.138.58.141/phpinfo.php (which is incorrect)

Svante

2024-08-12 11:32

reporter   ~0007045

Hi all.
I have what looks like the same problem that is described here.
I am using wsl2 and windows 11.
From the point of view of Phpstorm, I get the error message:

Cannot find file ‘/home/svante/projects/myproject/bin/cli.php’ locally

In the xdebug log I get entries like:

[11181] [Step Debug] <- breakpoint_set -i 15 -t line -f file:////wsl.localhost/Ubuntu/home/svante/projects/myproject/bin/cli.php -n 10
[11181] [Step Debug] WARN: Breakpoint file name does not exist: //wsl.localhost/Ubuntu/home/svante/projects/myproject/bin/cli.php (No such file or directory).
[11181] [Step Debug] DEBUG: Setting 'has_line_breakpoints on {main} (/home/svante/projects/myproject/bin/cli.php:0)
[11181] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="15" id="111810001" resolved="unresolved"></response>

I tried mapping wsl to w:\, which makes little difference.

[1543] [Step Debug] <- breakpoint_set -i 15 -t line -f file://W:/home/svante/projects/myproject/bin/cli.php -n 15
[1543] [Step Debug] WARN: Breakpoint file name does not exist: W:/home/svante/projects/myproject/bin/cli.php (No such file or directory).
[1543] [Step Debug] DEBUG: Setting 'has_line_breakpoints on {main} (/home/svante/projects/myproject/bin/cli.php:0)
[1543] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="15" id="15430001" resolved="unresolved"></response>

I see that you have a "target version" to solve this problem that is set to 3.4dev, but I guess this just is default for "next version", or something like that.
I am currently running Xdebug v3.4.0alpha2-dev.
I can also see that you derick, found that it is not xdebug handling things wrong, so perhaps I am in the wrong forum.
However, I was curious to ask if there is any known development around this problem?
I will post back to this entry from the JetBrains forum, in this youtrack post:
https://youtrack.jetbrains.com/issue/WI-58406
Let me know if there is anything I can do to help debug, or otherwise.

Svante

2024-08-12 13:58

reporter   ~0007046

An extra note. In the above I focused on cli. In fpm it actually works, mapped to w:\ or not, until I press F9 (resume program).
Then I get:
Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
With xdebug not enabled, the page loads fine. That last part might be some xdebug setting, looking into that now.