Can someone give me the default launch.json in Visual Studio Code? - visual-studio-code

Ok, so I was writing some simple python code and when I ran it, It always said attached to chrome.
So to fix this problem,I went into the launch.json and accidentally removed all the code.
Can you please give me the DEFAULT launch.json please?

Python:
{
// 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}",
"console": "integratedTerminal"
}
]
}

Related

Cannot open localhost:8080

I have tried EVERYTHING. I have no idea why I keep getting this error every time I try to run/debug a website on visual studio code. Please see attached image for the error.
Here is my 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": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
Error Image

How to fix it googleMap flutter web

This URL refresh every time when run and debug
If you're referring to the port, you can set it using flutter run --web-port <your_port_number>
If you are using VSCode, you can create launch.json file in .vscode folder.
The contents of the launch.json can be like this:
{
// 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": "Run (Debug)",
"program": "lib/main.dart",
"request": "launch",
"type": "dart",
"args": [
"--web-port",
"8686",
]
},
]
}
In you Google Cloud Console, you can just pass the referrer as http://localhost:8686

How to debug Quasar Electron App with VS Code

I'm having a hard time configuring vs code to debug an electron app.
What I'm trying to do is to build the project with the -d option to generate the debug (https://quasar.dev/quasar-cli/cli-documentation/commands-list#build)
And then using the following vscode launch config:
{
// 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",
"sourceMaps": true,
"cwd": "${workspaceRoot}",
"name": "Electron Main",
// "preLaunchTask": "npm: quasar build -m electron",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"args" : ["."],
"outputCapture": "std",
"program": "${workspaceFolder}/dist/electron/UnPackaged/electron-main.js"
}
]
}
This doesn't work. The program starts but every breakpoint gets "unverified" and it is not hit. Probably because, as far as I know, quasar uses babel to transpile files or something like that. I think I'm missing some configs. Any ideas how can I debug it?

How to disable "just my code" setting in VSCode debugger?

When starting my project in the debugger (C# .NET Core), it states it's debugging "just my code".
I want to also debug the libraries, and can't see a setting to disable this anywhere in VSCode.
Is it possible to disable?
Just adding "justMyCode": false to launch.json doesn't work. You need to add a separate config in launch.json like below. FYI each {} represents a config.
"configurations": [
{
.... # existing config
},
{
"name": "Debug Unit Test",
"type": "python",
"request": "test",
"justMyCode": false,
}
]
As pointed out in here
For this you need to change the launch.json file. Inside the launch.json file you have to set "justMyCode" to false.
As described here. (I was pointed to that link through this post on the Visual Studio Code site.)
VSCode 1.60 was complaining about the "request": "test" method suggested by others.
But I did have to add a new section below my existing configuration to get "justMyCode": false to work.
Here is what 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
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"blah",
"whatever"
]
},
{
"name": "Python: Debug Unit Tests",
"type": "python",
"request": "launch",
"purpose": ["debug-test"],
"console": "integratedTerminal",
"justMyCode": false,
}
]
}
The purpose addition appears to be important.
I found the correct approach documented here: https://code.visualstudio.com/docs/python/testing#_debug-tests
If you're specifically debugging Python unit tests, adding "justMyCode": "false" to your normal config won't do, you'll need to add another in your launch.json with "request": "test":
{
"name": "Debug Unit Test",
"type": "python",
"request": "test",
"justMyCode": false,
},
Source: Github Microsoft/vscode-python Issue #7131
I added the "justMyCode": false" setting to launch.json and it still didn't stop at breakpoints in external library code. What was even more confusing: It did work for once and then suddenly it didn't anymore.
Then I found out: If you are in the "Run and Debug (SHIFT+CMD+D)"-tab and select your configuration there and click the green triangle / "Start Debugging (F5)" it works! However, if I click "Debug Python File" in the upper right corner it does not stop in external library code!
As of 2022, VS Code no longer seems to have an “Open launch.json” shortcut in its command palette, but it still prompts you to edit launch.json to set "justMyCode" to false. The solution that worked for me was:
create a directory called .vscode in the root of the repository
create a file called launch.json in the .vscode directory
put this text in the file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Unit Test",
"type": "python",
"request": "test",
"justMyCode": false,
}
]
}
There will be an error message under the word "test" saying that "test" is not a valid value, and that "attach" would be valid. However, it doesn't work for me if I change "test" to "attach". If the "version" field isn't there, it doesn't work and VS Code raises an error saying launch.json is missing a field.
In the documenentation of Visual Studio Code they have a section "Skipping uninteresting code".
VS Code Node.js debugging has a feature to avoid source code that you don't want to step through (AKA 'Just My Code').
This feature can be enabled with the skipFiles attribute in your launch configuration. skipFiles is an array of glob patterns for script paths to skip.
In your launch.json file you have to add (or any other file you want to skip):
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"${workspaceFolder}/lib/**/*.js"
]
If you are using vscode on mac, press shift+command+p, search for Open'launch.json', open an editor you want, and add the following JSON object to the file :
{
"name": "Python: Debug Unit Tests",
"type": "python",
"request": "launch",
"purpose": ["debug-test"],
"console": "integratedTerminal",
"justMyCode": false,
}
Reopen your vscode and now you can put breakpoints on lines that are imported or you have not written.
I added in the configurations part as below:
"configurations": [
{
"name": "Python: Curent File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false,
}
],
It took me a while to understand where the file needs to be and what exactly needs to be inside it. So here's what I've got for others to enjoy:
The launch.json file is not in the root of your project, it needs to be in .vscode/launch.json instead. And for new VSCode versions, once you open that file from that location, you can get warnings on issues in the file, and also automatically add sections to it.
For me, at the end the contents of the file is this:
{
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
},
]
}
This allows me to enter (F11) other libs when I run a custom code in debug mode for Python.
None of the fiddling with launch.json worked for me.
I had to tick the "Allow setting breakpoints in any files" box in the Settings:
Recently, even I faced this issue where the VS code was not taking the latest launch.json (one with 'justMycode: false'). So, I had to perform the following steps.
Instead of running a debugger from the Top right group menu of the editor, I ran it from below status bar as shown in the below picture
Click here to see the screenshot of the status bar
Once clicked on this option a pop-up appears asking which launch.json you want to run your debugging with, as shown below.
Click here to see the screenshot of the pop-up menu
You can click on launch.json here to edit the configuration file and now the debugger opens with the selected launch.json and 'justtMycode:false' setting will be applied.
I merged the previous answers and the below setting works for me (vscode 1.75.0).
"launch": {
"configurations": [
{
"name": "Debug Unit Test",
"type": "python",
"request": "launch",
"purpose": "debug-test",
"justMyCode": false,
"program": "${file}",
}
],
},

Debugging Perl with Visual Studio Code

I have just started with Perl today and installed ActivePerl 5.24.1 and everything went well. I was able to create my test program testPerl.pl with simple a print command and run it through console.
Now I wanted to use Visual Studio Code to run my Perl script, and so I opened the project folder [testPerl.pl location] with Visual Studio Code and tried to debug the code. I have installed the Perl-Debug extension in the editor and when I hit F5, Visual Studio Code asked me to Select Environment and I chose the Perl Debug option, which actually created the launch.json file for me with the below contents.
{
"version": "0.0.2",
"configurations": [
{
"type": "perl",
"request": "launch",
"exec": "perl",
"name": "Perl-Debug",
"root": "${workspaceRoot}/",
"program": "${workspaceRoot}/${command.AskForProgramName}",
"inc": [],
"stopOnEntry": true
}
]
}
I have kept default values as it, and when I hit F5 again, it asked me for a command with default value test.pl. It is because of ${command.AskForProgramName}, I assume. I entered my file name testPerl.pl in the command, but then nothing happens. It starts and ends without any print in console.
How can I actually configure this launch.json file or is there another way I need to do this?
I tried with a newer version of the plugin: Perl Debug version 0.2.0.
This works out of the box. The proposed configuration looks as follows:
{
// 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": "perl",
"request": "launch",
"name": "Perl-Debug local",
"program": "${workspaceFolder}/${relativeFile}",
"exec": "perl",
"execArgs": [],
"root": "${workspaceRoot}/",
"inc": [],
"args": [],
"env": {},
"stopOnEntry": true
},
{
"type": "perl",
"request": "launch",
"name": "Perl-Debug remote",
"program": "${workspaceFolder}/${relativeFile}",
"root": "${workspaceRoot}/",
"stopOnEntry": true,
"port": 5000
}
]
}
Do note I tried this out on a Mac, with Visual Studio Code version 1.24.0.
I ran Visual Studio Code on a Mac and changed
"program": "${workspaceRoot}/${command.AskForProgramName}"
to
"program": "${file}"
to get the current file to debug.