-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Provide a way of getting packageRoot as a Uri #19430
Comments
We can't change the type returned from packageRoot – we want to avoid breaking changes. We could add a packageRootUri property or similar, though Added Library-IO label. |
Consider using 'new Uri.file(Platform.packageRoot)' to get the Uri you need. You will still need to look for tailing slash though. |
For a Platform-independent version without double slashes that would require: Uri fileUri = Uri.base.resolveUri( This is, and will be, handled incorrectly in many use-cases. |
Uri fileUri = Uri.base.resolveUri(new Uri.file(Platform.packageRoot)); Should be sufficient. But I agree, it's non-trivial. |
For those following along, this getter will start to return a URI if the VM has resolved packageRoot, even if --package-root was not set on the command line. In other words, if the VM has decided to use a package root, then packageRoot will return something. |
That might even be worse. If you want to create a new process in your own package environment you will not be able to do so if you don't rely on packages yourself. |
Johnni, I am not sure what you are trying to say in your last comment. But let me explain the semantics that Seth has been referring to:
The above points are evaluated in the order they have been listed for the root isolate. For spawned isolates the parameters to spawnUri are equivalent to command line flags. In all cases the result is irrespective of whether your isolate has or has not loaded any packages. |
Sounds good. |
@iposva-google, you are working on this, right? |
Correct. A CL (https://codereview.chromium.org/1334353002/) is in review, but a lot of tests need adjusting... |
This has been rolled back, so I'm re-opening. |
And I believe it has been landed again, so closing |
Platform.packageRoot should return a Uri.
Currently is is passed on verbatim from the system, and even though the package root always refers to a directory-like resource every user must ensure that it is normalized before handling.
For instance, you cannot use
Uri packageRoot = Uri.base.resolve(Platform.packageRoot);
because it might be missing a trailing slash and might contain ''.
The text was updated successfully, but these errors were encountered: