Skip to content

Error: spawn php ENOENT on Macos #705

Closed
@kaysonwu

Description

@kaysonwu

PHP version: v7.2.34
Xdebug version: v3.0.4
VS Code extension version: v1.22.0

Your launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 0,
            "log": true,
            "runtimeArgs": [
                "-dxdebug.start_with_request=yes"
            ],
            "env": {
                "XDEBUG_MODE": "debug,develop",
                "XDEBUG_CONFIG": "client_port=${port}"
            }
        },
    ]
}

Xdebug php.ini config:

zend_extension="xdebug.so"

[xdebug]
xdebug.mode = "coverage"

Xdebug logfile (from setting xdebug.log in php.ini):
VS Code extension logfile (from setting "log": true in launch.json):

<- launchResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 2,
  command: 'launch',
  success: true
}
<- initializedEvent
InitializedEvent { seq: 0, type: 'event', event: 'initialized' }
<- outputEvent
OutputEvent {
  seq: 0,
  type: 'event',
  event: 'output',
  body: {
    category: 'console',
    output: 'Error: spawn php ENOENT\n' +
      '    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)\n' +
      '    at onErrorNT (internal/child_process.js:465:16)\n' +
      '    at processTicksAndRejections (internal/process/task_queues.js:80:21) {\n' +
      '  errno: -2,\n' +
      "  code: 'ENOENT',\n" +
      "  syscall: 'spawn php',\n" +
      "  path: 'php',\n" +
      '  spawnargs: [\n' +
      "    '-dxdebug.start_with_request=yes',\n" +
      "    '/private/var/www/jinmao/jinmao-backend-store/a.php'\n" +
      '  ]\n' +
      '}\n'
  }
}
Error: spawn php ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn php',
  path: 'php',
  spawnargs: [
    '-dxdebug.start_with_request=yes',
    '/private/var/www/jinmao/jinmao-backend-store/a.php'
  ]
}
-> setBreakpointsRequest
{
  command: 'setBreakpoints',
  arguments: {
    source: {
      name: 'a.php',
      path: '/private/var/www/jinmao/jinmao-backend-store/a.php'
    },
    lines: [ 4 ],
    breakpoints: [ { line: 4 } ],
    sourceModified: false
  },
  type: 'request',
  seq: 3
}
<- setBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 3,
  command: 'setBreakpoints',
  success: true,
  body: {
    breakpoints: [
      {
        verified: true,
        line: 4,
        source: {
          name: 'a.php',
          path: '/private/var/www/jinmao/jinmao-backend-store/a.php'
        },
        id: 1
      }
    ]
  }
}
-> setFunctionBreakpointsRequest
{
  command: 'setFunctionBreakpoints',
  arguments: { breakpoints: [] },
  type: 'request',
  seq: 4
}
<- setFunctionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 4,
  command: 'setFunctionBreakpoints',
  success: true,
  body: { breakpoints: [] }
}
-> setExceptionBreakpointsRequest
{
  command: 'setExceptionBreakpoints',
  arguments: { filters: [] },
  type: 'request',
  seq: 5
}
<- setExceptionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 5,
  command: 'setExceptionBreakpoints',
  success: true,
  body: { breakpoints: [] }
}
-> configurationDoneRequest
{ command: 'configurationDone', type: 'request', seq: 6 }
<- configurationDoneResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 6,
  command: 'configurationDone',
  success: true
}
-> threadsRequest
{ command: 'threads', type: 'request', seq: 7 }
<- threadsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 7,
  command: 'threads',
  success: true,
  body: { threads: [] }
}

Code snippet to reproduce:

<?php

$a = 1;

echo $a;

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions