-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Setting environment variable for adapter deletes them all instead. #1088
Comments
Tried local osEnv = {}
for line in io.popen("set"):lines() do
envName = line:match("^[^=]+")
osEnv[envName] = os.getenv(envName)
end
osEnv["PWNDBG_DISABLE_COLORS"] = "1"
dap.adapters.gdb = {
type = "executable",
command = "/usr/local/bin/gdb",
args = { "--interpreter", "dap" },
options = {
-- env = env,
env = osEnv,
},
} But that also cleared out everything. |
Found a workaround. After installing the posix library (
|
Workaround for mfussenegger/nvim-dap#1088
Encountering this same issue myself. Here's my workaround: Core config file: -- Configure the GDB adapter to allow loading local .gdbinit files
dap.adapters.gdb = {
type = "executable",
command = gdb_bin,
args = { "-i", "dap", "-iex", "set auto-load safe-path " .. vim.fn.getcwd() },
name = 'gdb'
} Project-specific config file (I use a Telescope picker that loads configurations from a -- Create a .gdbinit file that sets up the desired dnvironment variables
local function setup_gdbinit(custom_env, cwd)
local gdbinit = cwd or vim.fn.getcwd()
gdbinit = gdbinit .. '/.gdbinit'
local f = io.open(gdbinit, 'w')
if f ~= nil then
print('Opened file ' .. gdbinit .. ' for storing environment')
for key, value in pairs(custom_env) do
f:write('set env ' .. key .. '=\"' .. value .. '\"\n')
end
f:close()
else
error("Unable to open file '" .. gdbinit .. ".gdbinit' for editing")
end
end
return {
configurations = {
cpp = {
{
name = "My Test Executable with GDB + Custom env",
type = 'gdb',
request = 'launch',
cwd = '${workspaceFolder}',
stopOnEntry = false,
program = function()
-- Specify any desired environment variables
local custom_env = {
LD_LIBRARY_PATH = vim.env.LD_LIBRARY_PATH .. ':' .. vim.env.HOME .. '/.local/lib/',
PATH = vim.env.PATH .. ':' .. vim.env.HOME .. '/.local/bin/',
}
setup_gdbinit(custom_env)
-- The executable to debug
return 'build/bin/my_test'
end,
args = { '-a', '-b', '-o', 'foo.out' },
},
},
},
adapters = {}
} |
Faced the same problem. Worked around it by creating a wrapper script to simply set the env: #!/bin/sh
ELS_ELIXIR_OPTS="--sname sunrise --cookie secret" exec /Users/kirillrogovoy/.cache/nvim/elixir-tools.nvim/installs/elixir-lsp/elixir-ls/tags_v0.21.1/1.16.2-26/debug_adapter.sh |
Note that the To set the environment variables for your application you need to set an option in the launch configuration. Usually it is called See https://sourceware.org/gdb/current/onlinedocs/gdb.html/Debugger-Adapter-Protocol.html for the gdb docs. As for the removal of the adapters |
Debug adapter definition and debug configuration
I want to use gdb as my adapter. I have the pwndbg extension installed in gdb and I would like to use it. In my ~/.gdbinit I load it with the
~
shorthand for the home directory.However pwndbg prints ansi color sequences. To prevent that, you can configure an environment variable
PWNDBG_DISABLE_COLORS=1
.This is my adapter:
When not setting
env
inoptions
, gdb knows about all the environment variables. For example when I start a session with DAP and use REPL and type inshell echo ${HOME}
it prints the correct home directory.When I do set
env
inoptions
, pwndbg does not load at all, because it can not determine the correct path from~
, presumably because ${HOME} isn't set.Furthermore there is no documentation for what format env is supposed to be. I have tried
and
none of which seem to be setting that environment variable, that is
shell echo ${PWNDBG_DISABLE_COLORS}
in REPL does only print an empty line.The only thing that comes up when I type
shell env
in REPL is thisWhen not setting env in options I get dozens of environment variables.
My configuration
Debug adapter version
9d81c11
Steps to Reproduce
shell env
to send that command to gdbshell env
Expected Result
options.env
are also presentActual Result
options.env
are also not presentThe text was updated successfully, but these errors were encountered: