Vscode-php-debug: Unable to resolve non-existent file. (Path mapping)

Created on 25 Mar 2021  ·  12Comments  ·  Source: xdebug/vscode-php-debug

PHP version: 7.2.24-0ubuntu0.18.04.7
Xdebug version: 2.6.0
PHP Debug: 1.14.11

A previously working setup.
A remote apache web server.
A windows vscode client.
Remote source files are mapped to a local drive (y:) via webdav.

"pathMappings": {
"/srv/www/servernamehere/" : "y:",
}

Breakpoints are hit correctly but VS code cannot now open the source file...... Seems to be prepending where it thinks the local copy of the file should live.......
Unable to open 'EnquiryController.php': Unable to read file 'c:UsersusernamehereAppDataLocalProgramsMicrosoft VS Codey:badgercontrollersEnquiryController.php' (Error: Unable to resolve non-existing file 'c:UsersusernamehereAppDataLocalProgramsMicrosoft VS Codey:badgercontrollersEnquiryController.php').

Notice how the drive letter (y:) appears after the local store folder. The path after y: will correctly find my file.

Here is an example of a log from a debug session.
<- launchResponse
Response {
seq: 0,
type: 'response',
request_seq: 2,
command: 'launch',
success: true
}
new connection 1
<- threadEvent
ThreadEvent {
seq: 0,
type: 'event',
event: 'thread',
body: { reason: 'started', threadId: 1 }
}
<- initializedEvent
InitializedEvent { seq: 0, type: 'event', event: 'initialized' }
-> setBreakpointsRequest
{
command: 'setBreakpoints',
arguments: {
source: {
name: 'BadgerImportController.php',
path: 'y:\badger\controllers\BadgerImportController.php'
},
lines: [],
breakpoints: [],
sourceModified: false
},
type: 'request',
seq: 3
}
-> setBreakpointsRequest
{
command: 'setBreakpoints',
arguments: {
source: {
name: 'EnquiryController.php',
path: 'y:\badger\controllers\EnquiryController.php'
},
lines: [ 69 ],
breakpoints: [ { line: 69 } ],
sourceModified: false
},
type: 'request',
seq: 4
}
-> setBreakpointsRequest
{
command: 'setBreakpoints',
arguments: {
source: {
name: 'PurchaseOrderController.php',
path: 'y:\badger\controllers\PurchaseOrderController.php'
},
lines: [],
breakpoints: [],
sourceModified: false
},
type: 'request',
seq: 5
}
-> setBreakpointsRequest
{
command: 'setBreakpoints',
arguments: {
source: {
name: 'StructureListItemController.php',
path: 'y:\badger\controllers\StructureListItemController.php'
},
lines: [ 461 ],
breakpoints: [ { line: 461 } ],
sourceModified: false
},
type: 'request',
seq: 6
}
<- setBreakpointsResponse
Response {
seq: 0,
type: 'response',
request_seq: 3,
command: 'setBreakpoints',
success: true,
body: { breakpoints: [] }
}
<- setBreakpointsResponse
Response {
seq: 0,
type: 'response',
request_seq: 5,
command: 'setBreakpoints',
success: true,
body: { breakpoints: [] }
}
<- setBreakpointsResponse
Response {
seq: 0,
type: 'response',
request_seq: 4,
command: 'setBreakpoints',
success: true,
body: { breakpoints: [ { verified: true, line: 69 } ] }
}
<- setBreakpointsResponse
Response {
seq: 0,
type: 'response',
request_seq: 6,
command: 'setBreakpoints',
success: true,
body: { breakpoints: [ { verified: true, line: 461 } ] }
}
-> setFunctionBreakpointsRequest
{
command: 'setFunctionBreakpoints',
arguments: { breakpoints: [] },
type: 'request',
seq: 7
}
<- setFunctionBreakpointsResponse
Response {
seq: 0,
type: 'response',
request_seq: 7,
command: 'setFunctionBreakpoints',
success: true,
body: { breakpoints: [] }
}
-> setExceptionBreakpointsRequest
{
command: 'setExceptionBreakpoints',
arguments: { filters: [] },
type: 'request',
seq: 8
}
<- setExceptionBreakpointsResponse
Response {
seq: 0,
type: 'response',
request_seq: 8,
command: 'setExceptionBreakpoints',
success: true
}
-> configurationDoneRequest
{ command: 'configurationDone', type: 'request', seq: 9 }
-> threadsRequest
{ command: 'threads', type: 'request', seq: 10 }
<- threadsResponse
Response {
seq: 0,
type: 'response',
request_seq: 10,
command: 'threads',
success: true,
body: { threads: [ Thread { id: 1, name: 'Request 1 (10:09:11 AM)' } ] }
}
<- configurationDoneResponse
Response {
seq: 0,
type: 'response',
request_seq: 9,
command: 'configurationDone',
success: true
}
<- stoppedEvent
StoppedEvent {
seq: 0,
type: 'event',
event: 'stopped',
body: { reason: 'breakpoint', threadId: 1, allThreadsStopped: false }
}
-> threadsRequest
{ command: 'threads', type: 'request', seq: 11 }
<- threadsResponse
Response {
seq: 0,
type: 'response',
request_seq: 11,
command: 'threads',
success: true,
body: { threads: [ Thread { id: 1, name: 'Request 1 (10:09:11 AM)' } ] }
}
-> threadsRequest
{ command: 'threads', type: 'request', seq: 12 }
<- threadsResponse
Response {
seq: 0,
type: 'response',
request_seq: 12,
command: 'threads',
success: true,
body: { threads: [ Thread { id: 1, name: 'Request 1 (10:09:11 AM)' } ] }
}
-> stackTraceRequest
{
command: 'stackTrace',
arguments: { threadId: 1, startFrame: 0, levels: 20 },
type: 'request',
seq: 13
}
<- stackTraceResponse
Response {
seq: 0,
type: 'response',
request_seq: 13,
command: 'stackTrace',
success: true,
body: {
stackFrames: [
{
id: 1,
name: 'app\controllers\EnquiryController->actionToJob',
source: {
name: 'EnquiryController.php',
path: 'C:\Users\mywindowsusername\AppData\Local\Programs\Microsoft VS Code/y:/badger/controllers/EnquiryController.php'
},
line: 69,
column: 1
},
{
id: 2,
name: 'call_user_func_array:{/srv/www/dev.charnvel.co.uk/badger/vendor/yiisoft/yii2/base/InlineAction.php:57}',
source: {
name: 'InlineAction.php',
path: 'C:\Users\mywindowsusername\AppData\Local\Programs\Microsoft VS Code/y:/badger/vendor/yiisoft/yii2/base/InlineAction.php'
},
line: 57,
column: 1
},
{
id: 3,
name: 'yii\base\InlineAction->runWithParams',
source: {
name: 'InlineAction.php',
path: 'C:\Users\mywindowsusername\AppData\Local\Programs\Microsoft VS Code/y:/badger/vendor/yiisoft/yii2/base/InlineAction.php'
},
line: 57,
column: 1
},
{
id: 4,
name: 'app\controllers\EnquiryController->runAction',
source: {
name: 'Controller.php',
path: 'C:\Users\mywindowsusername\AppData\Local\Programs\Microsoft VS Code/y:/badger/vendor/yiisoft/yii2/base/Controller.php'
},
line: 181,
column: 1
},
{
id: 5,
name: 'yii\web\Application->runAction',
source: {
name: 'Module.php',
path: 'C:\Users\pete.STOVESY-HP\AppData\Local\Programs\Microsoft VS Code/y:/badger/vendor/yiisoft/yii2/base/Module.php'
},
line: 534,
column: 1
},
{
id: 6,
name: 'yii\web\Application->handleRequest',
source: {
name: 'Application.php',
path: 'C:\Users\mywindowsusername\Local\Programs\Microsoft VS Code/y:/badger/vendor/yiisoft/yii2/web/Application.php'
},
line: 104,
column: 1
},
{
id: 7,
name: 'yii\web\Application->run',
source: {
name: 'Application.php',
path: 'C:\Users\pete.STOVESY-HP\AppData\Local\Programs\Microsoft VS Code/y:/badger/vendor/yiisoft/yii2/base/Application.php'
},
line: 392,
column: 1
},
{
id: 8,
name: '{main}',
source: {
name: 'index.php',
path: 'C:\Users\mywindowsusername\AppData\Local\Programs\Microsoft VS Code/y:/badger/web/index.php'
},
line: 12,
column: 1
}
]
}
}

Thank you for your time

Most helpful comment

Needed pathMapping to map a folder on WSL to Windows filesystem. The following used to work fine:

"pathMappings": {
    "/mnt/c": "c:/",
}

Had to change it to:

"pathMappings": {
    "/mnt/c": "c:\\",
}

@zobo, Shouldn't the issue be reopened? IMHO, changing pathMapping is a workaround for something that used to work fine but somehow got broken...

All 12 comments

I think I've found the problem. I need to alter my local drive mapping to be 'y:\\' (Two backslashes) then vs code can open the file correctly at the breakpoint line..

Hi. Has this worked before? Before you had only “y:” ? There were some changes related to this and I did not encounter configuration like this...

Had the same issue.
Can confirm that changing from "x:/..." to "x:\\.." in pathMappings fixed the issue for me.

VSCode 1.54.3, PHP Debug 1.14.11.

@zobo Yes, only x:/... have worked before, probably related to https://github.com/xdebug/vscode-php-debug/pull/525 ?

Needed pathMapping to map a folder on WSL to Windows filesystem. The following used to work fine:

"pathMappings": {
    "/mnt/c": "c:/",
}

Had to change it to:

"pathMappings": {
    "/mnt/c": "c:\\",
}

@zobo, Shouldn't the issue be reopened? IMHO, changing pathMapping is a workaround for something that used to work fine but somehow got broken...

