-
Notifications
You must be signed in to change notification settings - Fork 341
Support extensions from globally activated pub packages #7594
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
@sigurdm 😄 |
We have You probably want a way to find the .dart_tool/package_config.json for each of these to detect extensions - right? @jonasfj should we extend the list command with more info? Any other ideas? |
I'm not sure globally activated packages should be used for this. Global package activation is a mechanism for installing a package onto your system. That said, a somewhat ludicrous idea would be for devtools to discover system-level extensions by searching Imagine that devtools discovers system-level extensions by:
If you are authoring a global devtools extension, you don't have to ship it as a pub package to be globally activate. You can ship as a globally activated package, because you can use the I suppose it would also be possible for devtools to try and guess the location of the global With this approach system-level devtools extensions could also be installed using system package manager like Maybe, it's a bit crazy, but:
It might just work :D |
@sigurdm
For a globally activated package, we would really just need to look at its contents for the
@jonasfj Since DevTools extensions are shipped as part of the pub ecosystem, I actually think this is a reason we need to support this use case. As a user, I would expect that if I install a package onto my system, that I can use anything that package provides, including executables, extensions, etc.
While this could work, my concern is that this is one more thing that extension authors have to manually set up, and they have to know when they need this and when they do not. I don't expect extension authors to have as much familiarity with what it means to be a "static" extension vs. a "runtime" extension and "global" vs "non-global". We want to make it as simple as possible for authors to build a tool, and know that no matter how users install their package (as a global or as a project dependency), that their users will be able to discover the tool they have built and use it.
I don't think we want to diverge the extension distribution (and enablement) mechanism, since this will be less discoverable for users and will make the development process more difficult for extension authors. Having one way to ship and install an extension (via pub) is ideal. Shipping / installing with pub is straight forward and keeps DevTools extensions in alignment with the Dart ecosystem standards. |
Pinging this issue again since another use case has come up where we'd like to be able to load a DevTools extension for a globally activated package. Rationale:
For these reasons and the ones I outlined above, extension detection for globally activated packages is something we'd like to support. Could |
In an ideal world: (1) is something that should be solved by:
(2) should be addressed by allowing multiple versions of the same package in a resolution (probably by marking some dependencies as The motivation for global extensions should be that there may be extensions which:
In practice, I think (2) I suspect that (1) is something we do need to solve, we haven't found a good way yet. But I don't think that an optional Flutter SDK constraint is a controversial feature. And progress on native hooks will probably only make this more urgent. This is my thoughts of the top of my head. Not sure what we should do. Or if there are other reasons to do global extensions. Or maybe, tracking devtools extensions in |
Given that devtools extensions are "just" precompiled flutter(-web) binaries. There should (from the point of view of distributing the extension) not be the need for any other dependencies? With no extensions there is no potential for conflicts? |
Using a I'm not following how this would solve the issue for extensions. Can you provide an example? Here is the potential set up for an extension user: my_dart_app/pubspec.yaml name: my_dart_app
version: 1.0.0
environment:
sdk: ^3.5.0
dependencies:
# dependencies for the my_dart_app project
dev_dependencies:
foo: ^1.0.0 # add dependency for standalone devtools extension foo/pubspec.yaml name: foo
version: 1.0.0
environment:
sdk: ^3.8.0
flutter: ^3.32.0
dependencies:
flutter:
sdk: flutter
# other dependencies for the foo devtools extension
How would this solve the problem? I assume even private_dependencies still have to solve with the remaining dependencies in the pubspec, which would leave us with the same friction points I described above.
Agreed. For example, we want to provide a DevTools extension for inspecting the state of the Dart Tooling Daemon. This tool is not specific to a single Dart / Flutter project, but rather is useful for any Dart / Flutter project. It is cumbersome set up to have to manually add this dependency to a project (which may mess up the pub solve and cause toilsome dependency issues) in order to use this tool.
For this case, I'd recommend using the
I do believe this would be controversial for any package developed in the Dart SDK. In general though, I don't understand a reason not to support extensions for globally activated packages? This seems like the most simple way to support the global tool use case and would require minimal changes to the extension discovery mechanism. We could even hack this together today with the information we have available from |
While this is true, this would not be an ideal development story for extension authors nor an ideal discovery mechanism for extension users. One of the benefits of how DevTools extensions are designed is that users get the extension for any package they depend on for free; they do not have to discover this in some other way. If the extension was shipped as a separate package, this benefit would go away completely and extension authors would likely struggle to get tool adoption. We saw this with the Another benefit for authors of standalone extensions (extensions that do not ship with a parent package but rather are a standalone tool) is that development is simple and can be done in a single package. The source code and the precompiled extension that is shipped to users are in the same package. Requiring extension authors to ship as a separate package that only contains the binary seems like unnecessary overhead when we could just allow users to globally activate a single package to use the extension.
Can you elaborate? I'm not sure I understand the question. |
Right, but when you are using the package, you most likely want to resolve all the constraints along with the rest of the package - no? I was arguing about stand-alone extensions. The argument kind of extends though: the dependencies for compiling the extension itself should not necessarily be dependencies of the package. See suggestion for a nested package layout below.
I think I would suggest a nested package layout in that case such that the code for the extension is contained inside the package, but not really part of it. Something like: pubspec.yaml # pubspec for distributing the extension, the one that is published. No dependencies.
extension/
devtools/
build/
... # pre-compiled output of the Flutter web app.
pubspec.yaml # pubspec for the extension code itself, defines the dependencies for compiling the web app.
lib/ # source code for your extension Flutter web app
src/
... Connecting the two packages into a pub workspace might make development bearable.
Sorry that was a brain-hiccup - I meant "With no dependencies there is no potential for conflicts" (the question mark was kinda rhetorical). |
Not necessarily for standalone extensions. For example, someone may have built a tool that does something interesting with the connected VM service instance but that doesn't have any need to pub solve with the user's project. The DevTools extension is precompiled, so the dependencies for a standalone extension package should not matter for the end user. For non-standalone extensions (extensions that are tightly coupled to a parent package like Re: nested layout above - it feels a bit strange to have an entire Flutter web app nested under the I do think the topic of how to structure your extension for development is a separate topic than enabling extensions for globally activated packages. In many cases, it will depend on the extension author's use case, repository standards, and preference. So I propose we keep this issue focused on how to support DevTools extensions for globally activated packages and work toward a solution for that problem. Essentially the ask for the pub team is this: can we have a way to list the |
An example of an extension that fits this use case would be an arbitrary development tool package (like an AI-assisted development experience extension or a tool that interacts with the Dart analysis server). These extensions may be runtime or static extensions.
It would be a bit awkward to require a user to add a dev_dependency to every Dart project where they want to use this DevTools extension, since tools like these are not specific to a Dart / Flutter project, but rather to the general Dart / Flutter development experience. The workflow for an end user would be:
dart pub global activate some_pkg
some_pkg
provides a DevTools extension, we should be able to load this in DevTools (and also embedded in the IDE).@jonasfj @sigmundch is there a way to tell from the pub cache what the globally activated pub packages are?
The text was updated successfully, but these errors were encountered: