microsoft / microsoft/vscode-cpptools

[Linux] Cannot Pass Environment Variable To Debug Session

Open
#3,189 5 comments 1 reaction 1 assignee View on GitHub

@WardenGnaw is already working on this.

Since Feb 20, 2019.

debugger
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Describe the bug

  • OS and Version: Linux
  • VS Code Version: 1.31.0
  • C/C++ Extension Version: 0.22.0
  • Other extensions you installed (and if the issue persists after disabling them): None
  • A clear and concise description of what the bug is.

I am attempting to debug an application that has to link to some custom DLL's.

The application needs the proper path set in the LD_LIBRARY_PATH environment variable.

When I launch the application in debug mode, I receive the following output.

&"warning: GDB: Failed to set controlling terminal: Operation not permitted\n"
/home/myuser/git/myworkspace/bin/debug/Linux/3.10.0/x86_64/myprogram: error while loading shared libraries: mySharedLib.so: cannot open shared object file: No such file or directory

The problem is simple, I just need to get the debug session to have the proper environment variable setup prior to launching my application.

In my launch.json file, I have external console set to FALSE. When I echo the LD_LIBRARY_PATH variable from this terminal it has the correct path. If I launch my program from here (non debug mode) it works fine.

I have tried the following settings in launch.json...

"args": ["${env:LD_LIBRARY_PATH}"],

"environment": [ { "name": "LD_LIBRARY_PATH", "value": "/mypath/to/lib/" } ]

"setupCommands": 
[{ 
     "description": "Additional libs",
     "text": "set env LD_LIBRARY_PATH =/mypath/to/lib/",
}],

"additionalSOLibSearchPath" : "/mypath/to/lib/"

But I continue to receive the same error where it cannot find my libs. This seems like something trivial and should work. Anyone else with this issue?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.