Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

[Warning] Failed to generate IntelliSense configuration. #1541

Closed
lukasgabriel opened this issue Oct 14, 2022 · 28 comments
Closed

[Warning] Failed to generate IntelliSense configuration. #1541

lukasgabriel opened this issue Oct 14, 2022 · 28 comments
Labels
intellisense needs-more-info More details about this issue are needed for it to be actionable. stale

Comments

@lukasgabriel
Copy link

lukasgabriel commented Oct 14, 2022

When trying to generate the IntelliSense configuration in c_cpp_properties.json, I get this error:
image

This makes the extension pretty much unusable since no IntelliSense info is there - might as well use the Arduino IDE.
image

The sketch name is the same name as the folder it is in.
The problem also appears in a fresh project.
I have tried reinstalling the Arduino and C/C++ extensions.
I've also uninstalled Visual Studio, VS Build Tools and several other things that could have interfered (as described in other issues with this problem).
I've tried everything I could find and think of for the past 2 hours, no luck. Any help would be greatly appreciated.

System info:
Windows 11 Pro for Workstation 22H2 22623.746
VSCode Version 1.72.2
Arduino CLI Version 0.27.1
Arduino and C/C++ Extensions on their respective newest versions.
Board: Raspberry Pi Pico

Here's my arduino.json:

{
    "arduino.path": "C:/ProgramData/chocolatey/bin",
    "sketch": "client\\client.ino",
    "configuration": "flash=2097152_0,freq=133,opt=Small,rtti=Disabled,stackprotect=Disabled,exceptions=Disabled,dbgport=Disabled,dbglvl=None,usbstack=picosdk,ipstack=ipv4only",
    "board": "rp2040:rp2040:rpipico",
    "port": "COM8",
    "output": "output"
}

And here's my workspace settings.json:

{
    "cmake.configureOnOpen": false,
    "arduino.path": "C:\\ProgramData\\chocolatey\\bin",
    "arduino.useArduinoCli": true,
}

This is probably related to #1373 #1489 #1514 #1517

@github-actions github-actions bot added the triage New issues that have not been reviewed. label Oct 14, 2022
@olifink
Copy link

olifink commented Nov 16, 2022

I had the same problem, was foolishly trying to use new software like arduino-cli and alternatively the new Arduino IDE 2.x. But both didn't work, however by installing Arduino IDE 1.8 and removing the arduino settings both from the project and user settings before trying again resulted in an auto generated c_cpp_properties.json for the Arduino config that handles IntelliSense correctly

@DoganM95
Copy link

DoganM95 commented Nov 30, 2022

i fought with this nonsense for 2 days now. am tired of this extremely buggy and poorly maintained vscode extension.
Switched to PlatformIO now, a bit unconvenient but it works at least...

@lukasgabriel
Copy link
Author

Sadly, looking at all the unadressed issues, this repo (and extension) seems to be in a pretty poor state and not really usable right now.
I think it really deserves some attention since VSCode these days can do 99% of things, sucks having to leave that workflow and familiar environment for Arduino things.

@Scoutzknifez
Copy link

I had the same problem, was foolishly trying to use new software like arduino-cli and alternatively the new Arduino IDE 2.x. But both didn't work, however by installing Arduino IDE 1.8 and removing the arduino settings both from the project and user settings before trying again resulted in an auto generated c_cpp_properties.json for the Arduino config that handles IntelliSense correctly

This worked for me as well.
Make sure your VSCode settings for Arduino.path are empty. I deleted the c_cpp_properties.json and it regenerated it completely fine.
Took a while to come to this solution though, I do wish it was more straight forward.

@jamesrwaugh
Copy link

I found I needed to actually open the Arduino IDE, verify some code, and install a library before the extension worked. I'm assuming this places compilation C/C++ files on the system that the extension uses.

On Ubuntu:

  1. Started with a fresh arduino.json / settings.json
  2. Install Ardunio IDE 1.8.x using the provided install.sh
  3. Plug in my Arduino
  4. Upload blank sketch, add any libraries I'm using
  5. Set extension paths accordingly, for me these were left blank as I used default install.sh options
  6. Verify / generate now works.

@javos65
Copy link

javos65 commented Jan 13, 2023

I went through this VS-Hell as well on Windows , The point for Arduino compiler is that :

Arduino IDE 1.xx is supported , as it supports cli (command line interface) calls that VS use to operate.
Arduino IDE 2.00 is NOT supported, as it does not support cli-calls
Arduino PRO is NOT supported - idem
Arduino-CLI is supported, this is the ' under the hood' version of IDE2.0 / PRO

