Closed
Description
Tested with 1.0.5 on Windows.
To reproduce:
- Have a sketch.
- Create a file, let's call it "foo.h", in the sketch's directory.
- Add
#include "foo.h"
to the sketch. - Compile the sketch.
- Delete the file "foo.h".
- Compile the sketch again. If the bug is present, there is no error message despite the header file being deleted.
This happens because the Arduino IDE copies all source files to a temporary directory, reuses that directory and does not clear it of files that shouldn't be there.
On Windows 7, the temporary directory may be called something like "c:\Users\AppData\Local\Temp\build4632717550972951918.tmp".
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
sngl commentedon May 14, 2014
Hello @fredrikeldh,
have you tried to close and reopen the Arduino IDE. Closing it should clean the temporary directory.
fredrikeldh commentedon May 14, 2014
Closing the IDE does not remove any temporary files, but reopening it does create a new temp-build dir.
Interestingly, if you delete the temporary header file, it gets recreated when you verify, with the same contents as before, even if you've deleted or modified the original.
If you don't touch any temporary files, and modify the source header file, that modification does not get copied to the temporary directory. This means that if you modify the header, you must reload the IDE for that modification to take effect.
I've been trying to share code between sketches in a less roundabout way than Libraries, but that can't happen before this bug is fixed.
per1234 commentedon Jul 3, 2017
I find that if I use the Arduino IDE 1.8.3 to delete the tab via the tab menu it works correctly. This may not have been the case at the time of the issue report as indicated by #4233 and #1161). It is only if you delete the tab from outside the IDE that this issue occurs now and that's not really unexpected behavior since the tab is still shown in the Arduino IDE even though the file was deleted from the disk.
Where I find more problematic behavior is this issue as it occurs when an included file is deleted from a subfolder of the sketch folder (e.g. `#include "src/foo/foo.h"). In this case there is no mechanism to delete the file from within the IDE so there is no alternative to deleting files from outside the IDE. I suppose that is more appropriate to discuss in the arduino-builder repository now.
EDIT: There is already an issue in the arduino-builder repository for how to solve this issue: arduino/arduino-builder#86
per1234 commentedon Jan 15, 2023
Closing as resolved. I can still reproduce the fault via the modified procedure described in my previous reply when using Arduino IDE 1.8.3, but I cannot reproduce it via that procedure when using Arduino IDE 1.8.19 or Arduino IDE 2.x.
I didn't bisect the resolution so I don't know exactly where the bug was fixed.
.ino
sketch code file arduino/arduino-cli#1240