Skip to content

Previous file persists in build folder after renaming non-.ino sketch code file #1240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
digimeas opened this issue Jun 19, 2016 · 1 comment
Open
3 tasks done
Labels
topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@digimeas
Copy link

digimeas commented Jun 19, 2016

Describe the problem

The previous file persists in the sketch build folder after a sketch code file with extension other than .ino/.pde is renamed.

🐛 This can result in spurious compilation errors or confusing bugs. Arduino CLI users can work around the bug by adding the --clean flag to their command, but the only workaround for Arduino IDE users is to manually clean the build folder.

To reproduce

$ arduino-cli version

arduino-cli.exe  Version: git-snapshot Commit: a735ddfd Date: 2023-01-15T01:00:07Z

$ arduino-cli sketch new /tmp/FooSketch

$ echo "void asdf() {}" > /tmp/FooSketch/foo.cpp

$ arduino-cli compile --fqbn arduino:avr:uno /tmp/FooSketch

[...]

$ mv /tmp/FooSketch/foo.cpp /tmp/FooSketch/bar.cpp

$ arduino-cli compile --fqbn arduino:avr:uno /tmp/FooSketch

C:\Users\per\AppData\Local\Temp\arduino\sketch-2405C4C9F90028537C79B0744BCE536E\sketch\foo.cpp.o (symbol from plugin): In function `asdf()':
(.text+0x0): multiple definition of `asdf()'
C:\Users\per\AppData\Local\Temp\arduino\sketch-2405C4C9F90028537C79B0744BCE536E\sketch\bar.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

Used platform Version Path
arduino:avr   1.8.6   C:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Error during build: exit status 1

$ ls "C:/Users/per/AppData/Local/Temp/arduino/sketch-2405C4C9F90028537C79B0744BCE536E/sketch"

bar.cpp  bar.cpp.d  bar.cpp.o  foo.cpp  foo.cpp.d  foo.cpp.o  FooSketch.ino.cpp  FooSketch.ino.cpp.d  FooSketch.ino.cpp.o

🐛 foo.cpp is still present in the build folder even though not present in the sketch. foo.cpp is compiled in addition to bar.cpp and the primary sketch file.

Expected behavior

Files are always removed from the sketch build folder when no longer present in the sketch.

Arduino CLI version

Original report

Arduino IDE 1.6.9

Last verified with

0.34.1

Operating system

  • Linux
  • Windows

Operating system version

  • Mint
  • 10

Additional context

Workaround

Arduino CLI users

Run an arduino-cli compile command with the --clean flag.

Arduino IDE users
  1. Examine the compiler error message. It will show the path of the temporary build folder.
    For example, in this error:
    C:\Users\per\AppData\Local\Temp\arduino\sketches\7930E8409AED6D4F4A4782CF985194E9\sketch\foo.cpp.o (symbol from plugin): In function `asdf()':
    (.text+0x0): multiple definition of `asdf()'
    C:\Users\per\AppData\Local\Temp\arduino\sketches\7930E8409AED6D4F4A4782CF985194E9\sketch\bar.cpp.o (symbol from plugin):(.text+0x0): first defined here
    collect2.exe: error: ld returned 1 exit status
    
    exit status 1
    
    Compilation error: exit status 1
    
    The temporary build folder is:
    C:\Users\per\AppData\Local\Temp\arduino\sketches\7930E8409AED6D4F4A4782CF985194E9\sketch\
    
  2. Delete the temporary build folder.

Additional reports


Keywords

  • rename

  • header

  • .h

  • .cpp

  • .c

  • C++

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@matthijskooijman
Copy link
Collaborator

This is related to arduino/arduino-builder#86, I think the changes I have in mind for that issue will also fix this one.

@per1234 per1234 transferred this issue from arduino/Arduino Mar 28, 2021
@per1234 per1234 added topic: code Related to content of the project itself topic: core labels Mar 28, 2021
@fstasi fstasi removed the type: bug label Sep 16, 2021
@rsora rsora added type: imperfection Perceived defect in any part of project topic: core labels Sep 22, 2021
@per1234 per1234 changed the title changed filename persists in /tmp/.../sketch/ Previous file persists in /tmp/.../sketch/ after renaming non-.ino sketch code file Jan 15, 2023
@per1234 per1234 changed the title Previous file persists in /tmp/.../sketch/ after renaming non-.ino sketch code file Previous file persists in build folder after renaming non-.ino sketch code file Sep 1, 2023
@per1234 per1234 added the topic: build-process Related to the sketch build process label May 26, 2024
@per1234 per1234 marked this as a duplicate of #2870 Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

6 participants