Skip to content
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

dart run prints errors twice #4375

Closed
julemand101 opened this issue Sep 9, 2024 · 2 comments · Fixed by #4377
Closed

dart run prints errors twice #4375

julemand101 opened this issue Sep 9, 2024 · 2 comments · Fixed by #4377
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@julemand101
Copy link

(Not entirely sure if this is actually an issue in pub or Dart SDK. Please just move the issue if it is posted wrongly) :)

Environment

Tested with the following:

Dart SDK version: 3.6.0-198.0.dev (dev) (Thu Aug 29 13:03:18 2024 -0700) on "windows_x64"
Dart SDK version: 3.5.2 (stable) (Wed Aug 28 10:01:20 2024 +0000) on "windows_x64"

Problem

When making a project containing a syntax error like:

void main() {
  print('')
}

And run it with dart run, we see the error message being printed twice:

$ dart run
Building package executable...
Failed to build advent_of_code_2022:advent_of_code_2022:
bin/advent_of_code_2022.dart:2:11: Error: Expected ';' after this.
  print('')
          ^
Failed to build advent_of_code_2022:advent_of_code_2022:
bin/advent_of_code_2022.dart:2:11: Error: Expected ';' after this.
  print('')
          ^

Expected behavior

Expected the error only be printed once like it is also the case if you run the program with:

$ dart run bin/advent_of_code_2022.dart
bin/advent_of_code_2022.dart:2:11: Error: Expected ';' after this.
  print('')
          ^

And:

$ dart bin/advent_of_code_2022.dart
bin/advent_of_code_2022.dart:2:11: Error: Expected ';' after this.
  print('')
          ^

Bonus observation

It looks like colors of the error message are missing in the output from dart run compared to dart run file.dart and dart file.dart:

billede

Same behavior have also been noticed in both PowerShell and Bash for Windows.

@sigurdm
Copy link
Contributor

sigurdm commented Sep 10, 2024

I was not able to reproduce this on windows with latest flutter sdk.

PS C:\Users\sigurdm\blah> C:\Users\sigurdm\flutter\bin\flutter.bat --version
[...]
Flutter 3.25.0-1.0.pre.320 • channel master • https://github.com/flutter/flutter.git
Framework • revision d6e2b6aedb (6 hours ago) • 2024-09-10 01:27:20 -0400
Engine • revision 3dc8b71f96
Tools • Dart 3.6.0 (build 3.6.0-232.0.dev) • DevTools 2.39.0

PS C:\Users\sigurdm\blah> C:\Users\sigurdm\flutter\bin\cache\dart-sdk\bin\dart.exe run .\bin\syntax_error.dart
bin/syntax_error.dart:2:22: Error: Expected ';' after this.
  print('hello world')
                     ^
PS C:\Users\sigurdm\blah>

@sigurdm sigurdm added the needs-info Additional information needed from the issue author label Sep 10, 2024
@sigurdm
Copy link
Contributor

sigurdm commented Sep 10, 2024

Oh - now I managed!

This is dart run :syntax_error not dart run bin/syntax_error.dart.

@sigurdm sigurdm added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed needs-info Additional information needed from the issue author labels Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants