Skip to content

"env": [] does not work with "Launch currently open script"  #420

Closed

Description

@OldStarchy

Adding "env": [] to the "Launch currently open script" config breaks the launch. The default launch config (as below, but without env works fine and the code is executed.

The "env" property does not cause any problems with the default "Listen for XDebug" configuration.

<?php

$test = 'test';

echo 'this is a '. $test;

Outputs "this is a test", so there's no question that php is installed and available.

On this system (docker php-7.4) there is only one php.ini for both apache and cli, so I'm trying to include

"env": {
	"XDEBUG_CONFIG": "remote_autostart=on",
},

But simply having the env property causes the launch to fail, regardless of is content.

PHP version: 7.4.9
XDebug version: 2.9.6
Adapter version: 1.13.0

Your launch.json:

{
	"version": "0.2.0",
	"configurations": [
		{
			"name": "Launch currently open script",
			"type": "php",
			"request": "launch",
			"program": "${file}",
			"cwd": "${fileDirname}",
			"port": 9000,
			"env": {}
		}
	]
}

XDebug php.ini config:

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
xdebug.remote_enable=true

XDebug logfile (from setting xdebug.remote_log in php.ini):

n/a xdebug.remote_log => no value => no value

Adapter logfile (from setting "log": true in launch.json): I don't know where the log is but this is the Debug Console output

<- launchResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 2,
  command: 'launch',
  success: true
}

<- 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:264:19)\n' +
      '    at onErrorNT (internal/child_process.js:456:16)\n' +
      '    at processTicksAndRejections (internal/process/task_queues.js:81:21) {\n' +
      "  errno: 'ENOENT',\n" +
      "  code: 'ENOENT',\n" +
      "  syscall: 'spawn php',\n" +
      "  path: 'php',\n" +
      "  spawnargs: [ '/app/test.php' ]\n" +
      '}\n'
  }
}

Error: spawn php ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:81:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn php',
  path: 'php',
  spawnargs: [ '/app/test.php' ]
}

Also worth noting that this is running through a "remote container"

Name: Remote - Containers
Id: ms-vscode-remote.remote-containers
Description: Open any folder inside (or mounted into) a container and take advantage of Visual Studio Code's full feature set.
Version: 0.138.0
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers

Activity

  1. zobo commented on Apr 24, 2022

    @zobo
    Contributor

    This was fixed in #706 . The extension did not merge the existing env with the provided one, but rather did an override.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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