Skip to content

No error highlight after "No such file or directory" error #7614

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
per1234 opened this issue May 20, 2018 · 3 comments
Closed

No error highlight after "No such file or directory" error #7614

per1234 opened this issue May 20, 2018 · 3 comments
Assignees
Labels
Component: Board/Lib Manager Boards Manager or Library Manager Component: IDE The Arduino IDE
Milestone

Comments

@per1234
Copy link
Collaborator

per1234 commented May 20, 2018

Using Arduino IDE 1.9.0 Beta Build 58 or Arduino IDE 1.8.6 Hourly 2018-05-15 10:41 w/ Windows 10 64 bit

Compile the following sketch:

#include <foobar.h>
void setup() {}
void loop() {}

Compilation fails:

C:\Users\per\AppData\Local\Temp\arduino_modified_sketch_114310\sketch_may20d.ino:1:20: fatal error: foobar.h: No such file or directory

but there is no error highlight on line 1, as would be expected with a compilation error caused by sketch code.

I'm not sure how difficult this would be to resolve, but "No such file or directory" is probably the most common error we see on the Arduino forum. The users encountering this error are usually very new to Arduino (they haven't learned they need to install libraries yet) and so any additional clues to the problem could be very helpful. Sometimes there will be a helpful comment near #include directives in a sketch that gives some information regarding where to find the library dependency.

@facchinm
Copy link
Member

It looks like the problem is the "fatal" word that breaks the regexp.
Fixing it this way should at least highlight the line

diff --git a/arduino-core/src/cc/arduino/Compiler.java b/arduino-core/src/cc/arduino/Compiler.java
index 3f1ffb4e1..94a515150 100644
--- a/arduino-core/src/cc/arduino/Compiler.java
+++ b/arduino-core/src/cc/arduino/Compiler.java
@@ -133,7 +133,7 @@ public class Compiler implements MessageConsumer {
     }
   }
 
-  private static final Pattern ERROR_FORMAT = Pattern.compile("(.+\\.\\w+):(\\d+)(:\\d+)*:\\s*error:\\s*(.*)\\s*", Pattern.MULTILINE | Pattern.DOTALL);
+  private static final Pattern ERROR_FORMAT = Pattern.compile("(.+\\.\\w+):(\\d+)(:\\d+)*:\\s*(fatal)?\\s*error:\\s*(.*)\\s*", Pattern.MULTILINE | Pattern.DOTALL);
 
   private final File pathToSketch;
   private final Sketch sketch;

About the helper, it would need a few refactoring on that part (since now we only match exact errors).

@per1234
Copy link
Collaborator Author

per1234 commented May 21, 2018

About the helper, it would need a few refactoring on that part (since now we only match exact errors).

I'm not sure what you meant by that. If you're referring to what I said:

Sometimes there will be a helpful comment near #include directives in a sketch that gives some information regarding where to find the library dependency.

by that I only meant that sometimes the author of a sketch will leave a comment in the code about the library dependency. If that line was highlighted after the "No such file or directory" error it would draw the user's attention to any comment the sketch author might have left near that line. For example:

// Available from: http://github.com/per1234/foobar
#include <foobar.h>

If you're talking about some magical check of the Library Manager index for a library that matches the missing filename (without the extension), or even just a link to open a Library Manager search for it, that could be nice. Adding the library.properties include property to the Library Manager index and search scope (#7604) would help this since that would make it more likely that the library would be found with a search for the filename.

@facchinm facchinm self-assigned this May 21, 2018
@facchinm facchinm added Component: IDE The Arduino IDE Component: Board/Lib Manager Boards Manager or Library Manager labels May 21, 2018
@cmaglie
Copy link
Member

cmaglie commented May 21, 2018

I changed the regexp as @facchinm suggested, now the error is correctly highlighted.

@cmaglie cmaglie added this to the Release 1.8.6 milestone May 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Board/Lib Manager Boards Manager or Library Manager Component: IDE The Arduino IDE
Projects
None yet
Development

No branches or pull requests

3 participants