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
spawnUri should be relative to the working directory, not the entrypoint #8440
Comments
I think this is a duplicate of 5950 |
This seems to be fixed now, possibly as a result of the recent isolate refactor. Added Fixed label. |
Never mind, I think my attempted reproduction was flawed. This is still an issue. Added Triaged label. |
I don't think that relative to the working directory makes sense. |
Every other core library API that takes a path treats it as relative to the working directory. It's confusing and inconsistent to have this one API be an (undocumented!) exception. What's more, this behavior is rarely going to be useful at all. Most people writing code complex enough to use isolates are going to be splitting their code across multiple libraries. This means that they can't safely assume -- and may not even know -- where the entrypoint is. In the few cases where the author knows the location of the entrypoint and wants to load something relative to that, it's easy to use [Platform.script] to do so. Please don't sacrifice the comprehensibility of the API for that narrow use case. |
I'm not saying that the entry-point is the correct solution, but the current working directory isn't either. |
What we probably need is a way to get to the current script-directory. In which case the program would need to explicitly use that directory. |
Every other platform API that takes a path is in the I/O library. The isolate library works in a browser as well, and the only fixed point that a library has in there is the URL it was loaded from. When you have files and I/O, you can easily construct a file:-URL from a path, and get access to the current working directory. That means that letting relative URLs be relative to the library will work in all cases, and when you have files, you can also make them relative to the current working directory, you just have to do it explicitly. I think the current spawnUri is the best we can do, and I don't even think it's bad :) |
It doesn't support the use-case from comment #6. So we need to find a fix for that. |
Ah, yes. For the entry library, it works, but for other libraries it doesn't. It would be great if it worked relative to the library calling it, but that's probably unimplementable (or too fragile to ever work correctly). A better solution would be to somehow give a library access to its own location URL |
I'd certainly like to see issue #1145 fixed, but I still think the correct way to handle this case is to treat the URI as relative to the current base URI. I don't think it's at all correct to say that the notion of a "working directory" is specific to console apps -- relative URIs have a canonical meaning in the browser just as much as they do on the console. They're relative to the current window's URL. We already encode this notion in [Uri.base]. If we're going to claim that spawnUri takes a URI, it should resolve that URI in the canonical way. |
I don't think we can change this now without breaking code. Added this to the 2.0 milestone. |
Issue #5950 has been merged into this issue. |
Can we do this as part of 2.0? |
If the There are no plans for changing |
Removing the milestone, since this isn't happening for 2.0. |
Currently, dart:ioslate's spawnUri function treats the URI that it's spawning as relative to the Dart entrypoint. This means that the path you have to pass in is different from all the other paths that you use in an application, which all other APIs treat as relative to the working directory.
The text was updated successfully, but these errors were encountered: