1

I have some env vars set-up in my .bashrc but when I'm running Vimspector, those variables are not set-up. I want to export the env var when staring Vimspector, but I haven't managed to figure out how.

There is a relevant (almost same) question here, but the answer is (probably) "expired", meaning that the links provided do not show that they were supposed to show, probably because the linked scripts have changed.

So, can anyone explain how to export an environment variable to Vimspector?

1 Answer 1

1

In the configuration section of the .vimspector.json that you use to define the debugging parameters of the VimSpector session there is a env section that you can use for that.

.vimspector.json

{
    "configurations": {
        "grr": {
            "default": false,
            "adapter": "debugpy",
            "breakpoints": {
                "exception": {
                    "raised": "N",
                    "uncaught": "Y"
                }
            },
            "configuration": {
                "type": "python",
                "request": "launch",
                "cwd": ".",
                "python": "python.exe",
                "stopOnEntry": true,
                "console": "externalTerminal",
                "justMyCode": true,
                "debugOptions": [],

                "program": "grr.py",
                "args": ["--debug"],
                "env": { "foo" : "bar" }
            }
        }
    }
}

grr.py

import os
print(os.environ["foo"])
2
  • 1
    Yes, it worked. Thank you!
    – Xxxo
    May 26, 2023 at 6:48
  • 1
    Thanks for the feedback :-) May 26, 2023 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.