Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input command not working in launch.json - env sections is not invoking input command for python program #69027

Closed
neshdev opened this issue Feb 20, 2019 · 3 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues

Comments

@neshdev
Copy link

neshdev commented Feb 20, 2019

  • VSCode Version:
  • OS Version:

Steps to Reproduce:

I am trying to automate one of my workflows where I need to pass in a dynamic environment variable.

I created a tasks for generating the dynamic string

I tried to configure the launch.json to call the workbench.action.tasks.runTasks.

This command seems to be never invoked. I also have a problem passing default arguments to the workbench.action.tasks.runTasks command.

When I pass this input command in the args section. Its getting invoked but is not registering the string from the dynamic process.

launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File (Integrated Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "args": [
                "others",
            ],
            "env": {
                "test":"${inputs:test}"
            }
        },
    ],
    "inputs": [ 
        {
            "id" : "test",
            "type": "command",
            "command": "workbench.action.tasks.runTask",
            "args": ["echo"]
        },
    ]
}

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "${config:python.pythonPath} ${workspaceFolder}/runner.py"
        },
    ],
}

runner.py

print("hellopython")

temp.py

import os
import sys
print(os.environ["test"])
print("test")
print(sys.argv)

Does this issue occur when all extensions are disabled?: Yes

@vscodebot vscodebot bot added the tasks Task system issues label Feb 20, 2019
@alexr00 alexr00 added debug Debug viewlet, configurations, breakpoints, adapter issues and removed tasks Task system issues labels Feb 20, 2019
@alexr00 alexr00 assigned weinand and unassigned alexr00 Feb 20, 2019
@weinand
Copy link
Contributor

weinand commented Feb 20, 2019

@neshdev the syntax for input variables is ${input:variableID} (without a plural 's').
Please see https://code.visualstudio.com/docs/editor/variables-reference#_input-variables

In addition I don't think that "workbench.action.tasks.runTask" returns the output of a task as a string...

@weinand weinand closed this as completed Feb 20, 2019
@neshdev
Copy link
Author

neshdev commented Feb 20, 2019

@weinand - Is there any way to create a dynamic environment variable without creating a custom command/extension?

@weinand
Copy link
Contributor

weinand commented Feb 20, 2019

@neshdev no, this is not possible.

@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues
Projects
None yet
Development

No branches or pull requests

3 participants