I'v setup Arduino-CLI in VS, specifying the settings.json for compiler specifics:
{
"arduino.enableUSBDetection": true,
"arduino.path": "C:\Program Files\arduino-cli_0.29.0",
"arduino.commandPath":"arduino-cli.exe",
"arduino.useArduinoCli": true,
}

ALSO, check your arduino-cli.yaml init-file to set the arduino directories correct for library recognition.
it in the your AppData\Local\Arduino15 directory :

directories:
data: C:\Users<>\AppData\Local\Arduino15
downloads: C:\Users<>\AppData\Local\Arduino15\staging
user: C:\Users<>\OneDrive\Documents\Arduino

Last but not least: if your have custom libraries in use, CLI does not recognize them as it does not scan your library directory, it looks it up in an index-file. I had to re-install custom libs it using github (cli-command line install)

In VS the compiler environment and the C++ code-check environment are not the same, so check the C++ browse path to have code support.

i'v not been able to solve the intellisense support.

just my 50 cents.

@laurensV
Copy link

Same problem here, Arduino IDE 2.x (officialy released now) does not work, and when trying to use the arduino-cli (either the one that is already included in Arduino IDE 2.x or a freshly downloaded arduino-cli.exe file) have the problen that the libraries/dependencies are not (things like cannot open source file "Wire.h") and when trying to verify the project, I get the warning: Failed to generate IntelliSense configuration. Extension is not usable in this state..

@MKme
Copy link

MKme commented Jan 18, 2023

Same problems as above here. Have yet to get mine to work. Intellisense and Lib errors. The Lib errors I resolved with Arduino-CLI but then intellisense ruins the day. Wasted a week on this

@anzbert
Copy link

anzbert commented Jan 31, 2023

It works fine on macos, just with the CLI and Arduino 2.0 installed.

On windows on the in other hand, I need the old arduino 1.8.x installed for the extension to work properly.

@benmcmorran
Copy link
Member

Can you try again with the recently released version 0.5.0 of the extension? It includes #1591, a fix to the extension's handling of Arduino CLI for generating IntelliSense configurations.

@benmcmorran benmcmorran added intellisense needs-more-info More details about this issue are needed for it to be actionable. and removed triage New issues that have not been reviewed. labels Feb 17, 2023
@marsfan
Copy link

marsfan commented Feb 17, 2023

@benmcmorran I'm having issues with 0.5.0. The command Arduino: Verify only works every third time. Seems that it likes to wipe and re-generate the compile_commands.json file. Could this be related or should I open a separate bug?

End of Log Output After First Error:

Error during build: unable to read contents of the source item: open C:\Users\Gabe Roper\Documents\Arduino\simple_esp32_audio\.build\compile_commands.json: The system cannot find the file specified.

Used platform Version Path                                                                           
esp32:esp32   2.0.3   C:\Users\Gabe Roper\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.3
[Warning] Failed to generate IntelliSense configuration.
[Error] Verifying sketch 'simple_esp32_audio.ino': Exit with code=1

End of Log Output After Second Error:

Error during build: unable to read contents of the source item: open C:\Users\Gabe Roper\Documents\Arduino\simple_esp32_audio\.build\compile_commands.json: The system cannot find the file specified.
[Warning] Failed to generate IntelliSense configuration.
[Error] Verifying sketch 'simple_esp32_audio.ino': Exit with code=1

Contents of compile_commands.json after first error:

[]

Contents of arduino.json

{
    "configuration": "PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,LoopCore=1,EventsCore=1,DebugLevel=none",
    "board": "esp32:esp32:esp32",
    "sketch": "simple_esp32_audio.ino",
    "output": "./.build"
}

@benmcmorran
Copy link
Member

Thanks for checking. Based on the error messages it looks likely that this is the same issue as arduino/arduino-cli#1646. As a workaround, you can try changing the output setting to a path outside the sketch directory.

@marsfan
Copy link

marsfan commented Feb 18, 2023

@benmcmorran Moving the output directory to be in a path outside of the sketch directory seems to have fixed it for me. Not sure if that solves the problem for anyone else though.

@toamz
Copy link

toamz commented Feb 18, 2023

Changing the output directory to be outside of the sketch directory fixed it for me too.

@reflectingme
Copy link

It works fine on macos, just with the CLI and Arduino 2.0 installed.

On windows on the in other hand, I need the old arduino 1.8.x installed for the extension to work properly.

I am on MacOS and cannot get this extension to work, it is so frustrating. Regular errors experienced are unable to locate include files, and failed to generate Intellisense configuration.

I really don't like the ArduinoIDE and would much prefer VSCode. I load a file in ArduinoIDE and it compiles and uploads perfectly, load the very same file in the very same sketch folder using VSCode and it fails to find the include files and fails to generate Intellisense configuration. Pulling out what little hair I have left, lol.

@anzbert
Copy link

anzbert commented Mar 5, 2023

hey @reflectingme . I am not sure why its not working for you. Since the latest update includes arduino-cli, it should be even easier to set up.

I am using the following most important settings on my mac with M1 chip:

  • Arduino: Command Path and Arduino: Path: Both left empty
  • Arduino: Use Arduino CLI: Ticked!

That seems to do the trick. Otherwise, I do have Arduino IDE 2.0 installed on my Mac. Not sure if that makes a difference.

Good Luck :)

@reflectingme
Copy link

Thanks @anzbert - it is causing me to pull out the little remaining hair I have left :)

I am not on M1 but am using the same setup, both parameters empty and use Arduino cli ticked, and I have Arduino IDE 2.0 running, but I still get these darned intellisense and include errors. I run a file in the Arduino IDE and it works fine, and when I try to load and compile the very same file using VScode it does not even compile. So very annoying as I’m pretty much forced to use the IDE when I’d much rather use VScode.

Thanks though for your reply.

@anzbert
Copy link

anzbert commented Mar 5, 2023 via email

@github-actions
Copy link

github-actions bot commented Apr 4, 2023

This issue has been automatically marked as stale because it has been inactive for 30 days. To reactivate the issue, simply post a comment with the requested information to help us diagnose this issue. If this issue remains inactive for another 7 days, it will be automatically closed.

@github-actions github-actions bot added the stale label Apr 4, 2023
@github-actions
Copy link

This issue has been automatically closed due to inactivity. If you are still experiencing problems, please open a new issue.

@couillonnade
Copy link

For me, the solution came after I opened the .ino file in Arduino IDE and it complained that the file must be in a folder with the same name, proposed to create the folder and move the file. After that, I was able to use vscode. Conclusion, .ino file cannot be at the root of the workspace.

@tingjhenjiang
Copy link

tingjhenjiang commented Jun 13, 2023

