I want to debug my Kotlin Spring boot application after moving from Java to Kotlin, but the launch.json of Kotlin has different configurations than Java's, for example we're using profiles to switch between the environments, and when I add "args": "-Dspring.profiles.active=dev" I'm getting Property args is not allowed. And in the debug console I'm getting
Internal error: java.lang.IllegalArgumentException: io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.42.Final:compile is not a properly formed Maven/Gradle artifact
[ERROR] java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.42.Final:compile is not a properly formed Maven/Gradle artifact
Here's my current Kotlin configs:
{
"version": "0.2.0",
"configurations": [
{
"type": "kotlin",
"request": "launch",
"name": "Kotlin Launch",
"projectRoot": "${workspaceFolder}",
"mainClass": "path.to.my.Application",
"args": "-Dspring.profiles.active=dev" // <--- showing error
}
]
}
For comparison, here's my java launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug (Launch) - Current File",
"request": "launch",
"mainClass": "${file}",
"args": "-Dspring-boot.run.profiles=dev"
},
{
"type": "java",
"name": "Debug (Launch)",
"request": "launch",
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"mainClass": "path.to.my.application",
"projectName": "spring",
"args": "--spring.profiles.active=dev",
"vmArgs": "-Dspring.profiles.active=dev"
}
]
}
What are the correct configs for Kotlin if I want to use profiles or args?
Related
I am attempting to get VS Code to launch an asp.net mvc core website utilizing a specific port number. I would like to set this via the VS Code launch.json, and NOT utilize the appsettings.json files. I have referenced multiple websites that list a number of options, but none work other than using the appsettings.json file. Setting "ASPNETCORE_URLS":"https://localhost:5050" does not work, nor do setting the arguments.
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/WAPI.Foundation/bin/Debug/netcoreapp3.1/WAPI.Foundation.dll",
"args": [ ],
"cwd": "${workspaceFolder}/WAPI.Foundation",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)",
"uriFormat": "index.html"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS":"https://localhost:5050"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
] }
I have referenced among others: VSCode launch ASP.NET Core app on a specific port
The trick was to set the launch.json configuration command line "args" "--urls" property like so. I did not modify the "env" variables as described in other posts.
"configurations": [
{
"name": ".NET Core Launch (web)",
...
"args": ["--urls","https://localhost:44304;http://localhost:6000"],
"env": {
"ASPNETCORE_ENVIRONMENT": "Local"
},
...
}
]
I found the answer here: Launch specific URL in an ASP.NET Core app in VSCode when running the app.
Google searches on 'vs code setting port number' did not return this specific result, but search for 'vs code set url to run on' brought it right up.
I'm trying to debug a Vue website I'm writing in VSCode and Chrome.
When I put a breakpoint in the data() { return {...} } function it stops on it, but if I try to put it in a method in a Vue file or a JS service, once I launch Chrome through the debug config the breakpoints become unbound. Does anyone have any ideas about how to keep the breakpoints bound?
This is my config file:
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome",
"request": "launch",
"type": "pwa-chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/client/meet-for-lunch/src",
"sourceMapPathOverrides": {
"webpack:///src/*": "${webRoot}/*"
}
},
{
"type": "node",
"request": "launch",
"name": "Debug server",
"runtimeExecutable": "nodemon",
"program": "${workspaceFolder}/server/bin/www",
"restart": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": [
"<node_internals>/**"
]
}
]
}
I'm including the debug config for the server because in works.
Here is an example of a method I'm trying to debug (from the Vue file), I put a break point at this.error = null . The method runs normally so I expect it to stop at the breakpoint :
methods: {
async login() {
try {
this.error = null;
const response = await AuthenticationService.login({
email: this.email,
password: this.password
})
this.$store.dispatch('setToken', response.data.token)
this.$store.dispatch('setUser', response.data.user)
}
catch (err) {
console.log(`An error has occured: ${JSON.stringify(err.response)}`)
this.error = err.response.data.error
}
}
}
I'm also trying to debug my service:
login(credentials) {
return Api().post('/login', credentials)
}
The Api object just creates the Axios request
Thanks,
Ben
https://www.codegrepper.com/code-examples/javascript/vuejs+vscode+unbound+breakpoint
After a whole day of searching this solved my problem
{
"version": "0.2.0",
"configurations": [
{
"name": "WSL Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src",
"sourceMapPathOverrides": {
"webpack:///./src/*": "${webRoot}/*",
"webpack:///src/*": "${webRoot}/*"
}
}
]
}
When I had Unbound Breakpoints in VSCode I ended up needing to start the process with the --inspect or --debug-brk=5858 flag. Beyond that, launch.json gave me lots of trouble, and these resources helped
https://code.visualstudio.com/docs/nodejs/nodejs-debugging
https://code.visualstudio.com/docs/nodejs/debugging-recipes
https://github.com/microsoft/vscode-recipes/tree/master/nodemon
https://code.visualstudio.com/docs/typescript/typescript-debugging
launch.json examples:
{
"type": "node",
"request": "attach",
"name": "Node: Nodemon",
"processId": "${command:PickProcess}",
"restart": true,
"protocol": "inspector",
},
{
"name": "Launch tests via NPM",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script", "testDebug"
],
"port": 5858
}
package.json
"scripts": {
"start": "NODE_PATH=./src DEBUG=express:* NODE_ENV=dev nodemon -w src --ext ts --exec node --inspect -r tsconfig-paths/register -r ts-node/register src/index.ts",
"testDebug": "NODE_ENV=test ts-mocha --debug-brk=5858 --paths -p tsconfig.json",
}
},
Well, it's not really an answer but I've restarted my Node server a couple of (more) times and now it stops at the breakpiont. I hope that the problem doesn't return. Now he doesn't show the value of the variables for some reason but I guess that's another problem.
Thanks for the help :)
Ben
I had the same issue in my vueJS project. Something to try before making any changes to files etc which solved it for me:
In the ClientApp/App folder: 1.Delete the node_modules folder 2.Delete the package-lock.json file 3.Open a cmd prompt for your ClientApp/App folder 4.Use the cmd "npm i"
This final step will reinstall all your node-modules. The issue I had must've been a conflicting node-module.
As of May 2022...
A note if you're using vscodium and firefox you need to install firefox-devtools directly from the marketplace: https://marketplace.visualstudio.com/items?itemName=firefox-devtools.vscode-firefox-debug
Beyond that the launch.json config is standard:
{
"name": "Vue:Client",
"type": "firefox",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/src",
"pathMappings": [
{
"url": "file://",
"path": ""
}
]
},
The extension suggested I insert those pathMappings.
See https://github.com/firefox-devtools/vscode-firefox-debug/issues/267
started a new react-native project, followed link react native cli quickstart approach. even though I have not done any code change , getting the below error when i run npx react-native run-android
Version info:
"react": "16.9.0",
"react-native": "0.61.5"
Error info:
:ReactNative:Failed to parse React Native CLI configuration: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'I' with an int value of 73
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
FAILURE: Build failed with an exception.
* Where:
Script 'D:\xp\feb2020xp\AwesomeProject\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 200
* What went wrong:
A problem occurred evaluating script.
> Failed to parse React Native CLI configuration. Expected running 'npx.cmd --quiet --no-install react-native config' command from 'D:\xp\feb2020xp\AwesomeProject' directory to output valid JSON, but it didn't. This may be caused by npx resolving to a legacy global react-native binary. Please make sure to uninstall any global 'react-native' binaries: 'npm uninstall -g react-native react-native-cli' and try again
What I Tried :
npm uninstall -g react-native react-native-cli
and
npx.cmd --quiet --no-install react-native config
console ouput from 2nd command:
{
"root": "D:\\xp\\feb2020xp\\AwesomeProject",
"reactNativePath": "D:\\xp\\feb2020xp\\AwesomeProject\\node_modules\\react-native",
"dependencies": {},
"commands": [
{
"name": "log-ios",
"description": "starts iOS device syslog tail"
},
{
"name": "run-ios",
"description": "builds your app and starts it on iOS simulator",
"examples": [
{
"desc": "Run on a different simulator, e.g. iPhone 5",
"cmd": "react-native run-ios --simulator \"iPhone 5\""
},
{
"desc": "Pass a non-standard location of iOS directory",
"cmd": "react-native run-ios --project-path \"./app/ios\""
},
{
"desc": "Run on a connected device, e.g. Max's iPhone",
"cmd": "react-native run-ios --device \"Max's iPhone\""
},
{
"desc": "Run on the AppleTV simulator",
"cmd": "react-native run-ios --simulator \"Apple TV\" --scheme \"helloworld-tvOS\""
}
],
"options": [
{
"name": "--simulator [string]",
"description": "Explicitly set simulator to use. Optionally include iOS version betweenparenthesis at the end to match an exact version: \"iPhone 6 (10.0)\"",
"default": "iPhone 11"
},
{
"name": "--configuration [string]",
"description": "Explicitly set the scheme configuration to use",
"default": "Debug"
},
{
"name": "--scheme [string]",
"description": "Explicitly set Xcode scheme to use"
},
{
"name": "--project-path [string]",
"description": "Path relative to project root where the Xcode project (.xcodeproj) lives.",
"default": "ios"
},
{
"name": "--device [string]",
"description": "Explicitly set device to use by name. The value is not required if you have a single device connected."
},
{
"name": "--udid [string]",
"description": "Explicitly set device to use by udid"
},
{
"name": "--no-packager",
"description": "Do not launch packager while building"
},
{
"name": "--verbose",
"description": "Do not use xcpretty even if installed"
},
{
"name": "--port [number]",
"default": 8081
},
{
"name": "--terminal [string]",
"description": "Launches the Metro Bundler in a new window using the specified terminal path."
}
]
},
{
"name": "log-android",
"description": "starts logkitty"
},
{
"name": "run-android",
"description": "builds your app and starts it on a connected Android emulator or device",
"options": [
{
"name": "--root [string]",
"description": "Override the root directory for the android build (which contains the android directory)",
"default": ""
},
{
"name": "--variant [string]",
"description": "Specify your app's build variant",
"default": "debug"
},
{
"name": "--appFolder [string]",
"description": "Specify a different application folder name for the android source. If not, we assume is \"app\"",
"default": "app"
},
{
"name": "--appId [string]",
"description": "Specify an applicationId to launch after build.",
"default": ""
},
{
"name": "--appIdSuffix [string]",
"description": "Specify an applicationIdSuffix to launch after build.",
"default": ""
},
{
"name": "--main-activity [string]",
"description": "Name of the activity to start",
"default": "MainActivity"
},
{
"name": "--deviceId [string]",
"description": "builds your app and starts it on a specific device/simulator with the given device id (listed by running \"adb devices\" on the command line)."
},
{
"name": "--no-packager",
"description": "Do not launch packager while building"
},
{
"name": "--port [number]",
"default": 8081
},
{
"name": "--terminal [string]",
"description": "Launches the Metro Bundler in a new window using the specified terminal path."
},
{
"name": "--tasks [list]",
"description": "Run custom Gradle tasks. By default it's \"installDebug\""
},
{
"name": "--no-jetifier",
"description": "Do not run \"jetifier\" – the AndroidX transition tool. By default it runs before Gradle to ease working with libraries that don't support AndroidX yet. See more at: https://www.npmjs.com/package/jetifier.",
"default": false
}
]
}
],
"assets": [],
"platforms": {
"ios": {},
"android": {}
},
"haste": {
"providesModuleNodeModules": [
"react-native"
],
"platforms": [
"ios",
"android"
]
},
"project": {
"ios": {
"sourceDir": "D:\\xp\\feb2020xp\\AwesomeProject\\ios",
"folder": "D:\\xp\\feb2020xp\\AwesomeProject",
"pbxprojPath": "D:\\xp\\feb2020xp\\AwesomeProject\\ios\\AwesomeProject.xcodeproj\\project.pbxproj",
"podfile": "D:\\xp\\feb2020xp\\AwesomeProject\\ios\\Podfile",
"podspecPath": null,
"projectPath": "D:\\xp\\feb2020xp\\AwesomeProject\\ios\\AwesomeProject.xcodeproj",
"projectName": "AwesomeProject.xcodeproj",
"libraryFolder": "Libraries",
"sharedLibraries": [],
"plist": [],
"scriptPhases": []
},
"android": {
"sourceDir": "D:\\xp\\feb2020xp\\AwesomeProject\\android\\app",
"isFlat": false,
"folder": "D:\\xp\\feb2020xp\\AwesomeProject",
"stringsPath": "D:\\xp\\feb2020xp\\AwesomeProject\\android\\app\\src\\main\\res\\values\\strings.xml",
"manifestPath": "D:\\xp\\feb2020xp\\AwesomeProject\\android\\app\\src\\main\\AndroidManifest.xml",
"buildGradlePath": "D:\\xp\\feb2020xp\\AwesomeProject\\android\\app\\build.gradle",
"settingsGradlePath": "D:\\xp\\feb2020xp\\AwesomeProject\\android\\settings.gradle",
"assetsPath": "D:\\xp\\feb2020xp\\AwesomeProject\\android\\app\\src\\main\\assets",
"mainFilePath": "D:\\xp\\feb2020xp\\AwesomeProject\\android\\app\\src\\main\\java\\com\\awesomeproject\\MainApplication.java",
"packageName": "com.awesomeproject"
}
}
}
I am unable to figure out what is going wrong. please help me in resolving the error . thank you.
I experienced a similar issue. The problem for me turned out to be a syntax error in the file android/app/src/main/AndroidManifest.xml.
Specifically, I had a wrong part like android:screenOrientation=portrait rather than the correct android:screenOrientation="portrait" (note the quotation marks).
Although the specific reason for the problem likely does not match yours, it may hopefully give you a hint for a potential solution.
I have two projects with common root opened in visual code. First is .net core webapi. Second is frontend on react/redux etc. Now when I want to run application I need to manually from console run 'npm start' and then run webapi from visual code. How can I achieve this with configuration of vs code?
At then end I want that after clicking debug I will have recompiled and deployed webapi and rebuild and same with frontend app. Then open browser in desired page.
There is an idea that I can run some script that would handle that, but I would prefer do it with pure vs code configuration.
I think that I need to modify my launch.json file. Don't know how though.
This is launch.json https://pastebin.com/9a66n3Rx
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/server/bin/Debug/netcoreapp2.0/webapi.dll",
"args": [],
"cwd": "${workspaceFolder}/server",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
Frontend app is in "${workspaceFolder}/client" folder
I'm trying to setup debugging on OSX environment using .NET Core RC2 and Visual Studio Code. The following error is given when trying to run the debugger.
Couldn't find 'project.json' in current directory
Currently I've setup launch.json (see below) and chosen .NET Core Launch (web) in Visual Studio Code.
As my project is in a folder called Core and sharing space with two other folders my structure looks like this.
Structure
--.vscode
------ launch.json
------ tasks.json
-- Core
-- Core.Data
-- Core.Service
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/Core/bin/Debug/netcoreapp1.0/Core.dll",
"args": [],
"cwd": "${workspaceRoot}/Core",
"stopAtEntry": false
},
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/Core/bin/Debug/netcoreapp1.0/Core.dll",
"args": [],
"cwd": "${workspaceRoot}/Core",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open",
"args": "-a chrome ${auto-detect-url}"
},
"linux": {
"command": "xdg-open"
}
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processName": "<example>"
}
]
}
Folder structure
I needed to add this code
tasks.json
"options":{
"cwd": "${workspaceRoot}/Core"
}
None of the answers helped me. I just specified the whole path to project.json and it began to work fine.
tasks.json
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}\\project.json"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]}
So, for this particular question it would be
"args": [
"${workspaceRoot}\\Core\\project.json"
],
I ran into this problem as well. I was able to fix it by specifying the content root for the WebHostBuilder in the entry point for the application. Make sure your entry point method looks something like this:
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
The important part of that code is:
.UseContentRoot(Directory.GetCurrentDirectory())
This tells the host where to find your site assets, including project.json and your MVC views.
On Ubuntu 16.10, I went into the tasks.json file and changed the \\ to / in the single args property like below:
"${workspaceRoot}\\project.json"
to
"${workspaceRoot}/project.json"
After that it worked flawlessly. Below is my entire tasks.json (it is from a dotnet core starter project)
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}/project.json"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
}