-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Platform.script
should be reworked to always return the Dart entrypoint path
#60498
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
Comments
//cc @lrhn |
There are two meaningful options for how
The latter is a superset of the former, and it's what we do. It works both for running from from source and running an We could allow some intermediate forms to be considered "transitory", and let them keep compilation environment information, like script path and package resolution, with the clear understanding that they should be run on the same system where they were created, and that they only exist as a local optimization step. I don't know which kind of intermediate forms we have, but anything short of an The default is to not remember source system information, and you have to ask to have it included. It won't be useful if you move the artifact to another system, or maybe even if you keep it for too long, so the source paths are no longer correct. If we want to be defensive, a Dart installation could assign itself a random number, and bake that into local-only artifacts, and then refuse to run them if the number doesn't match. Maybe a new number every time the SDK is updated. Or every free days. That's my suggestion, a compilation flag that makes the VM remember source paths, as they would be if run from source, through intermediate representations. Preferably in a way that makes it hard to accidentally think such a compilation artifact of useful anywhere else. |
With Now, for |
Technically, |
Platform.script
behaves differently depending on how a Dart program is invoked:dart test
, the resident compiler, or a precompiled snapshot, the path to the intermediate artifact (e.g., dill, or snapshot) is returnedThis makes it difficult to resolve URIs relative to the entrypoint script, something that is frequently done within tests to load resources or spawn child processes. The difference in behavior depending on how the script was executed is also surprising and confusing.
We should consider providing a way to consistently provide the path to the entrypoint script for a given isolate, regardless of how it was run. Some ideas:
Platform.script
to not return paths to compilation artifacts (this would be a breaking change)Platform.entrypointUri
?)IOOverride
forscript
, which would at least allow forpackage:test
to possibly override the path to the correct entrypointThe text was updated successfully, but these errors were encountered: