In VS Code 1.13.1, running in Windows Creator Update, I have defined this task in tasks.json:
{
"version": "0.1.0",
"runner": "terminal",
"command": "echo",
"isShellCommand": true,
"args": ["Hello world"],
"showOutput": "always"
}
When I run the task I see this message in the integrated terminal:
Terminal will be reused by tasks, press any key to close it.
But I don't see "Hello world". Why?
I don't know if you solved it yet, but I was having the same problem until I changed the terminal on settings.json from
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
to
"terminal.integrated.shell.windows": "C:\\WINDOWS\\Sysnative\\cmd.exe"
If your settings.json file does not have this line you can add and see if the problem goes away.
Related
Microsoft recently released remote development support for SSH.
https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh
However, in python, if you click "select python interpreter". The interpreter available to be chosen is only for a set of python interpreters in anaconda.
The interpreter available to be chosen are in:
~/anaconda3/*
/usr/bin/python
I have a custom python interpreter in a custom location. My interpreter is in ~/projects/myproject/bin/python
How do we configure a remote python interpreter by giving it a path?
Note: I have configured setting.json
"python.pythonPath": "${workspaceFolder}/bin/python",
But it does not seem to respect it
managed to make it work with
update vscode
my files:
# settings.json
{
"python.pythonPath": "/custom/bin/python"
}
# launch.json
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"pythonPath": "${config:python.pythonPath}"
},
...
restarted vscode
F1 -> select Interpreter
I'm trying to compile some C code in visual studio with gcc using WSL.
I've got a super simple configuration that executes on an F5 Press
"version": "0.2.0",
"configurations": [
{
"name": "Build And Run",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/.vscode/BuildAndRun.bat",
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"externalConsole": true,
"environment": [],
},]
Which then should execute the batch file that contains a simple call to wsl and gcc
#echo off
wsl gcc main.c
pause
When I run this bat file by clicking on it, it works and everything compiles. however when I press F5 I get an error that 'wsl' is not recognized as an internal or external command.
I've tried adding it to Path and that didnt help.
I should also add that when I run the command inside the vs terminal it works, which just confuses me even more.
https://code.visualstudio.com/docs/cpp/launch-json-reference
program (required)
Specifies the full path to the executable the debugger will launch or attach to.
The debugger requires this location in order to load debug symbols
program is the executable for debugger to attach, not compile your code. Compile your C program via preLaunchTask in launch.json and config that command in tasks.json. See https://code.visualstudio.com/docs/cpp/config-mingw for reference.
Also, you may need WSL-Remote plugin and work directly in WSL, See also https://code.visualstudio.com/docs/cpp/config-wsl
Im trying to run "puppet-lint -f (currently open file)
The Puppet extenstion provides puppet-lint check, but doesnt auto fix any issues, it just gives warnings. How can I add a keyboard shortcut to run "puppet-lint -f" on a file Im currently editing?
Thanks
I don't know anything about the Puppet extension but in general here is how you can bind a shell command to a keychord:
Make a task for it (.vscode/tasks.json):
{
"version": "2.0.0",
"tasks": [{
"label": "node version",
"command": "node",
"args": [
"-v"
],
"type": "shell"
}]
}
In the args you may use ${file} for the current file.
Then add this option to your keybindings.json (you can find them in Command Palette under “Preferences: Open keyboard shortcuts (JSON)”):
{
"key": "shift+escape",
"command": "workbench.action.tasks.runTask",
"args": "node version"
},
co-author of the extension here. You can have the Puppet VSCode Extension run puppet-lint fix on the current file by using the Format Document command. You can then configure VSCode to run format on save.
I am in the process of switching a project from Gulp 3.9.1 (npm install gulp) to Gulp 4.0 (npm install gulp-4.0.build), but when I do this, Visual Studio Code is no longer able to auto-detect the tasks in my gulpfile.js. In both cases, gulp is installed locally.
My .vscode/tasks.json looks like:
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"showOutput": "always"
}
Looking at the Tasks output, I see the following message:
Running gulp --tasks-simple didn't list any tasks. Did you run npm install?
Can you use Gulp 4.0 with VS Code and have it autodetect the tasks? If so, what steps do I need to follow to get it setup?
Yes, you can use vscode and gulp4.0. I would look at how to upgrade to gulp4.0.
Did you uninstall gulp3.9.1 first?
You should also install gulp4.0 both locally and globally!
Then run
gulp -v
to make sure it worked. vsCode should detect both tasks in your tasks.json file and from your gulpfile.js. You are using the older tasks.json version 0.1.0. Here is an example of a tasks.json file which allows me to type "gulp sync" in the command line from anywhere in the workspaceRoot and run that task:
{
"version": "2.0.0",
"tasks": [
{
"label": "Start server and process files",
"command": "gulp",
"args": [
"sync"
],
"type": "shell",
"options": {
"cwd": "${workspaceRoot}"
}
}
]
}
It runs the "sync" task I defined in my gulpfile.js. In fact you can assign a hotkey combo to that such as:
{ "key": "shift+escape",
"command": "workbench.action.tasks.runTask",
"args": "Start server and process files"
},
in your keybindings.json.
I am running VS Code 1.6 on Windows and have configured the integrated terminal to be bash:
"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\bash.exe",
I want to build my C++ project using make running in WSL. So I defined a task:
{
"version": "0.1.0",
"command": "make",
"isShellCommand": true,
"args": [""],
"showOutput": "always"
}
How can I configure that task to run in WSL?
How can I set the directory in which make should run? (not the root directory of the folder opened in Code, but a subfolder of it).
Try this (replacing as appropriate:
{
"version": "0.1.0",
"command": "c:\\Windows\\sysnative\\bash.exe",
"isShellCommand": true,
"args": ["-c 'cd /mnt/c/<path>; make'"],
"showOutput": "always"
}