xdebug / vscode-php-debug

PHP Debug Adapter for Visual Studio Code šŸžā›”
MIT License
771 stars 176 forks source link

Cannot set env without running a program. #860

Closed mccaig closed 1 year ago

mccaig commented 1 year ago

Hi - I'm unable to launch the debugger - I receive the error that was mentioned in #788 (Cannot set env without running a program. Please remove env from [Listen for Xdebug] configuration.)

Note that I do not have an env variable set in my launch config - see below.

VS Code extension version: 1.29.0 Your launch.json:

{
    "configurations": [
    {
        "name": "Listen for Xdebug",
        "type": "php",
        "request": "launch",
        "port": 9003
    }
    ]
}

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

I edited the extension source to print the contents of args.env in the error message: throw new Error(Cannot set env without running a program.\nPlease remove envs: ${JSON.stringify(args.env)} from [${args.name || 'unknown'}] configuration.); You can see in the debugging output that env is an empty object - as the extension is testing for args.env !== undefined it is failing the test. I'm not sure if there was a change to the extension or even VSCode itself that is causing this variable to now be an empty object, or whether there is something weird about my IDE setup, but I don't see any obvious issues.

<- launchResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 2,
  command: 'launch',
  success: false,
  message:
   'Cannot set env without running a program.\nPlease remove env [{}] from [Listen for Xdebug] configuration.',
  body:
   { error:
      { id: 0,
        format:
         'Cannot set env without running a program.\nPlease remove env [{}] from [Listen for Xdebug] configuration.',
        showUser: true } } }

Perhaps this error might be better off as a warning?

zobo commented 1 year ago

Interesting. What is the vscode version?

Keanu73 commented 1 year ago

Hi, I am also experiencing this exact same issue. My VSCode version is 1.74.0, and the extension version is v1.29.0.

Keanu73 commented 1 year ago

I've made a fix for this, see my PR #872

zobo commented 1 year ago

Thanks. So weird that it never happens to me. Will look at the PR

zobo commented 1 year ago

Quite curious, I still cannot reproduce the issue. Do you have any other PHP related extensions installed?

Keanu73 commented 1 year ago

The only other PHP-related extension I have installed is PHP Intelephense, nothing else.

zobo commented 1 year ago

Could you try to disable all other extensions? I will release a version (hopefully today) with this fix, but I'd like to take this up with Microsoft if it turns out that vscode is doing this.

zobo commented 1 year ago

Alternatively, I think there is a Help>Report option where you can also generate a list of all active extensions.

Keanu73 commented 1 year ago

I've installed 1.29.1 and can confirm the bug is no longer present.

Extension Author (truncated) Version
vscode-openapi 42C 4.15.10
better-comments aar 3.0.2
copy-word ale 3.9.0
ng-template Ang 15.0.3
markdown-preview-github-styles bie 1.0.1
vscode-intelephense-client bme 1.8.2
language-hugo-vscode bud 1.3.1
npm-intellisense chr 1.4.3
vscode-markdownlint Dav 0.48.1
vscode-eslint dba 2.2.6
gitlens eam 13.1.1
vscode-html-css ecm 1.13.1
prettier-vscode esb 9.10.3
comment-anchors Exo 1.10.2
vscode-github-notifications-bell fab 2.3.1
vscode-firefox-debug fir 2.9.8
auto-rename-tag for 0.1.10
copilot Git 1.63.7601
vscode-pull-request-github Git 0.56.0
go gol 0.36.0
html-tag-wrapper hwe 0.2.3
svg joc 1.4.23
auto-comment-blocks kev 1.0.1
vscode-gutter-preview kis 0.30.0
file-downloader min 1.0.12
mindaro min 1.0.120221201
goto-next-previous-member mis 0.0.6
vscode-docker ms- 1.23.2
vscode-dotnet-runtime ms- 1.6.0
vscode-kubernetes-tools ms- 1.3.11
isort ms- 2022.8.0
python ms- 2022.20.1
vscode-pylance ms- 2022.12.20
remote-containers ms- 0.266.1
remote-ssh ms- 0.94.0
remote-ssh-edit ms- 0.84.0
remote-wsl ms- 0.72.0
remote-explorer ms- 0.0.3
sqltools mtx 0.26.0
angular-console nrw 17.27.1
vetur oct 0.36.1
vscode-openshift-connector red 1.0.0
vscode-redhat-account red 0.0.7
vscode-yaml red 1.10.1
keep-a-changelog RLN 1.2.2
vs-code-prettier-eslint rve 5.0.4
vscode-javascript-booster sbu 14.0.1
svelte-vscode sve 106.3.2
sass-indented syl 1.8.23
highlight-matching-tag vin 0.10.1
intellicode-api-usage-examples Vis 0.2.6
vscodeintellicode Vis 1.2.29
vscode-conventional-commits viv 1.24.4
vscode-wakatime Wak 22.1.0
vscode-import-cost wix 3.3.0
php-debug xde 1.29.1
json-helper zho 1.3.2
vscode-proto3 zxh 0.5.5
zobo commented 1 year ago

I went over the most extensions that would make sense but could not find any registerDebugConfigurationProvider that could cause this... I will close the issue. I would make sense to bisect the problem with the old version of the php-debug adapter, but honestly I can't spare the time...

Thanks for all the help!