Arduino IDE 2.0.3 Duplicate TAB page

When I open my sketch, the IDE shows it on two separate TABS. I don't see a way to close the extra copy. Is this a bug or a feature?

image

Hi @gilbert54. It is a bug. The Arduino IDE developers are tracking it here:

I'll share the instructions you can follow for a workaround to restore a sketch which is exhibiting the duplicate tabs fault:

  1. Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
  2. Select the "View: Reset Workbench Layout" command from the menu.

After doing that, the redundant tab should no longer be shown. It might come back later or happen on another sketch. If that happens, you can repeat the procedure.

1 Like

Thanks for picking this up. Doesn't work here. The IDE appears to restart, then drops my header file and still shows the ino file twice..

image

I've also noticed that it no longer works or no longer works reliably.

Log attached; last attempt to get rid of it was after IDE start at 2023-01-31 13:12:37; file was opened by double clicking in windows explorer.
2023-01-31_log.zip (55.8 KB)

Maybe another bug or for whatever reason it may be intended:
I'm using a library to use the MCP2515 CAN controller. The lib was originally developed by seeedstudio GitHub - Seeed-Studio/Seeed_Arduino_CAN: Seeed Arduino CAN-BUS library - MCP2518FD&MCP2515&MCP2551) to support their CAN shield (CAN-BUS Shield V2.0 - Seeed Wiki) and later enhanced by someone else. I'm now doing some rework for my own purposes. The lib contains 2 issues, one about an unused variable in a function and another one about a function which should return a value and returns (void). The first one is OK, but the 2nd one should IMHO be an error and not a warning.
When I run "Verify" those errors only show up the very first time. When I run "Verify" again without making any changes to the code, the warnings are gone.
When I close the IDE and open it again, then load the sketch again and run "Verify" again hte errors are never shown again. I re-tried this using a different target board, and still no errors...
Not sure if this is a GCC issue or an Arduino issue.

PS: I notice the same problem when I do this with IDE version 1.8.19

I apologize for the confusion. I am only able to reproduce the fault via an somewhat contrived procedure. The sketch is recovered when I perform that workaround after simulating the fault, but I was never certain whether it would also work for the variant of the fault you and others have reported, which might be caused by a completely different bug even though the symptom is the same.

I have another potential workaround. Which operating system are you using (e.g., "Windows")?

I ask because I want to give you the appropriate instructions for your operating system.

Thanks for your perseverance, but don't waste too much time trying to reproduce it. It's annoying, but that's really all it is. I'm working on WIN 10 (version 22H2).
I'm more worried about the compiler error/warning reporting issue as it may cause code to be uploaded of which I'm lead to believe that it's ok while it isn't.

Arduino IDE caches the compiled objects for everything other than the .ino files of your sketch. The cached objects are then reused for subsequent compilations for the same board until such time as they are modified (e.g., updating a library or editing its code).

This caching is useful because it means the subsequent compilations are much shorter in duration than would be the case if it compiled all the source code every time. Unfortunately, it means you only see compiler warnings for the cached code once.

The workaround is to manually delete the folder of the cache for the component you wish to recompile. If you enable verbose output in the Arduino IDE preference, you will see the locations of the caches in the compilation output:

  1. Select File > Preferences from the Arduino IDE menus.
  2. Check the box next to "Show verbose output during: ☐ compilation".
  3. Click the OK button.
  4. Select Sketch > Verify/Compile from the Arduino IDE menus.
  5. Wait for the compilation to finish.
  6. Examine the contents of the black Output panel at the bottom of the Arduino IDE window (scroll up to see it all).

The ideal system would be for Arduino IDE to also cache the warnings and then display them in the output when the compilation of a component is skipped due to it already being cached. The developers are tracking that request here:

Arduino IDE 1.x does clear the cache when you exit the IDE, but when using Arduino IDE 2.x the cache is persistent, so it will be used even during later IDE sessions (unless your operating system has cleaned the temporary folder in the meantime).

I already have in response to all the previous reports without any success unfortunately. So I'm now taking the strategy of gathering information and keeping an eye out for chance occurrences. Sometimes the required conditions to reproduce a fault like this will emerge over time if I am observant and mindful enough.

OK, here is the alternative potential workaround:

  1. Select File > Quit from the Arduino IDE menus if it is running.
  2. Delete the folder at the following path:
    C:\Users\<username>\AppData\Roaming\arduino-ide\
    
    (where <username> is your Windows username)
    :warning: Please be very careful when deleting things from your computer. When in doubt, back up!
  3. Start Arduino IDE.

Arduino IDE stores some use data in this folder, but it will regenerate it automatically, so there is nothing precious to be lost by deleting it. You will see the side effect of Arduino IDE checking to see whether the arduino:avr (Arduino AVR Boards) platform and "built-in" libraries are already installed, as it does the first run after a fresh install. The reason this will happen again after deleting that folder is because the flag for whether the IDE already did the first run installations is stored in that folder.

As before, I haven't been able to verify this workaround will remove the duplicate tabs, but it's worth a try. The good thing about this workaround compared to the other is it should fix all sketches instead of only the one currently open in the IDE, as would be the case with the "reset workbench" technique.

Please let me know how it goes. If it doesn't work, there is one other data folder you can clear that might do the trick.

Am I glad I am not in charge of developing this IDE. The number of permutations between computers, user setups and preferences plus user options and individual requirements when using the IDE is mind boggling.

In any case, I only had the duplicate tab problem a long time ago. It was fixed and I have not seen it again.

Recently I did a lot of reading and hid on the Outline option (did not know of its existence). I find that hugely useful since we do not have a "return" facility when using "Go to Definition (F12)". After having problems with the shortcut key (which I finally got working, the Keyboard Shortcuts option seriously needs some attention - it is almost impossible to find anything using the search) I can now easily open the Outline window from the side toolbar with its icon.

However, I started getting duplicate tabs. Resetting the workbench clears it as well as the Outline icon. No more duplicate tabs. Open the Outline view, save the sketch and close the IDE and the double tab is back on restarting. I found I have to wait a while after closing the IDE before the double tab appears. I seems as if there is some cashing, probably Windows, and it it does not appear if restarting the IDE immediately after closing.

This is 100% reproducible in my case.

1 Like

Looks like that solved it again for now. However (and this is only a FYI, no request for help), after restarting the IDE

Platform arduino:avr@1.8.6 already installed
Failed to install library: Arduino_BuiltIn:1.0.0.
Error: 9 FAILED_PRECONDITION: Library 'Arduino_BuiltIn@1.0.0' not found

and after opening a second instance from within the IDE (file -> open recent)

Platform arduino:avr@1.8.6 already installed
Already installed Stepper@1.1.3
Already installed TFT@1.0.6
Already installed Arduino_BuiltIn@1.0.0
Already installed Ethernet@2.0.1
Failed to install library: Arduino_BuiltIn:1.0.0.
Error: 2 UNKNOWN: Library Firmata@2.5.9 is already installed, but with a different version: Firmata@2.5.8

And to add

I working on a project that should run on Mega and Due. Still happily compiled for the Mega after the cleanup but the cleanup broke the compilation for the Due without any sensible error message in the IDE :cry: I've put the backup back; rather live with the enemy that you know than the friend that you don't know :smiley:

...
...
Generating function prototypes...
"C:\\Users\\Wim\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10607 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON "-DUSB_MANUFACTURER=\"Arduino LLC\"" "-DUSB_PRODUCT=\"Arduino Due\"" "-IC:\\Users\\Wim\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\sam\\1.6.12\\system/libsam" "-IC:\\Users\\Wim\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\sam\\1.6.12\\system/CMSIS/CMSIS/Include/" "-IC:\\Users\\Wim\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\sam\\1.6.12\\system/CMSIS/Device/ATMEL/" "-IC:\\Users\\Wim\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\sam\\1.6.12\\cores\\arduino" "-IC:\\Users\\Wim\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\sam\\1.6.12\\variants\\arduino_due_x" "-Ic:\\Users\\Wim\\Documents\\Arduino\\libraries\\ArduinoDue_3phase-master" "C:\\Users\\Wim\\AppData\\Local\\Temp\\arduino-sketch-D7FDAB935BC53DBF6D81656748AD008D\\sketch\\P1reader.0.4e.simple.ino.cpp" -o "C:\\Users\\Wim\\AppData\\Local\\Temp\\arduino-sketch-D7FDAB935BC53DBF6D81656748AD008D\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\Users\\Wim\\AppData\\Local\\Arduino15\\packages\\builtin\\tools\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\Wim\\AppData\\Local\\Temp\\arduino-sketch-D7FDAB935BC53DBF6D81656748AD008D\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Using library ArduinoDue_3phase-master in folder: C:\Users\Wim\Documents\Arduino\libraries\ArduinoDue_3phase-master (legacy)
exit status 1

Compilation error: exit status 1

As I mentioned in my previous reply, clearing the "user data" folder also causes Arduino IDE to try the "first run" installations. So this explains why it is attempting to install the arduino:avr ("Arduino AVR Boards") platform and "Arduino_BuiltIn" library. But it does not explain why the installation of "Arduino_BuiltIn" failed with this "not found" error.

