# Arduino IDE 2.0.3 Duplicate TAB page

**URL:** <https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561>\
**Category:** IDE 2.x\
**Created:** [January 31, 2023, 10:45am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561 "2023-01-31T10:45:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gilbert54](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gilbert54/32/649201_2.png) [@gilbert54](https://forum.arduino.cc/u/gilbert54)\
**Post date:** [January 31, 2023, 10:45am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/1 "2023-01-31T10:45:08Z")

</div>

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](https://europe1.discourse-cdn.com/arduino/original/4X/9/d/e/9de54d0fe8055a1ed2910210faff69546661758e.png)

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [January 31, 2023, 10:48am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/2 "2023-01-31T10:48:49Z")

</div>

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

> <https://github.com/arduino/arduino-ide/issues/1791>
>
> \### Describe the problem
> 
> I included a library via the menu and somehow this r…esulted in another tab opening for the same file. When I try to delete the file nothing happens. I've tried to move the sketch to some other folder and then open and that seems to work (after it renames the parent folder), but when I move it back to the original folder the new tab reappears.
> 
> I'm on Ubuntu 22.04.1 LTS and the latest stable version of the IDE shown on the website at the time of writing (2.0.3). I also tested on the latest nightly and it occurs there too.
> 
> If you need log files or something, please let me know.
> 
> !\[image\](https://user-images.githubusercontent.com/31189070/209982612-ecc4ae19-0ac0-40a7-87c3-f10fe0d66655.png)
> 
> 
> \### To reproduce
> 
> I tried reproducing and couldn't. But the issue is still there, even when I open the project on the nightly build.
> 
> \### Expected behavior
> 
> Delete closes the tab. Or closing and reopening the ediitor...
> 
> \### Arduino IDE version
> 
> 2.04-nightly-20221229
> 
> \### Operating system
> 
> Linux
> 
> \### Operating system version
> 
> 22.04.1 LTS
> 
> \### Additional context
> 
> The fact that this occurs across builds and after moving things around makes me think this has something to do with some kind of cache or (sketch?) settings file somewhere, but I don't know for sure.
> 
> I also remember the save icon being on briefly. I have autosave on, so I'm not sure if this happened before or after the library was included.
> 
> \---
> 
> Additional reports:
> 
> \- https://github.com/arduino/arduino-ide/issues/656#issuecomment-1363100279
> \- https://forum.arduino.cc/t/ide-restarts-during-a-start/1081761
> - Includes screencast and logs
> \- https://forum.arduino.cc/t/ide-2-0-3-double-tabs/1066585/1
> \- https://forum.arduino.cc/t/ide-2-0-3-double-tabs/1066585/2
> \- https://forum.arduino.cc/t/ide-2-0-3-double-tabs/1066585/3
> \- https://forum.arduino.cc/t/new-year-new-problems/1072182
> \- https://arduino.stackexchange.com/questions/91777/how-to-get-rid-of-the-second-tab-in-arduino-ide-2
> 
> \---
> 
> Related:
> 
> \- Previous incarnations of the duplicate tab bug (resolved:
> - Issues:
> - https://github.com/arduino/arduino-ide/issues/1054
> - https://github.com/arduino/arduino-ide/issues/793
> - https://github.com/arduino/arduino-ide/issues/665
> - https://github.com/arduino/arduino-ide/issues/656
> - PRs:
> - https://github.com/arduino/arduino-ide/pull/1085
> - https://github.com/arduino/arduino-ide/pull/1024
> - https://github.com/arduino/arduino-ide/pull/1012
> \- https://github.com/arduino/arduino-ide/issues/482
> - This bug produces a similar fault, but is otherwise unrelated.
> 
> \### Issue checklist
> 
> \- \[X\] I searched for previous reports in \[the issue tracker\](https://github.com/arduino/arduino-ide/issues?q=)
> \- \[X\] I verified the problem still occurs when using the latest \[nightly build\](https://www.arduino.cc/en/software#nightly-builds)
> \- \[X\] My report contains all necessary details

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.

---

<div class="post-metadata">

**Author:** ![gilbert54](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gilbert54/32/649201_2.png) [@gilbert54](https://forum.arduino.cc/u/gilbert54)\
**Post date:** [January 31, 2023, 10:57am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/3 "2023-01-31T10:57:11Z")

</div>

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](https://europe1.discourse-cdn.com/arduino/original/4X/6/0/d/60d2cb781afd7fad649e68c050340f39342b89f0.png)

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [January 31, 2023, 11:23am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/4 "2023-01-31T11:23:24Z")

</div>

> [@gilbert54](#):
>
> Doesn't work here.

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](https://forum.arduino.cc/uploads/short-url/zgFhvWuBxz3BvDoGmMzuWfSIjx7.zip) (55.8 KB)

---

<div class="post-metadata">

**Author:** ![gilbert54](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gilbert54/32/649201_2.png) [@gilbert54](https://forum.arduino.cc/u/gilbert54)\
**Post date:** [January 31, 2023, 12:12pm UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/5 "2023-01-31T12:12:12Z")

</div>

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](https://github.com/Seeed-Studio/Seeed_Arduino_CAN)) to support their CAN shield ([CAN-BUS Shield V2.0 - Seeed Wiki](https://wiki.seeedstudio.com/CAN-BUS_Shield_V2.0/)) 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.

---

<div class="post-metadata">

**Author:** ![gilbert54](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gilbert54/32/649201_2.png) [@gilbert54](https://forum.arduino.cc/u/gilbert54)\
**Post date:** [January 31, 2023, 12:15pm UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/6 "2023-01-31T12:15:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [January 31, 2023, 12:28pm UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/7 "2023-01-31T12:28:56Z")

</div>

> [@gilbert54](#):
>
> Doesn't work here.

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.

---

<div class="post-metadata">

**Author:** ![gilbert54](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gilbert54/32/649201_2.png) [@gilbert54](https://forum.arduino.cc/u/gilbert54)\
**Post date:** [January 31, 2023, 12:33pm UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/8 "2023-01-31T12:33:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [January 31, 2023, 12:43pm UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/9 "2023-01-31T12:43:47Z")

</div>

> [@gilbert54](#):
>
> 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.

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:

> <https://github.com/arduino/arduino-cli/issues/1008>
>
> \### Describe the problem
> 
> Compiler warnings for code from non-\`.ino\` source fi…les are not shown on subsequent sketch compilations.
> 
> \### To reproduce
> 
> When someone writes code like this (see below) he will correctly get two identical warnings: 
> \*\*\`"warning: deprecated conversion from string constant to 'char\*' \[-Wwrite-strings\]"\`\*\*
> 
> When one compiles it again the warnings will all \*\*disappear\*\* so the user (me) thinks he is perfectly fine and writing clean code. 
> 
> \*\*FunFact:\*\* This will \*\*not\*\* happen if all code is written to the main (.ino) file.
> 
> File \`DummyClass.h\`:
> 
> \`\`\` C++
> class DummyClass
> {
> public:
> char\* getString();
> 
> char\* getSecondString();
> };
> \`\`\`
> 
> File \`DummyClass.cpp\`:
> 
> \`\`\` C++
> char\* DummyClass::getString()
> {
> return "Some String";
> }
> 
> char\* DummyClass::getSecondString()
> {
> return "Some other string";
> }
> \`\`\`
> 
> File \`test.ino\`:
> 
> \`\`\` C++
> \#include "DummyClass.h"
> DummyClass dummy;
> 
> void setup()
> {
> Serial.begin(115200);
> }
> void loop()
> {
> Serial.println(dummy.getString());
> delay(1000);
> }
> \`\`\`
> 
> \### Expected behavior
> 
> Compiler warnings are shown every time the sketch is compiled if the code would produce a warning.
> 
> \### Arduino CLI version
> 
> 60a8aa96c725d0ebce9bbe4586013908669f14ff
> 
> \### Operating system
> 
> All
> 
> \### Operating system version
> 
> Any
> 
> \### Additional context
> 
> \#### Additional reports
> 
> \- https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/5
> \- https://forum.arduino.cc/t/warning-disappears-after-second-compilation/1139615
> 
> \#### Related
> 
> \- https://github.com/arduino/arduino-cli/issues/2204
> 
> \### Issue checklist
> 
> \- \[X\] I searched for previous reports in \[the issue tracker\](https://github.com/arduino/arduino-cli/issues?q=)
> \- \[X\] I verified the problem still occurs when using the \[nightly build\](https://arduino.github.io/arduino-cli/dev/installation/#nightly-builds)
> \- \[X\] My report contains all necessary details

> [@gilbert54](#):
>
> 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...

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

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [January 31, 2023, 1:02pm UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/10 "2023-01-31T13:02:18Z")

</div>

> [@gilbert54](#):
>
> don't waste too much time trying to reproduce it

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.

> [@gilbert54](#):
>
> I'm working on WIN 10 (version 22H2).

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:

```plaintext
C:\Users\<username>\AppData\Roaming\arduino-ide\

```

(where `<username>` is your Windows username)  
⚠ 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.

---

<div class="post-metadata">

**Author:** ![Willem43](https://avatars.discourse-cdn.com/v4/letter/w/ea5d25/32.png) [@Willem43](https://forum.arduino.cc/u/Willem43)\
**Post date:** [February 1, 2023, 8:52am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/11 "2023-02-01T08:52:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [February 1, 2023, 9:49am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/12 "2023-02-01T09:49:26Z")

</div>

> [@ptillisch](#):
>
> Please let me know how it goes.

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

```arduino
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)

```arduino
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

```

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [February 1, 2023, 3:05pm UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/13 "2023-02-01T15:05:28Z")

</div>

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 😢 I've put the backup back; rather live with the enemy that you know than the friend that you don't know 😃

```cpp
...
...
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

```

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [February 2, 2023, 4:27am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/14 "2023-02-02T04:27:45Z")

</div>

> [@sterretje](#):
>
> However (and this is only a FYI, no request for help), after restarting the IDE
> 
> ```plaintext
> 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
> 
> ```

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?](https://forum.arduino.cc/t/failed-precondition/1048344)), 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:

> <https://github.com/arduino/arduino-cli/issues/1802>
>
> \### Describe the problem
> 
> \[The Arduino CLI daemon\](https://arduino.github.io/a…rduino-cli/dev/commands/arduino-cli\_daemon/) scans the installed libraries when a gRPC client instance is \[initialized\](https://arduino.github.io/arduino-cli/dev/rpc/commands/#initrequest). Library installation operations are based on the data from the scan. 
> 
> The data from this scan will not be accurate if any of the following has occurred after a scan:
> 
> \- Manual changes to library installations
> \- Installations made via \[the \`cc.arduino.cli.commands.v1.ArduinoCoreService.ZipLibraryInstall\` method\](https://arduino.github.io/arduino-cli/dev/rpc/commands/#ziplibraryinstallrequest)
> \- Installations made via \[the \`cc.arduino.cli.commands.v1.ArduinoCoreService.GitLibraryInstall\` method\](https://arduino.github.io/arduino-cli/dev/rpc/commands/#gitlibraryinstallrequest)
> 
> The first two are not uncommon for the user to do.
> 
> 🐛 The result of library installation operations may be incorrect due to the libraries on disk not matching the internal data.
> 
> \### To reproduce
> 
> \#### Set up
> 
> \`\`\`text
> $ arduino-cli version
> arduino-cli.exe Version: 0.25.0-rc1 Commit: 63b53c0f Date: 2022-07-12T01:46:05Z
> 
> $ export ARDUINO\_DIRECTORIES\_USER="/tmp/arduino-cli-directories-user" # Use a clean directories.data for demo
> 
> $ arduino-cli daemon
> \`\`\`
> 
> \#### Demo
> 
> Use \[grpcurl\](https://github.com/fullstorydev/grpcurl) to run the following commands in another terminal:
> 
> \`\`\`text
> $ grpcurl \\
> -plaintext \\
> -import-path ./rpc \\
> -proto cc/arduino/cli/commands/v1/commands.proto \\
> 127.0.0.1:50051 \\
> cc.arduino.cli.commands.v1.ArduinoCoreService.Create
> 
> {
> "instance": {
> "id": 1
> }
> }
> 
> $ grpcurl \\
> -plaintext \\
> -import-path ./rpc \\
> -proto cc/arduino/cli/commands/v1/commands.proto \\
> -d '{"instance": {"id": 1}}' \\
> 127.0.0.1:50051 \\
> cc.arduino.cli.commands.v1.ArduinoCoreService.Init
> 
> $ export ARDUINO\_DIRECTORIES\_USER="/tmp/arduino-cli-directories-user"
> 
> $ arduino-cli lib install SD@1.2.3 # Change the libraries after Arduino CLI gRPC initialization
> 
> $ grpcurl \\
> -plaintext \\
> -import-path ./rpc \\
> -proto cc/arduino/cli/commands/v1/commands.proto \\
> -d '{"instance": {"id": 1}, "name": "SD", "version": "1.2.4"}' \\
> 127.0.0.1:50051 \\
> cc.arduino.cli.commands.v1.ArduinoCoreService.LibraryInstall
> 
> ERROR:
> Code: Unknown
> Message: destination dir C:\\Users\\per\\AppData\\Local\\Temp\\arduino-cli-directories-user\\libraries\\SD already exists, cannot install
> 
> $ grpcurl \\
> -plaintext \\
> -import-path ./rpc \\
> -proto cc/arduino/cli/commands/v1/commands.proto \\
> -d '{"instance": {"id": 1}}' \\
> 127.0.0.1:50051 \\
> cc.arduino.cli.commands.v1.ArduinoCoreService.Init
> 
> $ grpcurl \\
> -plaintext \\
> -import-path ./rpc \\
> -proto cc/arduino/cli/commands/v1/commands.proto \\
> -d '{"instance": {"id": 1}, "name": "SD", "version": "1.2.4"}' \\
> 127.0.0.1:50051 \\
> cc.arduino.cli.commands.v1.ArduinoCoreService.LibraryInstall
> 
> {
> "taskProgress": {
> "name": "Downloading SD@1.2.4"
> }
> }
> {
> "progress": {
> "file": "SD@1.2.4",
> "completed": true
> }
> }
> {
> "taskProgress": {
> "completed": true
> }
> }
> {
> "taskProgress": {
> "name": "Installing SD@1.2.4"
> }
> }
> {
> "taskProgress": {
> "message": "Replacing SD@1.2.3 with SD@1.2.4"
> }
> }
> {
> "taskProgress": {
> "message": "Installed SD@1.2.4",
> "completed": true
> }
> }
> {
> 
> }
> \`\`\`
> 
> 🐛 The library installation failed incorrectly due to the Arduino CLI gRPC daemon not being aware of the change that occurred externally. It was necessary to reinitialize the instance in order to make it behave correctly.
> 
> \### Expected behavior
> 
> Libraries are re-scanned at the start of every library installation operation.
> 
> \### Arduino CLI version
> 
> 0.25.0-rc1 Commit: 63b53c0f
> 
> \### Operating system
> 
> Windows
> 
> \### Operating system version
> 
> 10
> 
> \### Additional context
> 
> This is a similar problem to https://github.com/arduino/arduino-cli/issues/1755. However, it was not introduced by the commit reported there.
> 
> \### Issue checklist
> 
> \- \[X\] I searched for previous reports in \[the issue tracker\](https://github.com/arduino/arduino-cli/issues?q=)
> \- \[X\] I verified the problem still occurs when using the \[nightly build\](https://arduino.github.io/arduino-cli/dev/installation/#nightly-builds)
> \- \[X\] My report contains all necessary details

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.

> [@sterretje](#):
>
> ```plaintext
> 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
> 
> ```

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:

> <https://github.com/arduino/arduino-ide/issues/798>
>
> \*\*Describe the bug\*\*
> When I first installed I believe RC2 or 3 but for sure wit…h Nightly build and started testing with the first versions of the
> Teensy installs, I found I could no longer build some of the sketches I was working on.  
> 
> I traced it down to the first run of the IDE, overwrote my existing libraries in my \<sketch folder\>/libraries
> and replaced the version I was working on. 
> 
> In my Particular case it was the SD library. My current one was our current Github fork/branch of SD which is a thin wrapper to call off to the SDFat library. 
> 
> Note: In my case, it was actually a symbolic link to where I keep all my sources
> On my Windows machine I created this using: mklink /D SD d:\\github\\SD
> 
> Note: This also reproduced on my Ubuntu machine as well.
> 
> \*\*To Reproduce\*\*
> Steps to reproduce the behavior:
> 
> Have some custom version of SD in your \<Sketch folder\>/libraries/SD
> Install IDE 2 
> run the IDE
> 
> Also found that this will reproduce if you are having the issue, that updates in your tools.txt or tools.local.txt are not showing up as mentioned in:
> https://github.com/arduino/arduino-cli/issues/1614
> And you delete the directory
> \`\`\`
> C:\\Users\\\<user name\>\\AppData\\Roaming\\arduino-ide\\
> \`\`\`
> 
> And restart the IDE.
> 
> I noticed in the output window:
> \`\`\`
> Downloading LiquidCrystal@1.0.7
> Installing LiquidCrystal@1.0.7
> Already installed LiquidCrystal@1.0.7
> ...
> Downloading SD@1.2.4
> Installing SD@1.2.4
> Replacing SD@2.0.0 with SD@1.2.4
> ...
> \`\`\`
> 
> Notice it says it replaced SD and sure enough it did
> 
> \*\*Expected behavior\*\*
> I would expect it to leave alone user libraries, especially ones marked with a higher version number
> 
> \*\*Screenshots\*\*
> 
> \*\*Desktop (please complete the following information):\*\*
> - OS: Windows
> - Version: 10
> - OS: Ubuntu
> - Version: 20.0.4
> 
> \*\*Additional context\*\*

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:

> <https://github.com/arduino/arduino-ide/pull/1169>
>
> \### Motivation
> The first time the IDE is launched, it has a mechanism in place …to automatically install the most common libraries and platforms, in order to deliver a better out-of-the-box experience for a majority of users.
> Right now though, this process would \[overwrite libraries and platforms\](#798) that were previously installed by the user.
> 
> 
> \### Change description
> \- when installing libraries and platforms \_at first start-up\_, use the \`--no-overwrite\` flag of the arduino-cli 
> \- \[refactor\] move the code that manages the initialization of these libraries to a new contribution.
> 
> \### Other information
> 
> 
> \### Reviewer checklist
> 
> \* \[\] PR addresses a single concern.
> \* \[\] The PR has no duplicates (please search among the \[Pull Requests\](https://github.com/arduino/arduino-ide/pulls) before creating one)
> \* \[\] PR title and description are properly filled.
> \* \[\] Docs have been added / updated (for bug fixes / features)

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:

> <https://github.com/arduino/arduino-ide/issues/1055>
>
> \### Describe the request
> 
> Use a dedicated location for the "built-in" library …installations, with a lower location priority than \[platform bundled libraries\](https://arduino.github.io/arduino-cli/latest/platform-specification/#platform-bundled-libraries).
> 
> 🙂 Library dependency resolution will match the behavior of Arduino IDE 1.x
> 
> \### Describe the current behavior
> 
> In order to allow users to get started with Arduino with the minimum amount of complexity, the Arduino IDE 1.x installation comes with \[a collection\](https://github.com/arduino/Arduino/blob/1.8.19/build/build.xml#L254-L274) of fundamental Arduino libraries (e.g., \[Keyboard\](https://github.com/arduino-libraries/Keyboard), \[Mouse\](https://github.com/arduino-libraries/Mouse), \[Servo\](https://github.com/arduino-libraries/Servo)) pre-installed. Even experienced users now expect these libraries to be available by default, and many tutorials (both official and 3rd party) have been written based on that assumption. So it is important that Arduino IDE 2.x also provide these libraries.
> 
> In order to simplify the Arduino IDE packaging process and ensure users are provided with the newest available, the Arduino Library Manager infrastructure is currently used to install the libraries the first time the Arduino IDE is started (https://github.com/arduino/arduino-ide/pull/663).
> 
> Library Manager installs these libraries to the sketchbook folder. Libraries at this location have a higher \["location priority"\](https://arduino.github.io/arduino-cli/latest/sketch-build-process/#location-priority) than they did when bundled with the Arduino IDE installation.
> 
> 🙁 This priority increase can cause the "built-in" library to now be selected by the Arduino sketch build process in a case where a platform bundled library would have been selected when using Arduino IDE 1.x.
> 
> \### Arduino IDE version
> 
> 2.0.0-rc7
> 
> \### Operating system
> 
> All
> 
> \### Operating system version
> 
> N/A
> 
> \### Additional context
> 
> This would also provide an alternative solution to https://github.com/arduino/arduino-ide/issues/798
> 
> \### Issue checklist
> 
> \- \[X\] I searched for previous requests in \[the issue tracker\](https://github.com/arduino/arduino-ide/issues?q=)
> \- \[X\] I verified the feature was still missing when using the latest \[nightly build\](https://github.com/arduino/arduino-ide#nightly-builds)
> \- \[X\] My request contains all necessary details

After that was implemented, the "no overwrite" fix implemented in [`arduino/arduino-ide#1169`](https://github.com/arduino/arduino-ide/pull/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`](https://github.com/arduino/arduino-ide/pull/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.

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [February 2, 2023, 4:32am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/15 "2023-02-02T04:32:35Z")

</div>

> [@sterretje](#):
>
> the cleanup

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

> [@sterretje](#):
>
> the backup

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?

> [@sterretje](#):
>
> without any sensible error message in the IDE

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

> <https://github.com/arduino/arduino-cli/pull/2017>
>
> ctags can fail, for example if TMPDIR is unset. It aids debugging to show the st…derr with -v if that's the case

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

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [February 2, 2023, 7:37am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/16 "2023-02-02T07:37:25Z")

</div>

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 😉)

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [February 2, 2023, 9:19am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/17 "2023-02-02T09:19:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [February 3, 2023, 4:58am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/18 "2023-02-03T04:58:58Z")

</div>

@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 😕

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

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [February 17, 2023, 9:53am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/19 "2023-02-17T09:53:54Z")

</div>

> [@sterretje](#):
>
> I've also noticed that it no longer works or no longer works reliably.

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.

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [February 25, 2023, 3:55am UTC](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561/20 "2023-02-25T03:55:11Z")

</div>

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.

[Next page](https://forum.arduino.cc/t/arduino-ide-2-0-3-duplicate-tab-page/1084561.md?page=2)
