Skip to content

improvements for binary executables #2099

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

Closed
sigmundch opened this issue Mar 12, 2019 · 6 comments
Closed

improvements for binary executables #2099

sigmundch opened this issue Mar 12, 2019 · 6 comments
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@sigmundch
Copy link
Member

I was recently surprised that a package I published failed to install via pub global activate.

My issue was that I had some shared code in libraries within the bin/ folder that are not binaries themselves. When I ran pub global activate I saw that precompilation failed on those libraries. I was surprised by this because the libraries were not listed in the executables section in the pubspect.yaml file and because, during development, activating via path (pub global activate -s path ...) gives no warning of the issue.

My workaround is to move the shared code under bin/src/. However, I wonder:

  • Chould we detect libraries without a main and skip precompilation for those? Or
  • Chould we detect the issue earlier, either when activating a path or when validating a package before it's published?

To reproduce this, try:

pub global activate dart2js_info 0.6.0

and you'll see errors like:

Failed to precompile dart2js_info:deferred_library_check:
Dart_LoadScriptFromKernel: The binary program does not contain 'main'.
@jonasfj
Copy link
Member

jonasfj commented Mar 12, 2019

Reading:
https://www.dartlang.org/tools/pub/cmd/pub-global#configuring-package-executables

I'm starting to think that we might have two things we can do here:

A) We should maybe not be pre-compiling scripts from bin/ if they are not listed as executable in the pubspec.yaml. You can still trigger them with pub global run.

B) in pana reduce package score if there are libraries in bin/. Maybe we can do it in a pub package validation step prior to publishing. I'm not sure if any of the other validations does code analysis, or if there is a problem/concern with doing so..

@jakemac53
Copy link
Contributor

jakemac53 commented Mar 13, 2019

Fwiw I would actually love it if pub stopped precompiling scripts completely on pub get/upgrade - it is really slow and could instead be done lazily always.

That would also make it so pub get/upgrade don't fail just because of a bad executable (you would get the error later when you try to actually run the offending script), and also it would allow it to re-snapshot them if you delete your local pub cache (in .dart_tool of your package). Today if you do that you lose all snapshots until you run pub get/upgrade again so all binaries are slow after that point.

The downside of course is the first run of these executables is slow, but I think that is probably ok, or at least a reasonable tradeoff. Packages should be able to release executables without increasing pub get/upgrade times for all users who have a transitive dep on their package by multiple seconds which is the case today.

@jonasfj
Copy link
Member

jonasfj commented Mar 13, 2019

@sigurdm was also suggesting we made pre-compilation of scripts lazy.

@natebosch
Copy link
Member

I would actually love it if pub stopped precompiling scripts completely on pub get/upgrade

This issue is specifically pub global activate. In the pub get case the user hasn't necessarily indicated an intent to run the binaries - but in the activate case they have. I think for activate precompilation makes sense.

@jonasfj
Copy link
Member

jonasfj commented Mar 16, 2019

but in the activate case they have. I think for activate precompilation makes sense.

Yet, some packages contain many targets that you never run.. as a package may define multiple executable scripts.

I agree that, lazy pre-compilation is mostly a problem for pub get. But doing it lazily for pub global activate might be nice too.

@sigurdm sigurdm added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) run labels Feb 14, 2023
@sigurdm
Copy link
Contributor

sigurdm commented Mar 31, 2023

We made script precompilation lazy for dependencies: #2277

@sigurdm sigurdm closed this as completed Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants