4

I've created task (tasks.json) for setting environment variable as below

export SOME_IP_VARIABLE=1.2.3.4

my application needs IP parameters so I added args in launch.json as below

...
"configuration":[
    ...
    "args":[
        "${env:SOME_IP_VARIABLE}
    ]
...

When I print argv value in the application, this prints nothing.

Did I miss something?

Alan Birtles
  • 32,622
  • 4
  • 31
  • 60
JayMuzie
  • 341
  • 1
  • 4
  • 16
  • Maybe this can help - https://stackoverflow.com/questions/29971572/how-do-i-add-environment-variables-to-launch-json-in-vscode – Harshit May 11 '20 at 06:19
  • 1
    Environment variables defined in shell scripts only exist for the shell script and any child processes so `SOME_IP_VARIABLE` doesn't exist after your task finishes executing. What are you trying to achieve? – Alan Birtles May 11 '20 at 06:56
  • @AlanBirtles I thought If I export environment variables, the variables can be shared with launch.json because launch.json calls task. I'm not familiar with linux system so I thought environment variable works just like windows system variable. thanks for your help. – JayMuzie May 11 '20 at 07:24
  • try to add **env** in launch.json directly – alexzshl May 12 '20 at 01:28
  • Take a look here https://stackoverflow.com/a/70748562/3223785 . – Eduardo Lucio Jan 18 '22 at 00:47

0 Answers0