tasks.json exists but 'No task defined' - json

I have a tasks.json open in VSCode. When I try to 'Run Task' I get 'No task to be run. Configure Tasks'.
Trying to Configure Tasks I get 'Open tasks.json'. But tasks.json is already open in VSCode. Closing tasks.json and reopening it gives the same result.
Help appreciated. tasks.json shown below.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"label": "GnuCOBOL - Compile (single file)",
"type": "shell",
"options": {
"env": {
"PATH":"\\gnucobol3\\bin",
"COB_CONFIG_DIR": "c:\\gnucobol3\\config",
"COB_COPY_DIR": "c:\\gnucobol3\\copy",
"COB_INCLUDE_PATH": "c:\\gnucobol3\\include",
"COB_LIB_PATH": "c:\\gnucobol3\\lib",
},
"command": "cobc",
"args": [
"-x",
"-std=mf",
"-t${fileBasenameNoExtension}.LST",
"${file}"
]
},
}

It looks like your tasks.json file got changed. It should be of this form:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
// "global" options can go here
"options": {
"env": {
"APP_NAME": "Nice"
}
},
// you are missing the tasks array
"tasks": [
{ // task 1
"label": "Task A",
"type": "shell",
"command": "echo A2",
"problemMatcher": [],
"presentation": {
"group": "groupA"
}
// or task-specific options can go here
},
{ // task 2
"label": "Task B",
"type": "shell",
"command": "echo B",
"problemMatcher": [],
"presentation": {
"group": "groupA"
}
}
]
}
So with your code:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"options": {
"env": {
"PATH":"\\gnucobol3\\bin",
"COB_CONFIG_DIR": "c:\\gnucobol3\\config",
"COB_COPY_DIR": "c:\\gnucobol3\\copy",
"COB_INCLUDE_PATH": "c:\\gnucobol3\\include",
"COB_LIB_PATH": "c:\\gnucobol3\\lib",
}
},
"tasks": [
{
"label": "GnuCOBOL - Compile (single file)",
"type": "shell",
"command": "cobc",
"args": [
"-x",
"-std=mf",
"-t${fileBasenameNoExtension}.LST",
"${file}"
]
}
]
}
}
}

Not sure how to respond - my response is too big for a comment.
Mark: I've modified tasks.json thus but still get same errors:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
{
"label": "GnuCOBOL - Compile (single file)",
"type": "shell",
"options": {
"env": {
"PATH":"\\gnucobol3\\bin",
"COB_CONFIG_DIR": "c:\\gnucobol3\\config",
"COB_COPY_DIR": "c:\\gnucobol3\\copy",
"COB_INCLUDE_PATH": "c:\\gnucobol3\\include",
"COB_LIB_PATH": "c:\\gnucobol3\\lib",
},
"tasks": [
{"command": "cobc",
"args": [
"-x",
"-std=mf",
"-t${fileBasenameNoExtension}.LST",
"${file}"
]
}
]
}
}
}

Mark: your mods now run but with errors:
> Executing task: cobc -x -std=mf -ttasks.LST c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json <
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:2: error: invalid indicator 'e' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:3: error: invalid indicator 'o' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:4: error: invalid indicator 's' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:5: error: invalid indicator 'i' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:6: error: invalid indicator 'n' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:7: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:8: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:9: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:10: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:11: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:14: error: invalid indicator 'k' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:16: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:17: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:18: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:19: error: invalid indicator '"' at column 7
c:\WORKAREA\cobol\VisualStudioCode\.vscode\tasks.json:24: error: invalid indicator ']' at column 7

Related

How to query my JSON file for specific key

I am working on a project where I want to query a JSon using Jquery but I am getting an error:
jq: error: syntax error, unexpected IDENT, expecting $end (Unix shell quoting issues?) at <top-level>, line 1:
..id
jq: 1 compile error
Error: Process completed with exit code 3.
I am using the command:
jq '..id' new_file.json
To query my JSON file which is named new_file.json
Here is my JSON file:
[
{
"type": "users_export",
"status": "pending",
"connection_id": "con_kmZIjREZWYzt39JI",
"format": "json",
"limit": 5,
"fields": [
{
"name": "user_id"
},
{
"name": "user_id",
"export_as": "provider"
},
{
"name": "username"
},
{
"name": "username",
"export_as": "provider"
},
{
"name": "nickname"
},
{
"name": "email"
},
{
"name": "email"
},
{
"name": "identities[0].connection",
"export_as": "provider"
},
{
"name": "email_verified",
"export_as": "provider"
}
],
"connection": "dev-default-evoyanbs",
"created_at": "2022-11-16T17:45:58.429Z",
"id": "job_aztDgKXWT8g8iZ5T"
}
]
I want the 'job_aztDgKXWT8g8iZ5T' as my output but I am getting the above mentioned error, can someone please help me out, thanks.
As you have an array, the command should be:
jq '.[].id' new_file.json
And the result will be: "job_aztDgKXWT8g8iZ5T".
If you want to get rid of double quotes in your output, you can add raw-output flag in your command, like this:
jq -r '.[].id' new_file.json
or
jq --raw-output '.[].id' new_file.json

How to fix gdb : Giving weird error message

After debugging this C++ code:
#include <iostream>
int main() {
std::cout << "Checking Debugging Progress!";
return 0;
}
I'm getting a weird message.
Aborted (core dumped) [1] + Aborted (core dumped) "/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-ua1ohquu.lr2" 1>"/tmp/Microsoft-MIEngine-Out-s1zccpii.3ja"
Interestingly enough that, not always I'm getting this message in the terminal. Is there any specific thing I'm doing wrong that I'm facing this error ? Note that I'm debugging in Visual Studio Code, using Linux and using the following .json file to build the code :
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
The problem is with the "command" and "args" in the .json file. The command should be "/usr/bin/gdb" and the args should be ["-fdiagnostics-color=always", "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}"]

VSCode Linux tasks.json MQL4 Compilation

I am switching to VSCode from MetaEditor to develop for MetaTrader4.
I'm using MetaTrader4 and MetaEditor in Linux via Wine.
(and MetaEditor runs quite terribly in Wine)
I would like to create a task to compile the code, and hopefully return the same error log to VSCode to further debug the code as if I was using MetaEditor.
I've used this post to figure out what CLI command has been used to compile MQL4:
Compiling MQL4 via command line through wine metaeditor.exe
/usr/bin/wine /path/to/MT4/metaeditor.exe /compile:"Z:\path\to\MT4\MQL4\Experts\Foo\Bar_EA.mq4" /include:"Z:\path\to\MT4\MQL4" /log
My issue is that I don't understand and cannot find any resource that explains what the "commands" inside the tasks.json file does or list of available variables. Like "/include:" or "presentation":, ${file}, etc.
So I took some guesses and I pieced it together to look something like this so far:
{
"version": "2.0.0",
"tasks": [
{
"label": "MQL4 Compile",
"type": "shell",
"command": "/usr/bin/wine /.wine/drive_c/Program Files (x86)/FXChoice MetaTrader 4/metaeditor.exe",
"args": [
"/compile:${file}"
]
}
]
}
Its probably not quite right.
I appreciate your help, thank you
{
"version": "2.0.0",
"tasks":
[
{
"label": "MQL4-Compile",
"group":
{
"kind" : "build",
"isDefault" : true
},
"presentation":
{
"echo" : true,
"reveal": "always",
"focus" : true,
"panel" : "shared"
},
"promptOnClose" : true,
"type" : "process",
"osx" :
{
"command" : "wine",
"args" :
[
"/Users/SVG/.wine/drive_c/Program Files/MetaTrader/metaeditor.exe",
"/compile:${fileBasename}",
"/log:${fileBasenameNoExtension}.log",
]
},
"windows" :
{
"command" : "C:\\Program Files (x86)\\MetaTrader\\metaeditor.exe",
"args" :
[
"/compile:${fileBasename}",
"/log:${fileBasenameNoExtension}.log",
]
},
}
]
}

