arduino settings for Visual Studio Code - visual-studio-code

This is driving me crazy! I see solutions all over the web and I still can't get this to work. Here is my settings.json file:
{
"C_Cpp.updateChannel": "Insiders",
"workbench.editorAssociations": {
"*.ipynb": "jupyter.notebook.ipynb"
},
"arduino.additionalUrls": "",
"arduino.path": "C:\\Program Files (x86)\\Arduino",
"arduino.commandPath": "arduino.exe",
"files.autoSave": "onWindowChange",
}
I am running on Windows 10 and Arduino is installed in:
C:\Program Files (x86)\Arduino
I have four executables there:
arduino.exe
arduino_debug.exe (I downloaded this for good measure!)
arduino-cli.exe
uninstall.exe
When I click "Select Programmer" in VSC, I get"
"Cannot find Arduino IDE. Please specify the "arduino.path" in the User Settings. Requires a restart after change.
I have restarted the IDE and still get the same problem.
I have rebooted the laptop.
I have tried uninstalling both VSC and Arduino.
The Arduino IDE works fine stand-alone.

Wow! I finally stumbled on these installation instructions:
https://nortronics.com.au/setting-up-visual-studio-code-for-arduino-programming/
This is what my .vscode/settings.json (you can find it in the left pane under .vscode in your project folder) now looks like:
{
"arduino.path": "C:\\Program Files (x86)\\Arduino",
"C_Cpp.intelliSenseEngineFallback": "Disabled",
"C_Cpp.intelliSenseEngine": "Tag Parser",
"arduino.enableUSBDetection": true,
}

Related

Cargo build broke after using VS code

For a while I have been editing my Rust program with Pycharm Professional. However, I was curious and experimented with VS Code. At first my project was compiling and running. However, it suddenly started throwing a pretty wild error on cargo build and cargo run (while cargo check is fine), even in cmd outside of VS Code:
error: linking with `link.exe` failed: exit code: 1104
= note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.30.30705\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\rust\\book\\target\\debug\\deps\\book.1apvyby1qhuehv3.rcgu.o" "C:\\rust\\book\\target\\debug\\deps\\book.1cw7xmk0cjjg5uln.rcgu.o" "C:\\rust\\book\\target\\debug\\deps\\book.1e8ho0j4rykowhcr.rcgu.o" "C:\\rust\\book\\target\\debug\\deps\\book.1g2fbveo2gp7bxds.rcgu.o"
..............
..............
= note: LINK : fatal error LNK1104: cannot open file 'C:\rust\book\target\debug\deps\book.exe'
book is the name of my project.
I am on Windows 10, System Type: x64-based PC.
VS Code version 1.63.2
Sometimes VSCode file watcher watches the files in target/, that is not good.
So open the Settings, search for exclude, and in all "list-like" cofigurations add **/target/**, do a cargo clean and restart VSCode. This should fix this and future problems
Had to remove the directory, and redownload the whole project(used Git).

Visual Studio Code Debugger not launching

OS and Version: Windows 10 Build 19042.985
VS Code Version: 1.56.2
C/C++ Extension Version: v1.4.0-insiders
other extensions: remote-ssh
I've been working with remote-ssh on a raspberry and c/c++ extension without any issue, all of a sudden I cannot start the debugger. Nothing changed, configuration files are the same as before but now when I start the debugger, I see for a couple of seconds the top debugging bar and then it disappears. No message on the console, nothing.
For this purpose, I created a simple project from scratch, and even there, the same issue appears.
To Reproduce
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"logging": { "engineLogging": true },
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
]
}
]
}
main.c
#include <stdio.h>
int main(){
printf("ciao\n");
return 1;
}
Compile with gcc -g main.c
As I stated before, this workflow worked for me, from one second to another it stopped working as intended and I have no idea why and how to fix it, any help is appreciated.
What I tried
reinstall vscode
reinstall the c/c++ extension and delete by hand the extension folder
numerous reboots
Updates
I have tried with the wsl-remote extension and it is working as expected.รน
Tried to uninstall gdb from host and launch the debug session, the message "gdb" not found does not even appear as it should
I was in similar situation and couldn't find relevant resolutions:
Quick Answer:
After upgrade to VS Code 1.56.2, make sure to remove old breakpoints and create new breakpoint and at-least have 1 breakpoint and launch.json available.
Lengthy details:
I have similar issue for python scripts when I start the "debugger bar" I see it for a couple of seconds the top debugging bar and then it disappears. Bu then no message on the console, nothing. I tried reinstalling VS Code, enabling/disabling extension, various restart.
OS and Version: Mac OSX Version 11.4 (20F71)
VS Code Version: 1.56.2
Extension: Python v2021.5.842923320 by Microsoft
RootCause:
What I did know for sure that I updated my VS Code, and after that this mysterious issue start happening, so when to release log of VS Code 1.56.2. I found below release log
Debug view displayed on break#
The default value of the debug.openDebug setting is now
openOnDebugBreak so that on every breakpoint hit, VS Code will open
the Debug view. The Debug view is also displayed on first session
start.
So VS code Version 1.56 release, debugger will only show when at-least 1 breakpoint is found. However, looks like there is issue with their internal code checking for historical breakpoint data after VS Code upgrade..
https://code.visualstudio.com/updates/v1_56#_debug-view-displayed-on-break
I had this same issue in python. The fix for python was changing to a valid interpreter due to a python library not being installed. Make sure that the interpreter is correct and then try again.
This may be caused by a faulty installation of the VS Code C/C++ extension. When launching VS Code, if the message "Unable to start the C/C++ language server. IntelliSense features will be disabled" appears, this is probably the cause. Was able to fix the installation in this case by installing a previous version of the C/C++ extension as per this answer.
I had the same problem (though the debug bar would show up for a second and then disappear). I was using a conda env with python 3.6. I updated to 3.8, with the same dependencies, and it started working.

Getting "bash: XXX: command not found" in VS Code terminal

I am getting this error on my VS Code terminal. I have tried reinstalling the IDE but it did not go away. I am using Linux mint.
This VScode issue they say "By default the VS Code integrated terminal does not run as a login shell".
As this is n answer from 2016, the option they give is deprecated.
The problem I has is running the terminal in WSL environment and what worked for me is to add the following to my setting.json:
{
"terminal.integrated.profiles.linux": {
"bash": {
"path": "bash",
"icon": "terminal-bash",
"args": [
"--login"
]
}
}
}
You then need to delete the open terminal (the dustbin icon) and reopen. Or just restart VScode.

How to show warnings in VSCode editor for a .cpp file?

Is it possible to tweak VSC somehow to see GCC warnings in the text editor?
Refer to the screenshot below - it shows only errors in the console.
I'm using 1.43.2 version with C/C++ extension 0.26.3 installed.
Tried adding -Wall compiler flag to "args" in tasks.json but it didn't help.
Below are my settings:
{
"editor.fontSize": 13,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 100,
"files.insertFinalNewline": true,
}
The warning and errors are shown in Problem Panel.
You can see Problems 4 on it.
You might need to install Visual Studio IntelliCode or C++ Intellisense to help you identify mistakes before compilation.

How to configure bower in Asp.net project using Visual Studio Code

I create an empty project using Visual Studio Code's terminal. Then I add bower.json and bower_config.bowerrc files then using terminal run the bower update command. The files contains next code:
bower.json
{
"name": "asp.net",
"private": true,
"directory": "wwwroot/lib",
"dependencies": {
"bootstrap": "4.0.0-alpha.6"
}
}
bower_config.bowerrc
{
"directory": "wwwroot/lib"
}
But even I configured it to download files into wwwrooot/lib folder it still install into bower_comoponents folder. How can I resolve that?
P.S. I need to use Visual Studio Code not Visual Studio.
Your bower configuration file should be named .bowerrc (no bower_config prefix).