Comments (26)
The correct format for this environment object is:
"environment":[{"name":"name_of_var", "value":"value_of_var"}, {"name":"var2", "value": "var2_value"}]
from vscode-cpptools.
anyone who's looking for a node example, this worked for me.
{
// 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
// APPNAME=rap2 PORT=31000 DEBUG=*,-engine*,-socket.io*,-snapdragon*,-send,-express*,-nodemon*,-superagent,-AmpMetrics,-body-parser* nodemon server.js
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"cwd": "${workspaceFolder}/server",
"program": "${workspaceFolder}/server/server.js",
"env":
{
"APPNAME": "rap2",
"PORT": "31000"
}
}
]
}
it's not very well documented here:
https://code.visualstudio.com/docs/editor/debugging#_launch-configurations
from vscode-cpptools.
What OS are you using?
We could be clearer in the examples. The key/value pairs should go inside the array. So, something like this:
[{"name":"value", "name2":"value2"}]
Also, it looks like setting environment variables isn't working on mac.
from vscode-cpptools.
"env":
{
"APPNAME": "rap2",
"PORT": "31000"
}
For my Java App on Mac also works like this configuration.
from vscode-cpptools.
The correct format for this environment object is:
"environment":[{"name":"name_of_var", "value":"value_of_var"}, {"name":"var2", "value": "var2_value"}]
This doesnt seem to work on mac. Property environment is not allowed.
from vscode-cpptools.
they should really document this, I find my way back here every time I try messing around with the debugger before usually giving up anyway.
from vscode-cpptools.
Could you please make it more explicit in the documentation that the expected format is to pass the name of the env variable and its value as values of the respective "name" and "value" keys in the json object?
The "natural" way to describe the env var to me is {"my_env_var_name": "my_value"}
, not {"name": "my_env_var_name", "value": "my_value"}
and using the first causes a very cryptic error message instead of something like "name
key not found in environment variable specification" or something of the sort.
from vscode-cpptools.
How can I reference the env var from "env" in my "args"?
from vscode-cpptools.
Hey,
I have the same error on OS X (running 10.11.6), running Code Version 1.4.0. Even though I'm passing environemnt variables to the debugger (in launch.json) with
"environment": [
{
"name": "DYLD_FRAMEWORK_PATH",
"value": "/my/path/here"
},
{
"name": "A_VARIABLE",
"value": "/other/stuff/here"
}
]
it seems that the executable is run without those variable set beforehand.
Edit: My bad, it seems that in OS X lldb is started without any environment variables set, due to system protection. However, is there any way, using Visual Studio Code, to pass specific commands to the debugger, once it has been started?
For instance, on the command line I would do:
$ lldb my_executable
(lldb) env DYLD_LIBRARY_PATH=/my/foo/bar
(lldb) r
How would I achieve this, using Visual Studio Code?
Thanks in advance
from vscode-cpptools.
@dcsan If you are using node
and continually running into this problem, I would suggest you file an issue in the VS Code repository as this one is for the C/C++ extension. We don't have any control over the node extension or its documentation.
from vscode-cpptools.
@GPhilo Like this microsoft/vscode-docs#4492 and #7417 ?
from vscode-cpptools.
@bartekpacia also want to know if we can actually do this. The usage of ${env:VARNAME}
as suggested in docs for args
doesn't seem to work. I want to be able to use ENV vars from ENV file, so that I can commit this to my repo and don't expose any sensitive information.
from vscode-cpptools.
@rafaeldsousa Apparently this is not possible. You can take a look at this issue.
from vscode-cpptools.
Ubuntu 16.04 beta 2. Thanks for clarifying. That sorted it! Works great!
from vscode-cpptools.
I reopened this issue because I was mistaken when I said that sorted it.
When specifying anything in the 'environment' tag vscode reports the following error:
error while processing request 'launch' (exception: Required property 'Value' not found in JSON. Path 'environment[0]', line 15, position 6.)
My debug launch script looks like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"miDebuggerPath": "/usr/bin/gdb",
"targetArchitecture": "x64",
"program": "/home/ben/git/server/core/build/debug/src/libcored/vca-cored-cxx-unit-tests",
"args": [],
"stopAtEntry": false,
"cwd": "/home/ben/git/tool-chain/rootfs/host/ubuntu/16.04/opt/company/lib64",
"environment": [{"name":"value"}],
},
{
"name": "C++ Attach (GDB)",
"type": "cppdbg",
"request": "launch",
"launchOptionType": "Local",
"miDebuggerPath": "/usr/bin/gdb",
"targetArchitecture": "x64",
"program": "enter program name, for example ${workspaceRoot}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"processId": "enter program's process ID"
}
]
}
If I remove the contents of environment
it loads the process fine (I just can't debug it as I need to pass LD_LIBRARY_PATH for some shared lib dependencies).
from vscode-cpptools.
Closing as it looks like @krworks comment solves the problem
from vscode-cpptools.
This issue still seems to exist. I am unable to set LD_LIBRARY_PATH environment variable in Ubuntu 16.04.
from vscode-cpptools.
@nebjamin99 You can pass additional commands in the launch.json
using "setupCommands"
. You can find more info at: https://github.com/Microsoft/vscode-cpptools/blob/master/launch.md
@dhiraj113 I noticed you opened another issue, #616. Please update that issue with the information requested.
from vscode-cpptools.
@lohiarahul Can you confirm that your type field in your launch.json
is showing "type": "cppdbg"
? According to the package.json
schema, there doesn't seem to be a restriction for Mac and I can't duplicate the error.
from vscode-cpptools.
't seem to be a restriction for Mac and I can't duplicate the error.
The debugging type is different. Its node. I guess it might have a different format.
from vscode-cpptools.
@lohiarahul Yea, This extension provides the type
s of cppdbg
and cppvsdbg
. You probably need to find the issues page for the node
extension.
from vscode-cpptools.
also useful for node folks
https://techbrij.com/visual-studio-code-tasks-debugging
from vscode-cpptools.
windows ? $env:path+=/xx/xx;/xxxx/xxx
set path=%path%;/xx/xx;/xxx/xxx
"environment":[{βnameβ:"path","value":"${path};/xx/xx;/xxx/xxx"}] ?
from vscode-cpptools.
@sean-mcmanus That's much clearer now, thank you for the quick update!
from vscode-cpptools.
This works for python as well.
anyone who's looking for a node example, this worked for me.
{ // 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 // APPNAME=rap2 PORT=31000 DEBUG=*,-engine*,-socket.io*,-snapdragon*,-send,-express*,-nodemon*,-superagent,-AmpMetrics,-body-parser* nodemon server.js "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Launch Program", "cwd": "${workspaceFolder}/server", "program": "${workspaceFolder}/server/server.js", "env": { "APPNAME": "rap2", "PORT": "31000" } } ] }it's not very well documented here:
https://code.visualstudio.com/docs/editor/debugging#_launch-configurations
from vscode-cpptools.
@bartekpacia I believe I was able to use a combination of envFile
+ some non sensitive info on env
.
"envFile": "${workspaceFolder}/.env",
"env": {
.
.
.
}
from vscode-cpptools.
Related Issues (20)
- launch.json HOT 1
- cpptools IntelliSense Updating and Parsing Wrokspace speed is much slower than previous versions HOT 2
- Intellisense fails to find system headers in 1.20.5 (possible cmake integration issue?) HOT 12
- Make hover menu show documentation from source file instead of header file if it's written in the Doxygen format HOT 1
- Intellisense fails to distinguish same name files in different directories HOT 2
- Goto Definition takes a couple of seconds each time to complete the jump HOT 3
- Detection of clang-format version fails in SSH remote session when clang-format is a symlink
- Cannot deduce class template arguments HOT 1
- Display entire definition line when pointing at variable HOT 2
- C++ attributes are not proposed in auto-completion
- Search freezes with cpptools enabled HOT 3
- [opensuse] language server crashes HOT 4
- Error: Attempting to use languageClient before initialized HOT 1
- The 'auto' keyword is not colored HOT 1
- Inconsistent naming of command options for "IntelliSense" configurations
- includePath does not support ${fileDirname} HOT 3
- Code analysis fails to get configured for non-open files the 1st time it's run
- When a function is referenced via a macro definition, the referencing function cannot find it
- Support additional visualizers directories
- Not All Doxygen Comment Blocks Supported
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-cpptools.