Sublime text 3 MinGW build - io

I've been trying to build sublime text 3 for competitive programming and am getting confused about build systems. I've tried various build systems from the net and some start the console for i/o ,some show some error and don't work. I have downloaded MinGW as C:\MinGW\bin . I require a build which inputs from a file "input.txt" and outputs to "output.txt". Here is my sample code which I'm trying to run.
My code
What it does is open the console and even when I enter the input (present in the image), it doesn't give output.
The build -
{
"cmd": ["gcc", "${file}", "-o", "${file_base_name}.exe"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"shell": true,
"variants":
[
{
"name": "Run",
"cmd": ["start", "cmd", "/k", "${file_path}/${file_base_name}.exe"],
"shell": true
}
] }

Related

VSC Run and Debug - Process exited with code 1 - But runs fine in terminal

I am trying to test this serverless application but the Run and Debug function in VSC does not want to run it. I've tried numerous amount of pathing to the node modules but this does not change the outcome.
My configuration:
{
"type": "node",
"request": "launch",
"name": "invoke local",
"program": "/Users/MYNAME/.nvm/versions/node/v17.8.0/lib/node_modules/serverless/bin/serverless",
"args": [
"invoke",
"local",
"-f",
"${fileBasenameNoExtension}",
"-p",
"testEvents/${fileBasenameNoExtension}.json"
],
"cwd": "${fileDirname}/../",
"skipFiles": [
"<node_internals>/**/*.js",
"node_modules/**"
],
"env": { "AWS_PROFILE": "awsProfile" },
"outFiles": [
"${workspaceRoot}/**/*.js"
]
},
runs:
/Users/MYNAME/.nvm/versions/node/v17.8.0/bin/node ./../../../../../.nvm/versions/node/v17.8.0/lib/node_modules/serverless/bin/serverless invoke local -f fileName -p testEvents/FileName.json
which results in Process exited with code 1
When the same line is run terminal it returns the desired result.
Problem solved by running "console": "externalTerminal" in the config, this terminal gave me a more detailed error & in my case it was solved by fixed a typo in my AWS profile.
Still strange that it did run the line in the terminal as mentioned before, I've some could explain that, would be great.

Trying to run "npm run start" in VS Code's Debug on Windows 10

Normally, I run npm run start to run my program. I am trying to use the VS Code debugger to debug my program while running it.
Here's my 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": "(Windows) Launch electron",
"type": "cppvsdbg",
"request": "launch",
"program": "npm",
"args": ["run", "start"],
//"preLaunchTask": "build:win32",
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true
}
]
}
When I run this using VS Code the error I get is: launch program '' does not exist.
This all works fine if I use node under program for my debug sessions.
Other things:
$ which npm
/c/Program Files/nodejs/npm
I tried changing program to exactly that path but it didn't work.
I think the reason is in your "program" field, which is supposed to locate the executable files. Some common values are like "program": "${workspaceFolder}/app.js"
program - executable or file to run when launching the debugger

Sublime build for XML with different extension