how do i get rid of the json errors : line 2-4 Comments are not permitted in JSON. line 62 char 2 end of file expected

i am working on learning more about json code and how to get rid of the json errors and i am just working from the script i would like to make a better script. i did do everything i could think of to get rid of the errors without changing the language in visual studios, what is your solution to get rid of the errors?
here are the error message in visual studio:
line 2-4 Comments are not permitted in JSON.
line 62 char 2 end of file expected
the following json script is used to make the c++ debugger run and is used to enable visual studio to identifiy c++ errors. i am just tweaking it.
{
line 2 // Use IntelliSense to learn about possible attributes.
line 3 // Hover to view descriptions of existing attributes.
line 4 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "enter program name, for example ${workspaceFolder}/a.exe",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"miDebuggerPath": "/path/to/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"customLaunchSetupCommands": [
{ "text": "target-run", "description": "run target", "ignoreFailures": false }
],
"launchCompleteCommand": "exec-run",
"windows :gdb"
:"C:\\MinGw\\bin\\gdb.exe"
}
]
,"name": "(gdb) Bash on Windows Launch",
"type": "cppdbg",
"request": "launch",
"program": "enter program name, for example ${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"pipeTransport": {
"debuggerPath": "/usr/bin/gdb",
"pipeProgram": "${env:windir}\\system32\\bash.exe",
"pipeArgs": ["-c"],
"pipeCwd": ""
},
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
[enter image description here][1] ],"customLaunchSetupCommands": [
{ "text": "target-run", "description": "run target", "ignoreFailures": false }
],
"launchCompleteCommand": "exec-run",
"windows" : "gdb,"
,"miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe"
line 62 }[
]
to get rid of the line 2-4 Comments are not permitted in JSON. remove a backslash on 2 of those lines and a colon. remove the brackets at line 62.

Capturing Visual Stadio Command Line Compilier (CL.EXE) Output With Regular Expressions

I've been trying to set up VS command line compiler to use in VS code IDE. I have read the examples and can use GCC with no problem but need to use VS compiler now too.
I have tried a single line problem matcher and I multiple one. Yet VC code seems to capture nothing.
Here is an example of output with error from the compiler:
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.40629 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
helloWorld.c
..\Code\helloWorld.c(7) : error C2143: syntax error : missing ';' before '}'
Using the regExpr Expression:
(.*\n){2,3}\S+(\d+)\W+:\s(\bwarning|error\b\s\w+):\s(\w+\s\w+)\s+:\s(.*)$
It captures all the info I need (checked my work here: https://regex101.com/)
but when I put it in a Tasks.json file for VS code it doesn't work.
{
"version": "0.1.0",
"command": "Build",
"args": [
"${fileBasename}"
],
"isShellCommand": true,
"tasks": [
{
"taskName": "Build",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "always",
// No args
"args": [
"all"
],
// Use the standard less compilation problem matcher.
"problemMatcher": {
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
],
"pattern": {
"regexp": "(.*\n){2,3}\\S+(\\d+)\\W+:\\s(\bwarning|error\b\\s\\w+):\\s(\\w+\\s\\w+)\\s+:\\s(.*)$",
"file": 1,
"line": 2,
"severity": 3,
"code": 4,
"message": 5
}
}
}
]
}
Anyone know how to setup VS Code IDE to use VS command line compiler? Any help would be greatly appreciated
The first two lines in your output can be avoided by adding /nologo flag to the compiler. So your tasks.json should be:
"tasks": [
{
"taskName": "Build",
"isBuildCommand": true,
"showOutput": "always",
"args": [
"all"
],
"problemMatcher": {
"owner": "cpp",
"severity": "info", // treat note as info
"fileLocation": "absolute",
"pattern": {
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error|note)\\s*(\\w+)?:\\s+(.*)$",
"file": 1,
"location": 2,
"severity": 3,
"code": 4,
"message": 5
}
}
}
]