Skip to content

"Compilation error: Error: 2 UNKNOWN: exit status 1" error message is unnecessarily cryptic #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TheAnton205 opened this issue Mar 1, 2021 · 21 comments · Fixed by #664
Assignees
Labels
conclusion: resolved Issue was resolved criticality: highest Of highest impact topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@TheAnton205
Copy link

Describe the bug
Any program I run and attempt to compile I get this error:

c:/users/anton/appdata/local/arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/../lib/gcc/avr/7.3.0/../../../../avr/lib/avr5/crtatmega328p.o:(.init9+0x0): undefined reference to `main'
collect2.exe: error: ld returned 1 exit status
Compilation error: Error: 2 UNKNOWN: exit status 1

  • I recently got the beta and no matter what I do I had this (yes I restarted my pc) and I even download the latest Git (2.30.1) 64-bit.

To Reproduce
Steps to reproduce the behavior:

  1. Open any code
  2. Click compile

Expected behavior
Expected for the code to compile.

Desktop (please complete the following information):

  • OS: Windows 10 Pro 64-bit
  • Version: 2.0.0-beta3

Additional context
This could be due to from when some notification occurred which I couldn't figure out what it was for. I do remember that it led to this link. However, I don't see this notification anymore?

@Pioxis
Copy link

Pioxis commented Mar 2, 2021

I have the same error. I installed first DallasTemperature library from library manager, and for OneWire library I do the same.

After that I tried compile code at the bottom of the page.
But it ending with Error 2 UNKNOWN: exit status 1.
After that I installed manually libraries from .zip archives. (that works for me for old IDE). The same error.

My OS is Ubuntu 20.10

#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#include <OneWire.h>

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Definicja wejść wyświetlacza ciekłokrystalicznego //definition of lcd output
LiquidCrystal lcd(4, 5, 6, 7, 8, 9);
void setup(void) {
  // Inicjacja czujnika //sensor initiation
  sensors.begin();
  // Inicjacja wyświetlacza //screen initiation
  lcd.begin(16, 2);
  lcd.clear();
}
void loop(void) {
  lcd.setCursor(0, 0);
  lcd.print("Temperatura:");
  lcd.setCursor(0, 1);
  sensors.requestTemperatures();
  lcd.print(sensors.getTempCByIndex(0));
  lcd.setCursor(6, 1);
  lcd.print("st.C");
  delay(1000);
} 

@TheAnton205
Copy link
Author

I have the same error. I installed first DallasTemperature library from library manager, and for OneWire library I do the same.

After that I tried compile code at the bottom of the page.
But it ending with Error 2 UNKNOWN: exit status 1.
After that I installed manually libraries from .zip archives. (that works for me for old IDE). The same error.

My OS is Ubuntu 20.10

#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#include <OneWire.h>

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Definicja wejść wyświetlacza ciekłokrystalicznego //definition of lcd output
LiquidCrystal lcd(4, 5, 6, 7, 8, 9);
void setup(void) {
  // Inicjacja czujnika //sensor initiation
  sensors.begin();
  // Inicjacja wyświetlacza //screen initiation
  lcd.begin(16, 2);
  lcd.clear();
}
void loop(void) {
  lcd.setCursor(0, 0);
  lcd.print("Temperatura:");
  lcd.setCursor(0, 1);
  sensors.requestTemperatures();
  lcd.print(sensors.getTempCByIndex(0));
  lcd.setCursor(6, 1);
  lcd.print("st.C");
  delay(1000);
} ```

I see. I'm not sure if it is due to libraries, I still get this error even from examples without library (File>Examples>Basics>Blink) still causes this error yet there are no libraries?

@Pioxis
Copy link

Pioxis commented Mar 2, 2021

I have the same error. I installed first DallasTemperature library from library manager, and for OneWire library I do the same.
After that I tried compile code at the bottom of the page.
But it ending with Error 2 UNKNOWN: exit status 1.
After that I installed manually libraries from .zip archives. (that works for me for old IDE). The same error.
My OS is Ubuntu 20.10

