Double files in tab with a lock and redefines error's

Hi, I got a project with some issue’s ( macOS )

One issue is. During compiling I get errors from old files which are already deleted or updated. For now I don’t care about the code errors but about how Arduino IDE handles those.

F.e 4-5 days ago I did change a file and since today it pop’s up as a double file ( in the tab with a lock). It shows as diff file with the difference from the old file.

How and why and how to solve it and to get rid of the old information ( BTW I did duplicate the folder and deleted the old folder but still… )? I did delete Arduino folder inside /var/…/T/arduino* but didn’t work. So where is the real compile folder? Why is there no cleanUp button?

is it something similar to “https://github.com/arduino/arduino-cli/issues/1240” and “https://forum.arduino.cc/t/how-to-clear-cache-from-ide/1374114” but still in there in some way?

You need to show us with screen grabs your preferences, your fooder structure starting at the path in the preferences, and the actual IDE screen when you encounter the error.

Like this?
editor tab

That is indeed the tab for a diff viewer. That one is from Visual Studio Code. But AFAIK, that's not a feature of Arduino IDE (either v1 or v2), although it should be part of the underlying Theia Platform. Do you have any extra plugins installed?

One possible reason: it should almost never be necessary; if it was there, people would suggest clicking it "just to be sure", therefore wasting time and effort for virtually no benefit.

Try to Save As another sketch. Renaming it that way should "make it forget" in a similar way, and may fix your problem.

Hi @ipadawan.

It is possible this is caused by the bug you tried to reference:

I'm going to ask you to provide the full verbose output from a compilation that fails spuriously.


:red_exclamation_mark: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Open the problematic sketch in Arduino IDE.
  2. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  3. Check the box next to "Show verbose output during: ☐ compile" in the "Preferences" dialog.
  4. Click the "OK" button.
    The "Preferences" dialog will close.
  5. Select Sketch > Verify/Compile from the Arduino IDE menus.
  6. Wait for the compilation to fail.
  7. You will see a "Compilation error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  8. Open a reply here on this forum topic by clicking the "Reply" button.
  9. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  10. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the compilation output into the code block.
  11. Move the cursor outside of the code block markup before you add any additional text to your reply.
  12. Click the "Reply" button to publish the post.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here.

Click here for attachment instructions

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a reply here on this forum topic by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:

    The "Open" dialog will open.
  6. Select the .txt file you saved from the "Open" dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

This looks like the preview for Arduino IDE's global search and replace feature (which is accessed via the magnifying glass icon in the "activity bar" on the left hand side of the Arduino IDE window). If you enter a query in the "Search" field of this interface, and then a replacement string in the "Replace" field, you will see a list of results for the search query. If you click on one of those results a diff view will open in the main panel of the Arduino IDE window. Depending on the dimensions of the window, this diff view will either be in a side-by-side format, or in the "inline" format shown in your screenshot.

You can dismiss that diff view at any time by simply clicking the X icon on its tab:

Arduino IDE intentionally does not have a Git integration (even though as you point out the Eclipse Theia Platform IDE framework upon which it is build does indeed support having one). However, it does have a diff viewer (which we can see has uses beyond showing diffs between revisions in a Git repository).

You make a good point. There are surely 3rd party VS Code plugins (most likely Git related, but perhaps for other things as well) that would provide other paths to ending up with a diff view in Arduino IDE if @ipadawan happened to have installed one.

What about View: Toggle Source Control in the Command Palette? It opens up a pane that says "No repository found". Should that be hidden?

The curation of Arduino IDE's user interface is limited to the primary user interface. The command palette is only intended for advanced users and is very much a "here be dragons" zone to be used at your own risk.

Been there done that. :wink:
The clean button: that users uses this unnecessary doesn’t mean the button is not unnecessary.

I wrote just a script that search for the cache and give me a choice to clean it.

#!/usr/bin/env bash

set -euo pipefail

############## Hardcoded sketchbook cache folder ##############
SKETCHES_DIR="$HOME/Library/Caches/arduino/sketches"

if [[ ! -d "$SKETCHES_DIR" ]]; then
echo "Sketches folder niet gevonden: $SKETCHES_DIR" >&2
echo "Is de hardcoded folder correct?"
echo "Pas hardcoded pad aan."
exit 1
fi

############## Vind de INO in de huidige directory ##############
LOCAL_INO=( *.ino )
if [[ ${#LOCAL_INO[@]} -eq 0 ]]; then
echo "Geen .ino file gevonden in huidige folder: $(pwd)" >&2
exit 1
fi

if [[ ${#LOCAL_INO[@]} -gt 1 ]]; then
echo "Meerdere .ino bestanden gevonden. Kies één." >&2
# todo: recursive kiezen
exit 1
fi

LOCAL_INO_FILE="${LOCAL_INO[0]}"
#BASENAME=$(basename "$LOCAL_INO_FILE" .ino)

echo "Lokale sketch: $LOCAL_INO_FILE"
#echo "Basename:      $BASENAME"

############## Zoek overeenkomstige sketch in 'sketch' subfolders ##############
FOUND_SKETCH=""
FOUND_FOLDER=""
for SUBFOLDER in "$SKETCHES_DIR"/*/; do
SKETCH_SUBFOLDER="$SUBFOLDER/sketch"
# echo "Controleer sketch folder: $SKETCH_SUBFOLDER"
if [[ -d "$SKETCH_SUBFOLDER" && -f "$SKETCH_SUBFOLDER/$LOCAL_INO_FILE.cpp" ]]; then
FOUND_SKETCH="$SKETCH_SUBFOLDER/$LOCAL_INO_FILE.cpp"
FOUND_FOLDER="$SUBFOLDER"
break
fi
done

if [[ -z "$FOUND_SKETCH" ]]; then
echo
echo "Geen overeenkomstige sketch gevonden in $SKETCHES_DIR" >&2
exit 1
fi

echo "Overeenkomstige sketch gevonden: $FOUND_SKETCH"
echo "Bijbehorende folder:             $FOUND_FOLDER"

############## Moet de parent folder in Finder geopend worden ##############
echo
read -p "Wil je de folder openen in Finder om te checken? (j/n) " OPEN_RESP
case "$OPEN_RESP" in
[jJ]|[yY])
open "$FOUND_FOLDER"
;;
esac

############## Moet de folder verwijderd moet worden ##############
echo
read -p "Wil je de folder '$FOUND_FOLDER' verwijderen? (j/n) " DEL_RESP
case "$DEL_RESP" in
[jJ]|[yY])
rm -rf "$FOUND_FOLDER"
echo "Folder '$FOUND_FOLDER' verwijderd."
;;
*)
echo "Folder blijft aanwezig."
;;
esac

It did save me a lot of headache.
Maybe someone can use it. It is in Dutch and for macOS, but I guess it is not difficult to change it for win/linux. Hardcode in the script the path to the Arduino sketches cache like “$HOME/Library/Caches/arduino/sketches”. CD to the folder where the sketch.ino is in. run the script, what finds the .ino file and searches that sketch in the cache folder. It ask for to show it and/or to delete it.

Any comments are welcome so maybe I can make it better.

Hi,

Also thank you for your reply.
Those points you mentioned are already tried.

Also I have no plugins or even a Theme loaded.

Please provide a detailed description of what happened when you clicked the X icon on the tab.

It opens the other tab ( without a lock ) with the same name. So meaning ( I guess it wasn’t clear from my previous post ) Arduino opens several files twice, one with lock and one without a lock. The ones with a lock show file content like the image above. The magnify glass area is empty, meaning there is no value in the search/replace field. ( Side note; it would be nice if there is a ‘x’ button to clear that field.)

I can’t try it anymore because I did clear the cache files with above script and it works fine for now.

And is everything working and looking as expected in that tab without the lock?

That is correct. The one without the lock is the standard sketch editor. The one with the lock is the preview of the find and replace operation. This is normal and expected operation.

The preview view remains open even after you clear the fields in the "SEARCH" view. The view is only closed when you click the X icon on the tab.

I'm glad everything is working now.