In my case, after I changed the "name" part from "Win32" to "Arduino" in "c_cpp_properties.json", everything would go fine. VSCode would start to rebuild IntelliSense configuration (manual rebuild can be done by pressing ctrl+alt+I). An example is as below:
{ "version": 4, "configurations": [ { "name": "Arduino", ...

@lobodpav
Copy link

lobodpav commented Oct 14, 2023

For me, VSCode always reports errors in my .ino file, complaining that

cannot open source file "mbed_toolchain.h" (dependency of "WiFi.h")C/C++(1696)
cannot open source file "netsocket/NetworkInterface.h" (dependency of "thingProperties.h")C/C++(1696)

If I apply the Quick Fixes offered that update the includePath, it starts complaining again, this time

cannot open source file "platform/mbed_preprocessor.h" (dependency of "WiFi.h")C/C++(1696)
cannot open source file "EthernetInterface.h" (dependency of "thingProperties.h")C/C++(1696)

The problem goes on no matter how many times I apply the quick fixes, and after verifying the code or rebuilding IntelliSense, all these quick fixes get reverted.

@aklein24
Copy link

aklein24 commented Jan 6, 2024

I tried so many of the things here without any luck. I was looking again at tingjhenjiang's comment, and then I noticed in the bottom right of the screen that I had the Win32 C++ configuration selected. Changed that to Arduino and my problem went away!

Clicking this in the bottom right corner:
image

Will bring up the command palette, and then changing this to Arduino finally fixed it:
image
image

This issue has been annoying to me for years, but I just ignored it because everything worked OK. Thanks tingjhenjiang for putting me on the right path!

@kameo4242
Copy link

kameo4242 commented Jan 15, 2024

Rahhhhh, this thing drove me mad for days...
It's painful but can actually work, with intellisense! The real problem is I don't know what exactly made it work :/
(but I've a screen capture to prove it's real). Good news is: I've a working config I can share ;)

Current setup:

  • Windows 11 (22h2)
  • Arduino IDE 2.2.1
  • Arduino CLI 0.35.0
  • Visual Studio Code 1.85.1 (system, not user version)
  • Arduino extension Release version 0.6.230727001
  • C/C++ extension v1.18.5
  • Cmake v0.0.17
  • Cmake tools v1.16.32
  • UE Intellisense Fixes v3.1.4 (Can help fix some weirdnesses it seems)

What I think could have played a role:

  • Full fresh install of vscode with wiping of all data in Appdata\roaming\code
  • My project are stored in a directory without any space in their name to avoid Windows vs Posix issues
  • I renamed my profile from win32 to arduino as proposed above
  • I installed the beta version of Arduino extension
  • I edited hundreds of times my config files with all kind of weird attempts until these one worked
  • They know I'm a stubborn donkey

c_cpp_properties.json would be long to share but it was properly generated by a Ctrl+alt+I (regen intellisense config).

.vscode\settings.json

{
    "arduino.clearOutputOnBuild": true,
    "arduino.useArduinoCli": true,
    "arduino.path": "F:\\code\\compiler\\",
    "arduino.commandPath": "arduino-cli.exe",
    "arduino.enableUSBDetection": true,
    "workbench.colorTheme": "Default Dark Modern",
    "cmake.configureOnOpen": true,
    "cmake.options.statusBarVisibility": "icon",
    "C_Cpp.default.compilerPath": "F:\\code\\compiler\\"
}

c:\user\kameo\AppData\Roaming\code\User\settings.json

    "arduino.clearOutputOnBuild": true,
    "arduino.useArduinoCli": true,
    "arduino.path": "F:\\code\\compiler\\",
    "arduino.commandPath": "arduino-cli.exe",
    "arduino.enableUSBDetection": true,
    "workbench.colorTheme": "Default Dark Modern",
    "cmake.configureOnOpen": true,
    "cmake.options.statusBarVisibility": "icon",
    "cmake.showOptionsMovedNotification": false,
    "C_Cpp.default.compilerPath": "F:\\code\\compiler\\",
    "UEIntellisenseFixes.enableFixes": true,
    "UEIntellisenseFixes.enableOptionalFixes": true,
    "UEIntellisenseFixes.compiler.path": "F:\\code\\compiler\\",
    "security.workspace.trust.untrustedFiles": "open"
}

.vscode\arduino.json

    "configuration": "JTAGAdapter=default,PSRAM=disabled,FlashMode=qio,FlashSize=4M,LoopCore=1,EventsCore=1,USBMode=hwcdc,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PartitionScheme=default,CPUFreq=240,UploadSpeed=921600,DebugLevel=none,EraseFlash=none",
    "board": "esp32:esp32:esp32s3",
    "programmer": "esptool",
    "sketch": "AIBOX\\AIBOX.ino",
    "output": "f:\\code\\AIBOX"
}

c:\user\kameo\AppData\Local\Arduino15\arduino-cli.yaml

    additional_urls: []
build_cache:
    compilations_before_purge: 10
    ttl: 720h0m0s
daemon:
    port: "50051"
directories:
    data: C:\Users\kameo\Documents\Arduino\libraries
    downloads: C:\Users\kameo\AppData\Local\Arduino15\staging
    user: C:\Users\kameo\Documents\Arduino
library:
    enable_unsafe_install: true
logging:
    file: ""
    format: text
    level: info
metrics:
    addr: :9090
    enabled: true
output:
    no_color: false
sketch:
    always_export_binaries: false
updater:
    enable_notification: true

vscode-arduino-cli

@aklein24
Copy link

@kameo4242 sometimes being a stubborn donkey is the only way to solve some of these problems! Glad you got it working!

@youneshenni
Copy link

One thing that might help is to set the name for the .ino file as the same name of the folder it's into, very weird but it worked for me

@MatthewGumbert
Copy link

I found I needed to actually open the Arduino IDE, verify some code, and install a library before the extension worked. I'm assuming this places compilation C/C++ files on the system that the extension uses.

On Ubuntu:

1. Started with a fresh arduino.json / settings.json

2. Install Ardunio IDE 1.8.x using the provided `install.sh`

3. Plug in my Arduino

4. Upload blank sketch, add any libraries I'm using

5. Set extension paths accordingly, for me these were left blank as I used default `install.sh` options

6. Verify / generate now works.

yup, that worked thanks !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
intellisense needs-more-info More details about this issue are needed for it to be actionable. stale
Projects
None yet
Development

No branches or pull requests