Unable to use xdebug in Linux Mint / devilbox / Visual Studio Code

I have some days trying to use xdebug in Visual Studio Code, but I’m unable.

I followed steps indicated in this URL: 3.2.1.4. Docker on Linux: Xdebug for Visual Studio Code — Devilbox 1.0 documentation

But I receive this error:

Error: spawn /usr/local/etc/php ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
at onErrorNT (node:internal/child_process:477:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -2,
  code: 'ENOENT',
  syscall: 'spawn /usr/local/etc/php',
  path: '/usr/local/etc/php',
  spawnargs: [
    '-dxdebug.start_with_request=yes',
    '/home/daniel/devilbox/data/www/pruebas/htdocs/index.php'
  ]
}

My VSC’s settings.json is the following:

{
"workbench.colorTheme": "Default Dark+",
"diffEditor.ignoreTrimWhitespace": false,
"php.debug.executablePath": "/usr/local/etc/php",
"files.autoSave": "afterDelay",
"tabnine.experimentalAutoImports": true,
"todohighlight.isEnable": false,
"php.validate.executablePath": ""
}

And my VSC’s launch.json is the following:

{
"version": "0.2.0",
"configurations": [
  {
     "name": "Listen for Xdebug",
     "cwd": "${workspaceRoot}",
     "type": "php",
     "request": "launch",
     "port": 9000, // I also tried with port 9000
     "pathMappings": {
        "/shared/httpd/pruebas/htdocs": "${workspaceFolder}/htdocs"
     },
     "log": true,
     "xdebugSettings": {
        "max_children": 128,
        "max_data": 512,
        "max_depth": 3
     }
  }
]
}

If I assign “/php” in “php.debug.executablePath”, then I receive next error:

Error: spawn /php EACCES
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
at onErrorNT (node:internal/child_process:477:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -13,
  code: 'EACCES',
  syscall: 'spawn /php',
  path: '/php',
  spawnargs: [
    '-dxdebug.start_with_request=yes',
    '/home/daniel/devilbox/data/www/pruebas/htdocs/index.php'
  ]
}

Like mentioned in this thread: EACCES: permission denied in VS Code MAC

I tried using:

chown -R daniel /php

But it does not work.

Grateful in advance for any help.

I have the same environment: Linux Mint, devilbox, xdebug and phpstorm/vscode and all working fine.
First: with Xdebug v.3 you have to use port 9003 instead 9000.

In VSCode launch.json:

  "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "pathMappings": {
                "/shared/httpd/pruebas": "${workspaceFolder}",
                "/shared/httpd/pruebas/htdocs": "${workspaceFolder}/htdocs",
            },
            "log": true
        },

In devilbox/cfg/php-ini-8.0/xdebug.ini:

;
; PHP.ini configuration
;
[PHP]

; Xdebug https://3.xdebug.org/docs/upgrade_guide
xdebug.mode               = debug
xdebug.start_with_request = yes
xdebug.client_port        = 9003
xdebug.client_host        = docker.for.lin.host.internal
xdebug.idekey             = VSCODE
xdebug.log                = /var/log/php/xdebug.log
1 Like

Hi @massiws

Thank you very much for your reply.

In my launch.json the port set is 9003 ( sorry for my mistake ).

Could you share your VSC settings.json?

Thank you very much for your valuable help.

Hi @garciasanchezdani,
below is my settings.json: it’s shared between Linux and Windows machines, so some settings are for Windows only.

{
    "emmet.triggerExpansionOnTab": true,
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.snippetSuggestions": "top",
    "explorer.confirmDelete": false,
    "workbench.colorCustomizations": {
        "activityBarBadge.background": "#2979FF",
        "activityBar.activeBackground": "#2979FF50",
        "list.activeSelectionForeground": "#2979FF",
        "list.inactiveSelectionForeground": "#2979FF",
        "list.highlightForeground": "#2979FF",
        "scrollbarSlider.activeBackground": "#2979FF50",
        "editorSuggestWidget.highlightForeground": "#2979FF",
        "textLink.foreground": "#2979FF",
        "progressBar.background": "#2979FF",
        "pickerGroup.foreground": "#2979FF",
        "tab.activeBorder": "#2979FF"
    },
    "emmet.includeLanguages": {
        "blade": "html"
    },
    "workbench.editor.showTabs": true,
    "explorer.openEditors.visible": 0,
    "editor.tabCompletion": "on",
    "workbench.startupEditor": "none",
    "php-cs-fixer.onsave": false,
    "window.openFilesInNewWindow": "on",
    "files.trimTrailingWhitespace": true,
    "extensions.ignoreRecommendations": false,
    "workbench.iconTheme": "material-icon-theme",
    "files.insertFinalNewline": true,
    "editor.scrollBeyondLastLine": false,
    "editor.trimAutoWhitespace": true,
    "editor.useTabStops": true,
    "editor.wordSeparators": "./\\()\\'-:,.;<\">~!@#%^&*|+=[]{}`~?",
    "editor.wordWrap": "on",
    "php-cs-fixer.lastDownload": 1662041605770,
    "auto-close-tag.SublimeText3Mode": true,
    "auto-close-tag.fullMode": true,
    "workbench.colorTheme": "Monokai Dark Soda Extended",
    "terminal.external.windowsExec": "cmder.exe",
    "editor.formatOnPaste": true,
    "[php]": {
        "editor.defaultFormatter": "bmewburn.vscode-intelephense-client"
    },
    "editor.largeFileOptimizations": false,
    "diffEditor.renderSideBySide": true,
    "editor.formatOnSaveMode": "modifications",
    "blade.format.enable": true,
    "[javascript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "[html]": {
        "editor.defaultFormatter": "vscode.html-language-features"
    },
    "yaml.schemas": {
        "file:///home/max/.vscode/extensions/atlassian.atlascode-2.10.12/resources/schemas/pipelines-schema.json": "bitbucket-pipelines.yml"
    },
    "editor.linkedEditing": true,
    "[json]": {
        "editor.defaultFormatter": "vscode.json-language-features"
    },
    "sftp.debug": true,
    "eslint.validate": [
        "javascript",
        "vue"
    ],
    "vetur.format.defaultFormatter.js": "prettier-eslint",
    "php-cs-fixer.executablePath": "${extensionPath}/php-cs-fixer.phar",
    "intelephense.files.associations": [
        "*.php",
        "*.phtml"
    ],
    "files.associations": {
        "*.module": "php"
    },
    "redhat.telemetry.enabled": true,
    "atlascode.jira.enabled": false,
    "material-icon-theme.folders.color": "#26a69a",
    "editor.fontSize": 16,
    "aws.logLevel": "debug",
    "yaml.customTags": [
        "!And",
        "!And sequence",
        "!If",
        "!If sequence",
        "!Not",
        "!Not sequence",
        "!Equals",
        "!Equals sequence",
        "!Or",
        "!Or sequence",
        "!FindInMap",
        "!FindInMap sequence",
        "!Base64",
        "!Join",
        "!Join sequence",
        "!Cidr",
        "!Ref",
        "!Sub",
        "!Sub sequence",
        "!GetAtt",
        "!GetAZs",
        "!ImportValue",
        "!ImportValue sequence",
        "!Select",
        "!Select sequence",
        "!Split",
        "!Split sequence"
    ],
    "terminal.integrated.defaultProfile.windows": "Git Bash",
    "terminal.integrated.profiles.windows": {
        "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe (migrated)": {
            "path": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
            "args": []
        }
    },
    "json.schemas": [],
    "diffEditor.ignoreTrimWhitespace": false,
    "git.autofetch": true,
    "projectManager.groupList": true,
    "projectManager.git.baseFolders": [
        "~/www"
    ],
    "security.workspace.trust.banner": "never",
    "atlascode.bitbucket.enabled": true,
    "aws.profile": "profile:default",
    "[blade]": {
        "editor.defaultFormatter": "shufo.vscode-blade-formatter"
    },
    "editor.suggest.showMethods": true,
    "editor.suggest.preview": true,
    "editor.acceptSuggestionOnEnter": "on",
    "aws.resources.enabledResources": [
        "AWS::S3::Bucket"
    ]
}

PS: which version of PHP is enabled in your container? I had problems with v.7.3, but switching to 7.4 works fine, almost without code refactoring.