Skip to content

Set env to extensionHost type in launch.json did not work #22150

Closed

Description

@leozdgao
  • VSCode Version: 1.10.1
  • OS Version: MacOS 10.12.3

Steps to Reproduce:

I'm working on a vscode extension development, and my launch.json here:

{
    "version": "0.1.0",
    "configurations": [
        {
            "name": "Launch Extension",
            "type": "extensionHost",
            "request": "launch",
            "runtimeExecutable": "${execPath}",
            "args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
            "stopOnEntry": false,
            "env": {
                "NODE_ENV": "development"
            }
        }
    ]
}

And env seems not to be set. I try to follow the prompt here:

"node2" is no longer supported, use "node" instead and set the "protocol" attribute to "inspector".

And modify my launch.json like this:

{
    "version": "0.1.0",
    "configurations": [
        {
            "name": "Launch Extension",
            "type": "node",
            "protocol": "inspector",
            "request": "launch",
            "runtimeExecutable": "${execPath}",
            "args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
            "stopOnEntry": false,
            "env": {
                "NODE_ENV": "development"
            }
        }
    ]
}

But got the connection timeout error here:

Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:28486).

Activity

  1. roblourens commented on Mar 7, 2017

    @roblourens
    Member

    That error message about 'node2' is wrong. I think it was fixed by #21596, but the problem is that 'extensionHost' doesn't support the attribute 'env'. Right Isidor Nikolic (@isidorn)?

  2. added
    debug
    on Mar 7, 2017
  3. ramya-rao-a commented on Mar 7, 2017

    @ramya-rao-a
    Contributor

    leozdgao (@leozdgao) Can you debug your extension using your initial launch.json configuration but without the env attribute?

  4. leozdgao commented on Mar 8, 2017

    @leozdgao
    Author

    Ramya Rao (@ramya-rao-a) I'm not sure. I just want to find an approach to judge the debugging environment, so I could load some development configuration. Is there anyway to do so without set env? 😕

  5. ramya-rao-a commented on Mar 8, 2017

    @ramya-rao-a
    Contributor

    I was currently trying to narrow down if debugging the extension works at all to begin with. Hence the question about trying without the env attribute.

  6. leozdgao commented on Mar 8, 2017

    @leozdgao
    Author

    Ramya Rao (@ramya-rao-a) Oh, debugging the extension works well. But the env configuration did not work.

  7. isidorn commented on Mar 8, 2017

    @isidorn

    roblourens not sure if extensionHost supports env, forwarding to Andre Weinand (@weinand)

  8. weinand commented on Mar 8, 2017

    @weinand
    Contributor

    The extensionHost debugger doesn't yet support setting the env (but it is planned for this milestone).

    But the nasty problem is that the error squiggly is completely misleading:

    2017-03-08_12-46-29

    It flags the type "extensionHost" as wrong and not the illegal use of "env".

    If the key value pair "foo":"bar" is removed from the env structure the error is flagged correctly:

    2017-03-08_12-52-03

    Martin Aeschlimann (@aeschli) Is there a way to let your validator know that the "type" attribute is special (and has higher priority)?

  9. added
    feature-request
    on Mar 8, 2017
  10. leozdgao commented on Mar 8, 2017

    @leozdgao
    Author

    Andre Weinand (@weinand) BTW, is there anyway to know the code is running in the debug environment besides set env?

  11. weinand commented on Mar 8, 2017

    @weinand
    Contributor

    Currently this feature is blocked by #22233

  12. aeschli commented on Mar 8, 2017

    @aeschli
    Contributor

    Andre Weinand (@weinand) It's difficult for the JSON validator to know which variant ('any of') is the right one.
    Please file an issue against JSON.

  13. weinand commented on Mar 9, 2017

    @weinand
    Contributor

    leozdgao (@leozdgao) with the latest Insiders build you can now access env variables in the extension that are defined in the launch config.

  14. added
    verification-needed
    on Mar 27, 2017
  15. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

debugfeature-requestverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions