vadimcn / codelldb

A native debugger extension for VSCode based on LLDB
https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb
MIT License
2.43k stars 237 forks source link

Environment variables are not getting loaded from launch.json #918

Closed akhildevelops closed 1 year ago

akhildevelops commented 1 year ago

OS: UBuntu 22.04 VSCode version: 1.77.3 CodeLLDB version: v1.9.0 Compiler: rustc 1.69.0 Debuggee: aarch64-linux-gnu

Environment variables aren't being read from launch.json. Below is my launch.json file that's autogenerated by codelldb. I've added the env variables later.

{
    // 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": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug unit tests in library 'youtube-transcript'",
            "cargo": {
                "args": [
                    "test",
                    "--no-run",
                    "--lib",
                    "--package=youtube-transcript"
                ],
                "filter": {
                    "name": "youtube-transcript",
                    "kind": "lib"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}",
            "env": {
                "DATABASE_URL": "postgres://postgres:postgres@db/summarizer",
                "OPENAI_API_KEY": "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"
            }
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug executable 'youtube-transcript'",
            "cargo": {
                "args": [
                    "build",
                    "--bin=youtube-transcript",
                    "--package=youtube-transcript"
                ],
                "filter": {
                    "name": "youtube-transcript",
                    "kind": "bin"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}",
            "env": {
                "DATABASE_URL": "postgres://postgres:postgres@db/summarizer",
                "OPENAI_API_KEY": "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"
            }
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug unit tests in executable 'youtube-transcript'",
            "cargo": {
                "args": [
                    "test",
                    "--no-run",
                    "--bin=youtube-transcript",
                    "--package=youtube-transcript"
                ],
                "filter": {
                    "name": "youtube-transcript",
                    "kind": "bin"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}",
            "env": {
                "DATABASE_URL": "postgres://postgres:postgres@db/summarizer",
                "OPENAI_API_KEY": "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"
            }
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug unit tests in library 'summarizer'",
            "cargo": {
                "args": [
                    "test",
                    "--no-run",
                    "--lib",
                    "--package=summarizer"
                ],
                "filter": {
                    "name": "summarizer",
                    "kind": "lib"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}",
            "env": {
                "DATABASE_URL": "postgres://postgres:postgres@db/summarizer",
                "OPENAI_API_KEY": "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"
            }
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug executable 'job'",
            "cargo": {
                "args": [
                    "build",
                    "--bin=job",
                    "--package=summarizer"
                ],
                "filter": {
                    "name": "job",
                    "kind": "bin"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}",
            "env": {
                "DATABASE_URL": "postgres://postgres:postgres@db/summarizer",
                "OPENAI_API_KEY": "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"
            }
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug unit tests in executable 'job'",
            "cargo": {
                "args": [
                    "test",
                    "--no-run",
                    "--bin=job",
                    "--package=summarizer"
                ],
                "filter": {
                    "name": "job",
                    "kind": "bin"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}",
            "env": {
                "DATABASE_URL": "postgres://postgres:postgres@db/summarizer",
                "OPENAI_API_KEY": "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"
            }
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug executable 'controller'",
            "cargo": {
                "args": [
                    "build",
                    "--bin=controller",
                    "--package=summarizer"
                ],
                "filter": {
                    "name": "controller",
                    "kind": "bin"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}",
            "env": {
                "DATABASE_URL": "postgres://postgres:postgres@db/summarizer",
                "OPENAI_API_KEY": "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"
            }
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug unit tests in executable 'controller'",
            "cargo": {
                "args": [
                    "test",
                    "--no-run",
                    "--bin=controller",
                    "--package=summarizer"
                ],
                "filter": {
                    "name": "controller",
                    "kind": "bin"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}",
            "env": {
                "DATABASE_URL": "postgres://postgres:postgres@db/summarizer",
                "OPENAI_API_KEY": "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"
            }
        }
    ]
}

OPENAI_API_KEY has been revoked need not worry!

Verbose log
 Initial debug configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'test summarize::test::summarize',
  program: '${workspaceFolder:summarizer}/target/debug/deps/summarizer-71093ef113e77d09',
  args: [
    'summarize::test::summarize',
    '--exact',
    '--nocapture',
    '--ignored'
  ],
  cwd: '${workspaceFolder:summarizer}',
  sourceMap: {},
  sourceLanguages: [ 'rust' ],
  env: {
    RUST_BACKTRACE: 'short',
    HOSTNAME: '30558fb17a82',
    PIPX_HOME: '/usr/local/py-utils',
    HOME: '/home/vscode',
    NVM_SYMLINK_CURRENT: 'true',
    PIPX_BIN_DIR: '/usr/local/py-utils/bin',
    NVM_DIR: '/usr/local/share/nvm',
    PYTHON_PATH: '/usr/local/python/current',
    RUSTUP_HOME: '/usr/local/rustup',
    PATH: '/vscode/vscode-server/bin/linux-x64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/bin/remote-cli:/usr/local/python/current/bin:/usr/local/py-utils/bin:/usr/local/share/nvm/versions/node/v18.16.0/bin:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/vscode/.local/bin',
    VSCODE_AGENT_FOLDER: '/home/vscode/.vscode-server',
    SHELL: '/bin/bash',
    PWD: '/vscode/vscode-server/bin/linux-x64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710',
    CARGO_HOME: '/usr/local/cargo',
    VSCODE_HANDLES_SIGPIPE: 'true',
    VSCODE_AMD_ENTRYPOINT: 'vs/workbench/api/node/extensionHostProcess',
    VSCODE_HANDLES_UNCAUGHT_ERRORS: 'true',
    VSCODE_NLS_CONFIG: '{"locale":"en","osLocale":"en","availableLanguages":{}}',
    NVM_INC: '/usr/local/share/nvm/versions/node/v18.16.0/include/node',
    REMOTE_CONTAINERS_IPC: '/tmp/vscode-remote-containers-ipc-8a14f37c-b2ac-4401-9483-a810d4962295.sock',
    LS_COLORS: '',
    LESSCLOSE: '/usr/bin/lesspipe %s %s',
    REMOTE_CONTAINERS_SOCKETS: '["/tmp/vscode-ssh-auth-8a14f37c-b2ac-4401-9483-a810d4962295.sock","/tmp/.X11-unix/X16","/home/vscode/.gnupg/S.gpg-agent"]',
    LESSOPEN: '| /usr/bin/lesspipe %s',
    USER: 'vscode',
    SHLVL: '1',
    NVM_CD_FLAGS: '',
    PROMPT_DIRTRIM: '4',
    NVM_BIN: '/usr/local/share/nvm/versions/node/v18.16.0/bin',
    _: '/usr/bin/cat',
    SSH_AUTH_SOCK: '/tmp/vscode-ssh-auth-8a14f37c-b2ac-4401-9483-a810d4962295.sock',
    DISPLAY: ':16',
    REMOTE_CONTAINERS_DISPLAY_SOCK: '/tmp/.X11-unix/X16',
    REMOTE_CONTAINERS: 'true',
    BROWSER: '/vscode/vscode-server/bin/linux-x64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/bin/helpers/browser.sh',
    VSCODE_CWD: '/vscode/vscode-server/bin/linux-x64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710',
    ELECTRON_RUN_AS_NODE: '1',
    VSCODE_IPC_HOOK_CLI: '/tmp/vscode-ipc-5587b502-02ea-4f0e-b1be-c8c104b0df19.sock',
    NODE_TLS_REJECT_UNAUTHORIZED: '0',
    VSCODE_L10N_BUNDLE_LOCATION: ''
  }
}
Resolved debug configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'test summarize::test::summarize',
  program: '${workspaceFolder:summarizer}/target/debug/deps/summarizer-71093ef113e77d09',
  args: [
    'summarize::test::summarize',
    '--exact',
    '--nocapture',
    '--ignored'
  ],
  cwd: '${workspaceFolder:summarizer}',
  sourceMap: {},
  sourceLanguages: [ 'rust' ],
  env: {
    RUST_BACKTRACE: 'short',
    HOSTNAME: '30558fb17a82',
    PIPX_HOME: '/usr/local/py-utils',
    HOME: '/home/vscode',
    NVM_SYMLINK_CURRENT: 'true',
    PIPX_BIN_DIR: '/usr/local/py-utils/bin',
    NVM_DIR: '/usr/local/share/nvm',
    PYTHON_PATH: '/usr/local/python/current',
    RUSTUP_HOME: '/usr/local/rustup',
    PATH: '/vscode/vscode-server/bin/linux-x64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/bin/remote-cli:/usr/local/python/current/bin:/usr/local/py-utils/bin:/usr/local/share/nvm/versions/node/v18.16.0/bin:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/vscode/.local/bin',
    VSCODE_AGENT_FOLDER: '/home/vscode/.vscode-server',
    SHELL: '/bin/bash',
    PWD: '/vscode/vscode-server/bin/linux-x64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710',
    CARGO_HOME: '/usr/local/cargo',
    VSCODE_HANDLES_SIGPIPE: 'true',
    VSCODE_AMD_ENTRYPOINT: 'vs/workbench/api/node/extensionHostProcess',
    VSCODE_HANDLES_UNCAUGHT_ERRORS: 'true',
    VSCODE_NLS_CONFIG: '{"locale":"en","osLocale":"en","availableLanguages":{}}',
    NVM_INC: '/usr/local/share/nvm/versions/node/v18.16.0/include/node',
    REMOTE_CONTAINERS_IPC: '/tmp/vscode-remote-containers-ipc-8a14f37c-b2ac-4401-9483-a810d4962295.sock',
    LS_COLORS: '',
    LESSCLOSE: '/usr/bin/lesspipe %s %s',
    REMOTE_CONTAINERS_SOCKETS: '["/tmp/vscode-ssh-auth-8a14f37c-b2ac-4401-9483-a810d4962295.sock","/tmp/.X11-unix/X16","/home/vscode/.gnupg/S.gpg-agent"]',
    LESSOPEN: '| /usr/bin/lesspipe %s',
    USER: 'vscode',
    SHLVL: '1',
    NVM_CD_FLAGS: '',
    PROMPT_DIRTRIM: '4',
    NVM_BIN: '/usr/local/share/nvm/versions/node/v18.16.0/bin',
    _: '/usr/bin/cat',
    SSH_AUTH_SOCK: '/tmp/vscode-ssh-auth-8a14f37c-b2ac-4401-9483-a810d4962295.sock',
    DISPLAY: ':16',
    REMOTE_CONTAINERS_DISPLAY_SOCK: '/tmp/.X11-unix/X16',
    REMOTE_CONTAINERS: 'true',
    BROWSER: '/vscode/vscode-server/bin/linux-x64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/bin/helpers/browser.sh',
    VSCODE_CWD: '/vscode/vscode-server/bin/linux-x64/704ed70d4fd1c6bd6342c436f1ede30d1cff4710',
    ELECTRON_RUN_AS_NODE: '1',
    VSCODE_IPC_HOOK_CLI: '/tmp/vscode-ipc-5587b502-02ea-4f0e-b1be-c8c104b0df19.sock',
    NODE_TLS_REJECT_UNAUTHORIZED: '0',
    VSCODE_L10N_BUNDLE_LOCATION: ''
  },
  relativePathBase: '/workspace/summarizer',
  _adapterSettings: {
    displayFormat: 'auto',
    showDisassembly: 'auto',
    dereferencePointers: true,
    suppressMissingSourceFiles: true,
    evaluationTimeout: 5,
    consoleMode: 'commands',
    sourceLanguages: null,
    terminalPromptClear: null,
    evaluateForHovers: true,
    commandCompletions: true,
    reproducer: false
  }
}
Debug adapter exit code=0 (0x0), signal=null.
vadimcn commented 1 year ago

The log you provided does not seem to match any of the launch configurations above (there's no configuration named "test summarize::test::summarize")

akhildevelops commented 1 year ago

I'm trying to debug by running it directly from the file by clicking on Debug. You can also see the path of modules summarize(mod) > test(mod) > summarize(function) ~ summarize::test::summarize

Screenshot from 2023-04-28 09-50-36

vadimcn commented 1 year ago

Those inlay links are generated by the rust-analyzer extension. When you click one of them, rust-analyzer generates a launch configuration internally, it does not load one from launch.json.

AFAIK, you can customize them via undocumented rust-analyzer.debug.engineSettings configuration setting, e.g. "rust-analyzer.debug.engineSettings": { "lldb": { "env": { "DATABASE_URL": "postgres://postgres:postgres@db/summarizer" } } }

Alternatively, you can use CodeLLDB's launch configuration defaults: "lldb.launch.env": { "DATABASE_URL": "postgres://postgres:postgres@db/summarizer" }

akhildevelops commented 1 year ago

Thanks for the info. I'll let you know if it worked.

akhildevelops commented 1 year ago

Thanks it worked.