The Arduino is getting an error while compiling for Arduino Uno.

Hi Here is my code to use the Gravity pH sensor:

#define SensorPin 0          
unsigned long int avgValue;  
float b;
int buf[10], temp;

void setup()
{
  pinMode(13, OUTPUT);
  Serial.begin(9600);
  Serial.println("Ready");    
}
void loop()
{
  for (int i = 0; i < 10; i++) 
  {
    buf[i] = analogRead(SensorPin);
    delay(10);
  }
  for (int i = 0; i < 9; i++) 
  {
    for (int j = i + 1; j < 10; j++)
    {
      if (buf[i] > buf[j])
      {
        temp = buf[i];
        buf[i] = buf[j];
        buf[j] = temp;
      }
    }
  }
  avgValue = 0;
  for (int i = 2; i < 8; i++)               
    avgValue += buf[i];
  float phValue = (float)avgValue * 5.0 / 1024 / 6; 
  phValue = 3.5 * phValue;                  
  Serial.print("    pH:");
  Serial.print(phValue, 2);
  Serial.println(" ");
  digitalWrite(13, HIGH);
  delay(800);
  digitalWrite(13, LOW);

}

But then, when I try to upload, I get this error:
Arduino: 1.8.11 (Mac OS X), Board: "Arduino Uno"

fork/exec /Users/shivpatel/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-g++: no such file or directory
Error compiling for board Arduino Uno.

Does anybody know how to fix this?! Thank you!!!!

-Shiv

The posted code compiles fine for me. No warnings no errors. Uno, Win10, IDE ver 1.8.5. I have read (more than once) that 1.8.10 and 1.8.11 are having problems. Might want to roll back to 1.8.9 (or older) till the issues are resolved.

This error indicates you need to take some drastic action. Be aware this will uninstall any boards you have installed via Boards Manager:

  • (In the Arduino IDE) File > Preferences
  • In the Arduino IDE, click the link on the line following "More preferences can be edited directly in the file". This will open the Arduino15 (or similar name depending on OS) folder.
  • Delete all files and folders under the Arduino15 folder except for preferences.txt. Please be very careful when deleting things from your computer. When in doubt, back up!
  • Restart the Arduino IDE

Verify that you can now use your board before reinstalling any packages via Boards Manager.