I agree. I will add a workaround to also support c:/ and perhaps c:

Altho a more correct syntax is c:

I'm adding support for just the drive letter, like c:.

I implemented more edge cases #534.

Great, thanks!

Release should be out soon. Can you try it? Thanks.

Installed v1.14.12

The following pathMappings variants are all working fine:

"pathMappings": {
    "/mnt/c": "c:\\",
}
"pathMappings": {
    "/mnt/c": "c:/",
}



md5-3e02cb319c67b43aea7c7884416302e8



"pathMappings": {
    "/mnt/c": "c:",
}

Thanks for the quick fix!

Great!

However I was wondering, why don't you use ${workspaceRoot} or ${workspaceFolder} as suggested in the README? You probably have a workspace relative to these files, or is there a special case where absolute paths make more sense?

Since you are mentioning WSL, I had a different setup, where my files were in the WSL "partition" and VSC was running on windows:

      "pathMappings": {
        "/home/zobo/": "\\\\wsl$\\Ubuntu\\home\\zobo"
      },

Thanks!

Once WSL-v1 arrived, I replaced XAMPP on Windows by Apache on WSL:

  • VSCode on Windows
  • Apache on WSL-v1
  • webroot on Windows (for easy files access, e.g. explorer, editing, or FreeFileSync to backup)

It's said that WSL-v2 improved performance at lot (inside WSL), but communication between Windows and Linux deteriorated. I reverted back to WSL-v1. Maybe my config is not the most ideal config (anymore), but it suits my needs... I'm open for suggestions though.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

camrongodbout picture camrongodbout  ·  5Comments

jplew picture jplew  ·  12Comments

jmo161 picture jmo161  ·  4Comments

NerijusNoreika picture NerijusNoreika  ·  12Comments

evs-xsarus picture evs-xsarus  ·  5Comments