Skip to content
New issue

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

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

Already on GitHub? # to your account

The error for using dart:io is unhelpful #3

Closed
devoncarew opened this issue Jan 7, 2015 · 10 comments
Closed

The error for using dart:io is unhelpful #3

devoncarew opened this issue Jan 7, 2015 · 10 comments
Labels
P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@devoncarew
Copy link
Member

From @lukechurch on January 5, 2015 12:30

"Error compiling:
[500 Internal Server Error] [error, line 1] Library not found 'dart:io'."

Should be something along the lines of

"The dart:io library cannot be used in a browser context. Please see support page for common work arounds."

Lets chat about where we put in the fix.

Copied from original issue: devoncarew/dartpad_ui#14

@devoncarew
Copy link
Member Author

It now reads:

There was an issue when compiling to JavaScript:
[error, line 1] Library not found 'dart:io'.

Which is an intermediate step towards the above solution.

@devoncarew devoncarew added this to the M3 milestone Jan 20, 2015
@sethladd sethladd added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P1 A high priority bug; for example, a single project is unusable or has many test failures labels Apr 14, 2015
@sethladd
Copy link

We should prevent the Run button from being clickable, if the code somehow imports dart:io.

devoncarew pushed a commit that referenced this issue Apr 17, 2015
add mode change events to the playground context
@devoncarew devoncarew removed the P1 A high priority bug; for example, a single project is unusable or has many test failures label Apr 22, 2015
@devoncarew
Copy link
Member Author

The error has been cleaned up quite a bit. We can get some more info from the backend when analyzing, to be able to recognize a sample that directly or transitively imports dart:io.

@Sfshaza
Copy link

Sfshaza commented Jun 25, 2015

I am confused.

I am able to read a file in the darrrrt codelab, which depends on dart:html. So I expected that creating a simple example that relies on dart:io would also be able to read a file.

I tried it and got a confusing error:

CONSOLE
Error compiling to JavaScript:
[error on line 1] Library not found 'dart:io'.
[warning on line 7] Cannot resolve 'File'.

If dart:io is not supported, I would expect a clearer message saying that dart:io is not supported.

And why can I read a file in the Pirate codelab (dart:html) but not dart:io?

You can see my example here:
https://dartpad.dartlang.org/75e9c57f714e8a51ef21

Here is the Pirate codelab, which reads a JSON file:
https://dartpad.dartlang.org/9ccf6694c91268e78e79

@devoncarew
Copy link
Member Author

devoncarew commented Jun 25, 2015

Yeah, the net-net is that dart:io is not supported, and there's no real path to supporting it in dartpad.

We can do something like scrape the error message that comes back from dart2js in order to display a better error message.

You can use the dart:html apis to read a file because we compile your app to javascript and execute it in the browser (in an embedded iframe). We can't run a dart:io app in the browser, and we don't have a sandboxed environment to be able to execute it on a server :(

@devoncarew devoncarew added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Jun 25, 2015
@devoncarew
Copy link
Member Author

The action item here is to improve the error message in order to make it clear that the reason the app failed to run is because the dart:io library is not supported in dartpad.

@Sfshaza
Copy link

Sfshaza commented Jun 25, 2015

Yes, thanks.

@kwalrath
Copy link

Still an issue. You can even import 'dart:io' and get reasonable looking docs, which makes you think it'll be OK to use...

@matanlurey
Copy link

Another user ran into this.

@jcollins-g jcollins-g added P3 A lower priority bug or feature request and removed P1 A high priority bug; for example, a single project is unusable or has many test failures labels Oct 19, 2018
@RedBrogdon
Copy link
Contributor

Just opened a related but broader issue: #1000. I'm going to close this one as a duplicate of the new one.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

7 participants