Skip to content

[lldb-dap] Running in server mode does not propagate environment variables #159498

@mateusz-plociennik

Description

@mateusz-plociennik

Description

When debugging a program that uses std::getenv() with lldb-dap running in server mode,
the call to std::getenv("HOME") unexpectedly returns nullptr.


Environment

  • VS Code version: 1.103.2
  • Extension version: 0.2.16
  • lldb-dap version: 21.1.1
  • OS version: macOS 15.6.1 (24G90)

settings.json

{
    "lldb-dap.serverMode": true,
    "lldb-dap.executable-path": "/opt/homebrew/opt/llvm/bin/lldb-dap"
}

Minimal Reproducible Example

main.cpp

#include <cstdlib>
#include <filesystem>
#include <iostream>
#include <stdexcept>

std::filesystem::path getUserHomeFolder()
{
    if (const char* home = std::getenv("HOME"))
        return home;

    throw std::runtime_error("Could not determine user home directory");
}

int main()
{
    std::cout << getUserHomeFolder() << "\n";
    return 0;
}

Steps to Reproduce

  1. Enable lldb-dap.serverMode in settings.json.
  2. Debug the provided main.cpp with lldb-dap.
  3. Observe the result of std::getenv("HOME").

Expected Behavior

std::getenv("HOME") should return the user’s home directory path.


Actual Behavior

std::getenv("HOME") returns nullptr instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions