avr/io.h no such file or directory with the library of jm_wire

Hi recently encounter a problem where I am using the esp28666 nodemcu lua v2 2 to program a youtube live subscriber counter, however upon uploading I get an error saying

Arduino: 1.8.5 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

C:\Users\user1\Documents\Arduino\libraries\jm_Wire\src\utility\jm_twi.c:25:20: fatal error: avr/io.h: No such file or directory

#include <avr/io.h>

^

compilation terminated.

exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Is there a solution to this issue, please help.

That error indicates that the jm_wire library is written for use with the AVR architecture (e.g. Uno, Leonardo, Mega, Nano, etc.). It can't be used with ESP8266.

If compatibility is the issue then I conclude that "No such file or directory" error code is very misleading. Perhaps "Board selected is not compatible with AVR library".

It can easily be accomplished:

#ifndef __AVR__
#error This library only supports the AVR architecture
#endif
#include <avr/io.h>

But what happens if you are compiling for a non-AVR architecture that has added an avr/io.h file for compatibility with code written for AVR? Now compilation fails unnecessarily. One example of this is Arduino SAMD Boards, which does have avr/io.h even though it's not AVR architecture. And you can't use #warning because the warning will never be shown if a file not found error is encountered. I could add a SAMD boards specific macro to the conditional but I have no way of knowing all the possible packages now or in the future that have to be "whitelisted" from this error.

There actually is a feature of the Arduino IDE that displays a warning when compiling for an architecture that is not specified by the library's library.properties file but unfortunately that warning is not displayed after a file not found error. I have reported this issue here:

Hopefully it will be fixed soon.