Skip to content

Deleted header files remain includable #2072

Closed
@fredrikeldh

Description

@fredrikeldh

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".

Activity

sngl

sngl commented on May 14, 2014

@sngl
Contributor

Hello @fredrikeldh,
have you tried to close and reopen the Arduino IDE. Closing it should clean the temporary directory.

fredrikeldh

fredrikeldh commented on May 14, 2014

@fredrikeldh
Author

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.

assigned and unassigned on Oct 2, 2015
per1234

per1234 commented on Jul 3, 2017

@per1234
Collaborator

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

self-assigned this
on Jan 15, 2023
per1234

per1234 commented on Jan 15, 2023

@per1234
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @fredrikeldh@cmaglie@ffissore@sngl@per1234

      Issue actions

        Deleted header files remain includable · Issue #2072 · arduino/Arduino