Skip to content

Support environment variable for port number in launch.json debug configuration #962

Closed

Description

Multiple users on the same development server may wish to use a different port number for debugging java applications.
For that, it would be useful if the port number will not be limited to be a number, since the ${env:VAR} notion is (probably) a string. Currently, trying to use environment variable for the port number gives an error.

Environment
  • Operating System: CentOS Linux 8
  • JDK version: JavaSE-1.8 (java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64)
  • Visual Studio Code version: 1.53.2
  • Java extension version: 0.13.0
  • Java Debugger extension version: 0.31.0
Steps To Reproduce
  1. Add a launch.json attach configuration with environment variable for port number:
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Attach to Remote Program",
            "request": "attach",
            "hostName": "localhost",
            "port": "${env:DEBUG_PORT_NUMBER}",
        }
    ]
}
  1. Switch to the debug tab (CTRL+SHIFT+D) and click the start debugging play button

image

Current Result

Cannot start the debugger when using environment variable for port number

Expected Result

Should be able to start the debugger when using an environment variable for port number

Additional Informations

Jinbo Wang (@testforstephen)
v-wenkecheng

Activity

  1. elad-eyal commented on Mar 11, 2021

    @elad-eyal

    I think the problem is that the env var is treated as string but the port expects a number only

  2. tomereli commented on Mar 11, 2021

    @tomereli
    Author

    I think the problem is that the env var is treated as string but the port expects a number only

    Yes, this is a feature request to fix that - I asked about it on the vscode-java-debug gitter and Jinbo Wang (@testforstephen) asked me to open this feature request.

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions