Fatal error: avr/io.h: No such file or directory

is there any chance that you could help me with a similar problem? My error message is

In file included from C:\Users\Oscar\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Arduino.h:28:0,
                 from C:\Users\Oscar\AppData\Local\arduino\sketches\38DDA74554AB4CFF65BBA1E1B35761E3\sketch\sketch_jan28a.ino.cpp:1:
c:\users\oscar\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\pgmspace.h:90:10: fatal error: avr/io.h: No such file or directory
 #include <avr/io.h>
          ^~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: exit status 1
In file included from C:\Users\Oscar\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Arduino.h:28:0,
                 from C:\Users\Oscar\AppData\Local\arduino\sketches\38DDA74554AB4CFF65BBA1E1B35761E3\sketch\sketch_jan28a.ino.cpp:1:
c:\users\oscar\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\pgmspace.h:90:10: fatal error: avr/io.h: No such file or directory
 #include <avr/io.h>
          ^~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: exit status 1

Hello oscar-c

Your question has been split from another topic; please do not hijack existing topics.

ok, sorry.

i have gone through all of the troubleshooting steps in the original post but i still have the same result. any fixes?

I suspect a corrupt installation of the AVR board package.

To verify, please post your sketch. Don't forget to use code tags as described in https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#use-code-tags.

Which board are you compiling for? Uno?

Yes

// C++ code
//
int Red = 0;

int Orange = 0;

int Green = 0;

void setup()
{
  pinMode(5, OUTPUT);
  pinMode(8, INPUT);
  pinMode(12, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);

  digitalWrite(5, HIGH);
}

void loop()
{
  if (digitalRead(8) == LOW) {
    digitalWrite(12, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(5, LOW);
    delay(6000); // Wait for 6000 millisecond(s)
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    delay(2000); // Wait for 2000 millisecond(s)
    digitalWrite(4, LOW);
    digitalWrite(5, HIGH);
  } else {
    digitalWrite(12, LOW);
  }
}

OK

Your sketch compiles here for an Uno R3; IDE 2.3.4 on Windows.

I suggest that you use board manager in the IDE and downgrade the AVR board package from version 1.8.6 to 1.8.3. Test if it works; and next upgrade to 1.8.6 again.

How would I do that ( sorry I’m quite new to arduino)

Never mind, I figured it out, it still doesn’t work

the first contradicts the second...
Could you dive more in detail?

I figured out how to downgrade the firmware, tested it ( it didn’t work ) upgraded it again and it still didn’t work

Any other possible solutions?

You don't need any solution, your code is correct.
Just re-install the IDE right way.

What is your exact Arduino board - Uno R3 or Uno R4?

R3 ( I’m pretty sure )

Why do you ask @b707 ?

Uno R4 has a different hardware architecture to Uno R3. Uno R4 does not have avr/io.h, because it is not AVR architecture.

@b707 @sterretje re-installing the ide did not change a thing. any other ideas?

Not really.

Can you find the file io.h in Windows explorer? It should be in the following directories:
C:\Users\yourUsername\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr
and
C:\Users\bugge\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr

Running antivirus software? Check the AV logs, it might have, for unknown reason, quarantined it.

nope nothing. is there any chance that it could be my laptop @sterretje?

I do not know if it might be something on your laptop.

The only thing that I can think of is re-installing. I know you did this already but I do not know if you did clean out all additional directories; this article contains all directories that are involved: https://support.arduino.cc/hc/en-us/articles/4415103213714-Find-sketches-libraries-board-cores-and-other-files-on-your-computer#boards

I would also download a clean copy of the IDE from https://www.arduino.cc/en/software just in case your current one is corrupt for some reason.