#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#include <OneWire.h>

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Definicja wejść wyświetlacza ciekłokrystalicznego //definition of lcd output
LiquidCrystal lcd(4, 5, 6, 7, 8, 9);
void setup(void) {
  // Inicjacja czujnika //sensor initiation
  sensors.begin();
  // Inicjacja wyświetlacza //screen initiation
  lcd.begin(16, 2);
  lcd.clear();
}
void loop(void) {
  lcd.setCursor(0, 0);
  lcd.print("Temperatura:");
  lcd.setCursor(0, 1);
  sensors.requestTemperatures();
  lcd.print(sensors.getTempCByIndex(0));
  lcd.setCursor(6, 1);
  lcd.print("st.C");
  delay(1000);
} ```

I see. I'm not sure if it is due to libraries, I still get this error even from examples without library (File>Examples>Basics>Blink) still causes this error yet there are no libraries?

For Blink example from Basic folder of examples I have that error:
Compilation error: Error: 2 UNKNOWN: no FQBN provided

@ubidefeo
Copy link

ubidefeo commented Mar 3, 2021

@TheAnton205 @Pioxis
have you installed any cores?

which board have you selected?
If the platform for the selected board is not installed you should get prompted to install it.

please try to manually add support for your board via the boards manager on the left sidebar or from the "Tools > Board > Boards Manager" menu

@Pioxis
Copy link

Pioxis commented Mar 3, 2021

@TheAnton205 @Pioxis
have you installed any cores?

which board have you selected?
If the platform for the selected board is not installed you should get prompted to install it.

please try to manually add support for your board via the boards manager on the left sidebar or from the "Tools > Board > Boards Manager" menu

Additionally I get that info from my terminal, when Error appeared:

daemon INFO inventory.Store.ConfigFileUsed() /home/pioxis/.arduino15/inventory.yaml
root ERROR Request compile failed with error: 2 UNKNOWN: no FQBN provided

When I first opened program I was prompted for select the board. I selected for Arduino UNO.
I have installed Arduino AVR Boards by Arduino, version 1.8.3

@TheAnton205
Copy link
Author

@TheAnton205 @Pioxis
have you installed any cores?

which board have you selected?
If the platform for the selected board is not installed you should get prompted to install it.

please try to manually add support for your board via the boards manager on the left sidebar or from the "Tools > Board > Boards Manager" menu

SOLVED:

For me I solved it by reinstalling the beta IDE and by reinstalling Arduino AVR Boards by Arduino, version 1.8.3

Everything seems working now, thanks.

@ChuckBland
Copy link

ChuckBland commented Mar 5, 2021

Same issue here. A program that easily compiles and runs under the old IDE gets:

collect2.exe: error: ld returned 1 exit status Using library IRremote at version 3.0.3 in folder: C:\Users\ccbland\Documents\Arduino\libraries\IRremote Compilation error: Error: 2 UNKNOWN: exit status 1

when compiled with V2. No other discernable complaints when using verbose mode on compile.

I did uninstall/reinstall IDE 2.0 to no avail.

Here's my program

#include "IRremote.h"

const int IR_RECEIVE_PIN = 11;
long keyPressed;


void setup()
{
    //setup serial monitor
    Serial.begin(115200);

    //initialize IR Receiver
    IrReceiver.begin(IR_RECEIVE_PIN, DISABLE_LED_FEEDBACK);
}

void loop()
{
    //check to see if a button was pressed
    if (IrReceiver.decode())
    {
        //a button press was pressed and decoded

        //get the code of the key that was pressed
        keyPressed = IrReceiver.decodedIRData.decodedRawData;

        //if that code is from the power button, tell us
        if (keyPressed==0xBA45FF00) Serial.println("Power Key Pressed");

        //wait for things to settle down
        delay(700);

        //resume receiving button presses
        IrReceiver.resume();
    }
}

@bphermansson
Copy link

I think this is a case of bad error messages. I got the error too, "Compilation error: Error: 2 UNKNOWN: exit status 1" in the output window. I started the program from the console, and there I see:

daemon INFO /tmp/.arduinoIDE-unsaved2021316-1396774-1hhgvhh.m6o3/Blink/Blink.ino:1:10: fatal error: Servo.h: No such file or directory
daemon INFO  #include <Servo.h>
daemon INFO           ^~~~~~~~~
daemon INFO compilation terminated.
root ERROR Request compile failed with error: 2 UNKNOWN: exit status 1

If I install the servo lib everything is fine, so the error message in the output window is wrong.

@ChuckBland
Copy link

ChuckBland commented Apr 17, 2021 via email

@bphermansson
Copy link

bphermansson commented Apr 18, 2021

I started the program from the command prompt in Linux. You can do the same with Windows Powershell . You go to the program installation folder and run the program by entering it's name. Then you see all log messages directly.

@ChuckBland
Copy link

ChuckBland commented Apr 19, 2021 via email

@thelwyn
Copy link

thelwyn commented May 26, 2021

Same issue here. Win 10 Pro 64 bits. Arduino Uno, Core installed (as suggested by the IDE itself). Can't compile anything, same error message.

@jerabaul29
Copy link

Same error here, opening a detailed issue about it now.

@jeromegirard
Copy link

Same error here, but like @bphermansson, when I compiled with verbose, I saw the the error comes from a lacking library.
Add the library and everything is working fine.

@d-i-ry
Copy link

d-i-ry commented Aug 4, 2021

upgrading to Arduino IDE v2.0.0 beta 9 worked for me

@pibondchem
Copy link

I had this error specifically when I added

#include <LiquidCrystal.h>

in my code.

I'm using a Dell XPS, Windows 10

Arduino IDE
Version:2.0.0-beta.10
Date: 2021-08-05T08:23:32.577Z(1 week ago)
CLI Version:0.18.3 alpha [d710b642]

@cirobruno
Copy link

cirobruno commented Aug 21, 2021

Same error!

Out or the blue, I couldn't compile anymore!

Now, as soon as I restart Arduino IDE, I get this message:
"Plugin runtime crashed unexpectedly, all plugins are not working, please reload the page. If it doesn't help, please check Theia server logs."
Wen trying to compile, "Compilation error: Error: 2 UNKNOWN: exit status 1".

So, I've update the board's extension to esp32 by Espressif Systems V1.0.6, getting
"Compilation error: Error: 2 UNKNOWN: exit status 1".

Then, after changing it to esp32 by Espressif Systems V1.0.5, the error became:
"bash: line 0: [: /Users/cirobruno/Documents/Arduino/Testes: binary operator expected
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... target_directory
Compilation error: Error: 2 UNKNOWN: exit status 64".

Back to esp32 by Espressif Systems V1.0.4, same thing again!

Aug. 21th 9:20PM: By the way, I've just installed ESP32 V2.0.0, from
https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html

What to do now?
Maybe I should migrate to VSCode...

@cmaglie cmaglie removed the type: bug label Sep 16, 2021
@rsora rsora added the type: imperfection Perceived defect in any part of project label Sep 22, 2021
@markyousif
Copy link

im new to arduino and it says exit status 1 i dont know what to do

@per1234
Copy link
Contributor

per1234 commented Sep 26, 2021

@markyousif. This issue tracker is only to be used to submit detailed, formal bug reports and feature requests.

You need to ask for help on the Arduino Forum. I'm sure we'll be able to help you out over there:
https://forum.arduino.cc/

@arduino arduino locked as off-topic and limited conversation to collaborators Sep 26, 2021
@per1234 per1234 changed the title Compilation error: Error: 2 UNKNOWN: exit status 1 "Compilation error: Error: 2 UNKNOWN: exit status 1" error message is unnecessarily cryptic Oct 20, 2021
@per1234
Copy link
Contributor

per1234 commented Oct 20, 2021

Each actual cause of the generic "Error: 2 UNKNOWN" errors reported through this thread was completely unrelated to the others. The valuable feedback this issue ended up providing is that the current practice of exposing the users to internal details of the gRPC interface causes confusion and provides absolutely no benefit.

Even though the statuses have been made slightly more specific by arduino/arduino-cli#1251, in the end it's only a change from this:

Compilation error: Error: 2 UNKNOWN: exit status 1

to this:

Compilation error: Error: 13 INTERNAL: exit status 1

The "13 INTERNAL" doesn't add anything of value to the console output, and will likely even be misleading since "INTERNAL" implies something wrong within the IDE itself, so it's not really much of an improvement for the users over the mysterious "2 UNKNOWN".

@per1234
Copy link
Contributor

per1234 commented Oct 20, 2021

Should be resolved for the console output by #564

#564 does not solve the issue for the error messages shown in notifications though.

@per1234 per1234 added the topic: code Related to content of the project itself label Oct 29, 2021
@rsora rsora added criticality: high Of high impact criticality: highest Of highest impact and removed criticality: high Of high impact labels Nov 30, 2021
@per1234 per1234 added the conclusion: resolved Issue was resolved label Dec 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
conclusion: resolved Issue was resolved criticality: highest Of highest impact topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.