I also have experienced this fault. My finding was that it always happens when I have the ridiculous collection of >40 boards platforms in place I use to "stress test" Arduino IDE, but never happens when I have a more reasonable number of platforms installed. My hypothesis was that this is a "concurrency bug" caused by two operations happening simultaneously:

  • Update indexes
  • Install libraries

Arduino IDE (actually Arduino CLI) rescans the installed libraries during the index update process, so if the timing is just right, it loses its internal data about the libraries that are installed just as it is attempting to install this library. The number of platforms influences the timing because it takes longer to scan through them all.

I didn't report this specific bug because it only occurred for me under conditions a regular user would not have and that would be very difficult for the developers to reproduce (because they would have to spend hours installing 20 GB of platforms from dozens of obscure package indexes). I did see a user report of the problem since that time (Failed_precondition?), but it still seemed quite rare and my hope was that the fix for a more straightforward bug would also fix the elusive one. The straightforward bug is this:

That was fixed two weeks ago. I just tried replacing the stock version of Arduino CLI used by Arduino IDE with the one that has the fix and sure enough I am no longer able to reproduce the fault! So let's hope it is now fixed.

This time the result was expected.

During the beta/pre-release phase of Arduino IDE 2.x, we received complaints that when the user already had a specific version of one of the "built-in" libraries installed on their system from during their time using Arduino IDE 1.x, Arduino IDE 2.x's first run installation of the library would cause an unwanted update of the library, which might break projects that were intended to be used with the previous version of the library:

The fix implemented by the developers was to configure the first run "built-in" library installation to be canceled if it would result in an update of a previously installed library:

That solved the update problem, but not another problem caused by the "built-in" library installation, which was that their installation in the sketchbook resulted in them having a higher priority than the Arduino IDE 1.x "built-in" libraries. The solution was to use a special dedicated folder for the installation of these libraries just the same as Arduino IDE 1.x had, and with the same priority as given to the Arduino IDE 1.x "built-in" libraries:

After that was implemented, the "no overwrite" fix implemented in arduino/arduino-ide#1169 was no longer needed, since there was no longer any concern about the installation updating the user's pre-existing libraries. But there also wasn't any reason to revert arduino/arduino-ide#1169 since the installation is only ever expected to run once, in which case there would not be any chance of an overwrite. That doesn't consider that users might clear the "user data" folder and trigger an additional "first run" installation process. However, even then it is not necessarily wrong for Arduino IDE to decline to update the existing "built-in" libraries and in fact the safest behavior is probably to leave any updates up to the user instead of doing them automatically.

By "cleanup", do you mean deleting the C:\Users\<username>\AppData\Roaming\arduino-ide\ folder?

Similarly, by "the backup", do you mean you saved a copy of C:\Users\<username>\AppData\Roaming\arduino-ide\ and put the copy of that folder back?

That is frustrating. This specific situation might be better in the future thanks to this recent improvement:

Before that, any error output from ctags was not printed to the output.

Sorry for not being clear; I copied arduino-ide to arduino-ide-old and deleted arduino-ide. I started the IDE again, it all seemed to work till I tried to compile for the Due (see above).
Deleted the new arduino-ide and renamed arduino-ide-old to arduino-ide and everything was OK again.

Note that the application that I was working on (app A) did not have the double tabs; that was another application (app B) for which the solution did work though I did not try to compile that one for the Due. After putting the backup back, the problem of the duplicate tab in app B was back (as I did expect :wink:)

I assumed that was the case, but had to check because it is very unexpected to me that clearing this folder could have any impact on the compilation process. The contents of the folder are fairly specific to the GUI aspects of the IDE, whereas the error was from a process ran by Arduino CLI, which doesn't use that folder at all. It is very odd.

@ptillisch

It seems to be unrelated to the delete of arduino-ide. I was planning to do the exercise again today but did not get that far yet.

However, this morning I made a change to my application, compiled for Mega and it was happy. Changed to Due and got the same error again as yesterday. Undid the change and it compiled for the Due. Implemented the change again and it still compiled for the Due :confused:

I hope that this gives you a little peace-of-mind with regards to your alternative solution :slight_smile:

Although I haven't done thorough testing, the below might help others to get rid of the double-tab.

I had a sketch (single ino file) with the dupicate tab. While reorganising I created a couple of ino files; I do not think that I populated them with content from the main ino file yet.

After that I did a reset of the workbench and the double tab disappeared. After removing the additional ino files, the double-tab issue did not occur.

Just confirming that creating and removing an additional INO tab solves the issue

  1. Sketch with single ino file showing with double tab.
  2. Create a new tab with an ino file.
  3. Reset workbench layout.

The duplicate tab for the main ino file disappeared

  1. Delete the additional ino file
  2. Reset workbench layout

The duplicate tab for the main ino file does not re-appear.