Bug: IDE lost libraries, won't allow them to be reinstalled

I resurrected an old project into IDE 2.3.2, got all the libraries etc working. Did some work on it over several days (had occasional issues with ports etc, sometimes had to restart IDE, but generally OK).

Then returned to it, and suddenly when I compile, the first include is reported missing.

Compilation error: M5EPD.h: No such file or directory

When I go to the libraries manager, it doesn't shows that this library is already installed (the button is "Install" not "Remove"). When I click install, it says that it needs three other libraries, including FastLED and M5GFX. I invite it to install all, with this result

Failed to install library: 'M5EPD:0.1.5'.
Error: 2 UNKNOWN: destination dir /private/var/folders/y7/gddpm8ys0892ztpvq78knn2m0000gq/T/.arduinoIDE-unsaved2022826-26353-1cgw79.mn6nl/sketch_sep26a/libraries/FastLED already exists, cannot install

(Note - "sketch_sep26a" is not the sketch I have open and am trying to compile.)

I look for FastLED, there are a number of libraries, none of them marked as installed.

I decide to try installing another of the dependencies, M5GFX, by itself. It's not marked as installed. Result is:

Failed to install library: 'M5GFX:0.1.16'.
Error: 2 UNKNOWN: destination dir /private/var/folders/y7/gddpm8ys0892ztpvq78knn2m0000gq/T/.arduinoIDE-unsaved2022826-26353-1cgw79.mn6nl/sketch_sep26a/libraries/M5GFX already exists, cannot install

I solved the problem by deleting all the '.arduinoIDE-unsaved*' folders from the '/private/var...' folder listed above. Then restarted the IDE and was able to install the required libraries for my actual sketch.

Hi @KellyLH. When you select Arduino IDE > Settings... from the Arduino IDE menus, what path do you see in the "Sketchbook location" folder preference?

Library Manager installs libraries to the libraries subfolder of the sketchbook folder. By default, the sketchbook folder is at this path:

/Users/<username>/Documents/Arduino

(Where <username> is your macOS username)

So we would expect the "FastLED" library to be installed here:

/Users/<username>/Documents/Arduino/libraries/FastLED

But the path mentioned in the error message is at a completely different location:

/private/var/folders/y7/gddpm8ys0892ztpvq78knn2m0000gq/T/.arduinoIDE-unsaved2022826-26353-1cgw79.mn6nl/sketch_sep26a/libraries/FastLED

Of course, you are free to configure another location for a sketchbook folder, in which case we would expect to see a different path in the error message. However this implies that you configured the sketchbook folder to be inside the temporary folder where Arduino IDE staged the unsaved sketch named "sketch_sep26a". That is a very odd location to configure the sketchbook for. It might be that some characteristic of this path (I'm not very knowledgeable about the macOS file system) is the cause of the unexpected library installation error.