I have a project that uses a XML file of the type .uvprojx.
I have a sublime build I have found and modified slightly and it works fine but I can't get the build system to auto-detect that this is the build it needs to use. I need to manually go to Tools->Build systems -> My build.
This is my .sublime-build file:
{
"cmd": ["python", "C:/Users/cag/Documents/Tasks/PythonMisc/UvisionWrapper.py", "UV4", "-b", "-j0", "${file}", "-o", "out.txt"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.uvprojx",
"variants":
[
{
"name": "Flash",
"shell":true,
"cmd": ["python", "C:/Users/cag/Documents/Tasks/PythonMisc/UvisionWrapper.py", "UV4", "-f", "-j0", "${file}", "-o", "out.txt"]
},
{
"name": "Clean",
"shell":true,
"cmd": ["python", "C:/Users/cag/Documents/Tasks/PythonMisc/UvisionWrapper.py", "UV4", "-c", "-j0", "${file}", "-o", "out.txt"]
},
]
}
I have the python wrapper as the .exe file for the build creates a new process so I need to save the output to a file and read it in Python but anyway it works well.
What I want is that when I open a file with the extension .uvprojx this build is the default. If it matters Sublime detects this file as XML (which it is).
Change your selector to text.xml and add "file_patterns": ["*.uvprojx"], as per the documentation at http://www.sublimetext.com/docs/3/build_systems.html#options, then ST will auto-select the build system correctly for you.

What is the difference between args and runtimeArgs in VSCode's launch.json?

What is the difference between args and runtimeArgs in launch.json?
// Optional arguments passed to the runtime executable
"runtimeArgs": []
// Command line arguments passed to the program
"args": []
Is the program not the same thing as the runtime executable?
Extra information and motivation behind the question:
I am developing a nodejs application. In my package.json, I have a start script:
"start": "electron ./src/Main/main.js arg2", and in my app code, I access process.argv[2] which gets me arg2, so when I run npm start, my app works as intended.
When I run the app from VSCode, however it doesn't, and the reason was that I wasn't supplying any additional arguments in launch.json. Where should I put those arguments? process.argv seems to contains the arguments provided in either args or runtimeArgs though it also sticks in some --debug-brk argument, which I don't want.
I want to be able to use process.argv consistently when I run the app from the command line (npm start) or start it from VSCode.
I think this is mostly explained in the Node debugging docs:
Instead of launching the Node.js program directly with node, you can use 'npm' scripts or other task runner tools directly from a launch configuration:
Any program available on the PATH (for example 'npm', 'mocha', 'gulp', etc.) can be used for the runtimeExecutable attribute [...]
runtimeExecutable is not the program you want to debug, but the executable used to run it. So it appears that runtimeArgs is to runtimeExecutable as args is to program.
If you're interested in how it works in detail, here's the relevant part of the debugAdapter.ts implementation.
If you remove the attribute "program", the arguments are attached after another and you don't see any difference.
Consider following example, including "type" and "program":
{
"name": "vscode-jest-tests",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest.js",
"stopOnEntry": false,
"args": [
"--runInBand"
],
"cwd": "${workspaceFolder}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true
}
=> set "NODE_ENV=development" && "C:\Program Files\nodejs\node.exe" --nolazy --inspect-brk=35238 node_modules\jest-cli\bin\jest.js --runInBand
The runtimeArg "--nolazy" occurs behind node.exe (corresponds to type) and
The arg "--runInBand" occurs behind jest.js (corresonds to program)
If you remove the attribute "program", the arguments are attached after another and you don't see any difference.

Nodejs build sublime-text2

I am trying to use sublime-text 2, have installed Nodejs for Windows, the Nodejs plugin through package control and I get the following error:
ERROR: The process "node.exe" not found.
The filename, directory name, or volume label syntax is incorrect.
[Finished in 0.1s with exit code 1]
I have setup as my user environment variable a NODE_PATH: C:\Program Files\nodejs\node.exe
There is in my System variables PATH: C:\Program Files\nodejs\
My Nodejs.sublime-settings is set-up as follows:
{
// save before running commands
"save_first": true,
// if present, use this command instead of plain "node"
// e.g. "/usr/bin/node" or "C:\bin\node.exe"
"node_command": "C:/Program Files/nodejs/node.exe",
// Same for NPM command
"npm_command": false,
// as 'NODE_PATH' environment variable for node runtime
"node_path": "C:/Program Files/nodejs/node.exe",
"expert_mode": false,
"ouput_to_new_tab": false
}
My Nodejs.sublime-build is set-up as follows:
{
"cmd": ["C:/Program Files/nodejs/node.exe", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell":true,
"encoding": "cp1252",
"windows":
{
"cmd": ["taskkill /F /IM node.exe & node", "$file"]
},
"linux":
{
"cmd": ["killall node; node", "$file"]
}
}
As a side note, I'm using JSHint which uses Nodejs using the same path (namely "C:/Program Files/nodejs/node.exe") and JSHint works!
Any idea why I can't use Nodejs build system?
Thx
Try setting your build system just to the following for the time being:
{
"cmd": ["C:/Program Files/nodejs/node.exe", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell":true,
}
Because you have a Windows-specific section, it's running that instead of the "cmd" on the first line of the build system. I suspect there's some sort of issue with the taskkill command.
If this does work, and you feel the need to have the taskkill section back in there, try restructuring it like so:
"windows":
{
"cmd": ["taskkill", "/F", "/IM", "node.exe", "&", "C:/Program Files/nodejs/node.exe", "$file"],
"shell": true
}
Obviously, you don't need the linux section in there at all. I'm not too sure about the syntax on windows, you may need to have two ampersands && there instead of one - I know that's the case on OS X and Linux systems.
Good luck!

Resources