ESPUI icon indicating copy to clipboard operation
ESPUI copied to clipboard

When compiling: LITTLEFS.h: No such file or directory

Open funktionierbar opened this issue 2 years ago • 10 comments

Describe the bug The Arduino IDE fails to compile a project using the ESPUI library.

To Reproduce Steps to reproduce the behavior:

  1. Install ESPUI library 2.1.0 in the Library manager in Arduino IDE 1.8.15
  2. included it in my project
  3. fails to compile.

Expected behavior Compile without errors.

Screenshots /home/acnct/snap/arduino/current/Arduino/libraries/ESPUI/src/ESPUI.h:14:10: fatal error: LITTLEFS.h: No such file or directory #include <LITTLEFS.h> ^~~~~~~~~~~~

Desktop (please complete the following information):

  • OS: Kubuntu 20.04
  • ESPUI library 2.1.0
  • esp32 board collection by espressif Systems 2.0.2
  • Arduino IDE 1.8.15
  • Wemos Lolin D32 Pro Board V2.0

Additional context I searched the library folders, and I suspected this to be some kind of capitalization error. All the files that seem correct are called LittleFS and not LITTLEFS as called. But the code in ESPUI.h specifically states the LITTLEFS ist the correct one for the ESP32, so I am wary to just correct the capitalization manually. Can you give me a hint as to whats the difference between LITTLEFS and LittleFS?

funktionierbar avatar Feb 03 '22 17:02 funktionierbar

Hi,

As the documentation notes,

This library is dependent on the following libraries.
    ESPAsyncWebserver
    ArduinoJson
    (For ESP8266) ESPAsyncTCP
    (For ESP32) AsyncTCP
    (For ESP32) lorol/LittleFS_esp32

So the one you need in the Arduino IDE is "LittleFS_esp32":

Screenshot 2022-02-03 at 17 24 08

LittleFS has recently been moved into ESP core so it won't be needed soon as a separate dependency, once someone gets around to the necessary refactor.

iangray001 avatar Feb 03 '22 17:02 iangray001

I searched the library folders, and I suspected this to be some kind of capitalization error. All the files that seem correct are called LittleFS and not LITTLEFS as called. But the code in ESPUI.h specifically states the LITTLEFS ist the correct one for the ESP32, so I am wary to just correct the capitalization manually. Can you give me a hint as to whats the difference between LITTLEFS and LittleFS?

LITTLEFS is the library used by ESP32 builds and LittleFS is used by ESP8266 builds. The library that is used is automatically chosen by the board you have entered in Arduino IDE Tool->boards manager. Since your build is complaining that LITTLEFS is missing then that means you need to install the library, per iangray001.

FWIW, up until yesterday I was using LITTLEFS on my ESPUI project. After several days of hair pulling I found that serving the web files from LITTLEFS was the cause to random ESP32 crashes during a browser refresh. Switching back to embedded files has solved the problem 100%. However, I'm still able to safely use LITTLEFS to store the system configuration and png images used by ESPUI.

I have not done an investigation on why ESPUI's use of LITTLEFS causes a crash. I won't be able to revisit this until after my project is complete. If you end up using LITTLEFS then be sure to test your finished program by doing a lot of web page refreshes (or page re-visits) from different browsers.

  • Thomas

thomastech avatar Feb 03 '22 19:02 thomastech

Thanks for your hints, I missed that dependecy.

Unfortunately the LITTLEFS library then gives me a different error on compiling, and they state they dont take issues anymore.

/home/xxxxxx/snap/arduino/current/Arduino/libraries/LITTLEFS-master/src/LITTLEFS.cpp: In member function 'virtual bool LITTLEFSImpl::exists(const char*)':

/home/xxxxxx/snap/arduino/current/Arduino/libraries/LITTLEFS-master/src/LITTLEFS.cpp:44:28: error: no matching function for call to 'LITTLEFSImpl::open(const char*&, const char [2])'

File f = open(path, "r"); ^

My programming skills are not good enough to help with the refactor, unfortunately.

funktionierbar avatar Feb 03 '22 19:02 funktionierbar

I'm using Platformio so I'm not much help with Arduino IDE issues.

My only suggestion: After installing the new Arduino library, be sure to exit the IDE and then relaunch. This will re-sync library dependencies.

  • Thomas

thomastech avatar Feb 03 '22 19:02 thomastech

Yes I also dislike the Arduino IDE and don't use it. I'll break it out and have a look when I get a chance, in order to see what is going on, but I can confirm that everything works fine in PlatformIO.

As I say, ideally we'll remove the dependency on the library entirely. I'll bump this to the top of my list for when I get some time.

iangray001 avatar Feb 04 '22 11:02 iangray001

I think I found the error and will now no longer misuse this issue for problems of another library ;)

I will just document what I did if somebody runs into the same error. What gave it away was another note in the compile log

/home/xxxxx/snap/arduino/61/.arduino15/packages/esp32/hardware/esp32/2.0.2/libraries/FS/src/vfs_api.h:38:17: note: candidate: 'virtual fs::FileImplPtr VFSImpl::open(const char*, const char*, bool)' FileImplPtr open(const char* path, const char* mode, const bool create) override; ^~~~ /home/xxxxx/snap/arduino/61/.arduino15/packages/esp32/hardware/esp32/2.0.2/libraries/FS/src/vfs_api.h:38:17: note: candidate expects 3 arguments, 2 provided

in the LITTLEFS.cpp file the LITTLEFSImpl::exists() function calls an open() function thats defined in the abovementioned vfs_api of the core. This open() function wants 3 arguments. I looked for the same call in the LittleFS.cpp of the core, and it calls open with a false as third argument. So I changed the LITTLEFS.cpp accordingly, and it worked. I have no Idea what the false does, but at least I can compile the libraries.

Solution: change LITTLEFS.cpp Line 42-46 like this: bool LITTLEFSImpl::exists(const char* path) { File f = open(path, "r", false); return (f == true); }

funktionierbar avatar Feb 04 '22 11:02 funktionierbar

I have no Idea what the false does, but at least I can compile the libraries.

I chased down this little oddity. Seems a recent PR added the third Arg to the FS library {added bool flag for creating a new folder}. I checked my Arduino installation and my installed FS library does not have this PR. My FS library is from Mar 2021, before the third arg was added.

Long story short, your impromptu patch seems legit.

  • Thomas

thomastech avatar Feb 04 '22 17:02 thomastech

ESP32 core now includes "LittleFS" so you don't need a seperate "LITTLEFS" library. If you remove all the #if defined(ESP32) statements and replace all instances of LITTLEFS with LittleFS the library compiles.

beachmiles avatar Aug 09 '22 22:08 beachmiles

hello,

to fix it quickly with platformio.ini, i setup like this the project ` build_flags = -DLITTLEFS=LittleFS

lib_deps = Wifi Wire SPI FS LittleFS ESPAsyncTCP ESP Async WebServer ESPUI `

manoukianv avatar Aug 20 '22 09:08 manoukianv

This is fixed in me current PR.

MartinMueller2003 avatar Sep 22 '22 13:09 MartinMueller2003