I am trying to debug a Go project in VSCode. I am able to debug it, but the application is running in the internal VSCode terminal. I need the application to run in an external console instead. For instance I want it to run in cmd.exe.
// .vscode/launch.json
{
// 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": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}
How can I make the debug session open a external console and run it there, rather than in the internal console of VSCode?
The developers for the Go VSCode extension are in the process of adding a launch property for this. See: https://github.com/golang/vscode-go/issues/124#issuecomment-1006122877
Related
How do I get rid of this annoying message every time there's an error in my code?
I found the solution to this problem:
The error message isn't actually caused by VScode, it's caused by the golang extension.
To disable it you have to go to the extension manager and click the little gear next to the installed extension and revert it to a previous version from the context menu. The version I reverted to is from about a year ago.
If you don't see the little gear icon you need to have the extension installed first.
Add your main.go file path to "program" attribute located in launch.json file.
{
// 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": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "E:/GoProjects/main.go",
"env": {},
"args": []
}
]
}
Check the Go Lang extension settings and turn off the "Build On Save" feature.
Im starting a python basic course and trying to run some initial code with Vscode. After watching the course videos i notice that im not seeing any output under the DEBUG CONSOLE. I do get an output under the TERMINAL section.
Also, i notice that the debug icon is different compared to the one in the videos (mine has a play arrow).
Am i missing something?
My python
C:\Users\andres>py --version
Python 3.8.3
my current launch.json is
{
// 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": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"cwd": "",
"console": "integratedTerminal"
}
]
}
thanks
thanks to #tHeSiD for the initial advise. for the winerror123, i deleted and recreated the json file
I'm trying to debug a go project with vscode, when I run debug with those settings:
{
// 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": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"envFile": "${workspaceFolder}/.env.local",
"args": [],
}
]
}
I get:
go: finding gitlab.com/company/project/.vscode latest
can't load package: package gitlab.com/company/project/.vscode: unknown import path "gitlab.com/company/project/.vscode": cannot find module providing package gitlab.com/company/project/.vscode
exit status 1
Process exiting with code: 1
What can I do to fix it ?
Sounds like you're editing a file within your .vscode folder (e.g. the launch.json file you quoted) when you try to debug. Debug is relative to the file you have open (as you can see by the ${fileDirname} in your config). So the easiest fix is to make sure you have open the Go file you want to debug when you try to debug.
If you only ever want to debug one binary in your project, you can override the program setting in launch.json to always point at that package.
I successfully installed the "actionssdk-smart-home-nodejs" and it works well if i launch it using the command "node index.js" within the folder "...actionssdk-smart-home-nodejs\smart-home-provider".
I need now to debug some part of the code, thus i tried to debug it using VS Code as editor and with the launch.json configured like
{
// 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": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}"
}
]
}
When i launch the debugger all seems to start fine, but when i use the Google Chrome browser to access the main page (http://localhost:3000/) i get as response only "Cannot GET /".
It seems like the static route defined in the file "smart-home-provider-cloud.js" app.use('/', express.static('./frontend'));
isn't matched.
So i can't figure out why launching without debugging all works fine and if a start the debugger express returns only "Cannot GET /".
I would be grateful for any help or clue for further investigation !
After long digging i found my issue. The config file for debugging was missing a config line.
{
// 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": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}",
"cwd":"${workspaceRoot}/smart-home-provi
}
]
}
I have debug configuration with preLaunchTask:
{
"type": "node",
"request": "launch",
"name": "index.js - Build then launch",
"program": "${workspaceRoot}/node/dist/index.js",
"cwd": "${workspaceRoot}/node",
"preLaunchTask": "build"
}
And when I start debugging, vscode opens OUTPUT tab instead of DEBUG CONSOLE:
Is there way to open DEBUG CONSOLE after starting debugging? I wanted to create extension with interact with DOM UI, but it turned out that extensions dont have access to DOM UI.
You can set "internalConsoleOptions": "openOnSessionStart" in your launch config to always show the console after starting a debug session.
"internalConsoleOptions": "openOnSessionStart" is not sufficient for python launch configs.
It also requires
"purpose": [
"debug-test"
],
launch.json
{
// 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": [
{
"name": "Python: Debug Tests",
"type": "python",
"request": "launch",
"program": "${file}",
"purpose": [ //
"debug-test"
],
"console": "integratedTerminal",
"justMyCode": false,
"internalConsoleOptions": "openOnSessionStart"
}
]
}
Is there way to open DEBUG CONSOLE after starting debugging?
As another alternative, VSCode 1.70 (July 2022) offers:
Changing Quick Access for Debug Consoles to Debug Sessions
Quick access menu for debug consoles just lists your debug consoles, but the view menu pretty much lists the same.
Before: Quick access for debug consoles:
VScode 1.70: The quick access should actually just list the debug sessions like the call stack does.
See PR 153727, released today in VSCode insiders.
This can be accessed with the command Select Debug Session
It would look like this (but as a regular quickpick, not a quick access anymore):
for this tree structure:
Or for something different like python (where there are no compact debug sessions):
tree structure:
The structure is pretty generic to support any type of debug session.