[XL] Change in dart/sdk[main]: [dartdev] `dart install`

2 views
Skip to first unread message

Daco Harkes (Gerrit)

unread,
Aug 7, 2025, 11:44:02 AM8/7/25
to Commit Queue, rev...@dartlang.org

Daco Harkes added 2 comments

Patchset-level comments
File-level comment, Patchset 15 (Latest):
Daco Harkes . resolved

Hey!

I think this is ready for a first round of reviews.

@sig...@google.com, I think you're the most knowledgable about (1) how `dart pub global activate` works, and (2) how I may or may not use `package:pub` from `package:dartdev`. So, your review would be greatly appreciated!

Kind r

File pkg/dartdev/lib/src/commands/install.dart
Line 12, Patchset 15 (Latest):import 'package:pub/src/source/git.dart';
Daco Harkes . unresolved
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Gerrit-Change-Number: 441581
Gerrit-PatchSet: 15
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Comment-Date: Thu, 07 Aug 2025 15:43:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Sigurd Meldgaard (Gerrit)

unread,
Aug 8, 2025, 8:10:51 AM8/8/25
to Daco Harkes, Michael Goderbauer, Commit Queue, rev...@dartlang.org
Attention needed from Daco Harkes and Michael Goderbauer

Sigurd Meldgaard added 6 comments

File pkg/dartdev/lib/src/commands/install.dart
Line 450, Patchset 15 (Latest): await sourcePackagePubspecFile.copy(appBundleDirectory.pubspec.path);
Sigurd Meldgaard . unresolved

Consider using rename operations here, as they happen atomically.

And perhaps create the entire appBundle first in a temp-dir and then rename.

This requires that the temp-directory is colocated with the final destination, such that we don't have to rename across devices.

File pkg/dartdev/lib/src/commands/installed.dart
Line 121, Patchset 15 (Latest): throw StateError('Unknown package source: ${lockInfo.source.name}');
Sigurd Meldgaard . unresolved

Consider handling this more gracefully. The user could have a corrupt installation, we should report that nicely, not crash

File pkg/dartdev/lib/src/commands/uninstall.dart
Line 32, Patchset 15 (Latest): 'Wrong number of arguments, expected "<package>", got "${args.join(' ')}"',
Sigurd Meldgaard . unresolved

This reads a bit funny with 0 arguments,

File pkg/dartdev/lib/src/install/pub_formats.dart
Line 35, Patchset 15 (Latest): void writeSync(File file) {
Sigurd Meldgaard . unresolved

Please don't write lock files and package configs if you can avoid it.
That should be the job of pub.

File pkg/dartdev/test/commands/help_test.dart
Line 82, Patchset 15 (Latest):Global
Sigurd Meldgaard . unresolved

Can we have these below the project? They seem

File pkg/dartdev/test/native_assets/helpers.dart
Line 43, Patchset 15 (Latest): // Don't fail on files being in use.
Sigurd Meldgaard . unresolved

Consider retrying after a delay on windows

Open in Gerrit

Related details

Attention is currently required from:
  • Daco Harkes
  • Michael Goderbauer
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Gerrit-Change-Number: 441581
Gerrit-PatchSet: 15
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Michael Goderbauer <goder...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Attention: Daco Harkes <dacoh...@google.com>
Gerrit-Attention: Michael Goderbauer <goder...@google.com>
Gerrit-Comment-Date: Fri, 08 Aug 2025 12:10:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Goderbauer (Gerrit)

unread,
Aug 8, 2025, 10:14:50 AM8/8/25
to Daco Harkes, Sigurd Meldgaard, Commit Queue, rev...@dartlang.org
Attention needed from Daco Harkes

Michael Goderbauer added 10 comments

File pkg/dartdev/lib/src/commands/build.dart
Line 133, Patchset 15 (Latest): var target = args.option('target')!;
Michael Goderbauer . unresolved

My understanding from line 104 is that `target` could potentially be null if the user doesn't specify the option, which would make this `!` throw an ugly exception. We should probably handle that null case nicer? Might be also worthwhile to add a test where it ends up being null.

Line 224, Patchset 15 (Latest): executables.first.$2,
Michael Goderbauer . unresolved

Consider maybe a named tuple so this reads a little nicer?

File pkg/dartdev/lib/src/commands/install.dart
Line 44, Patchset 15 (Latest): argParser.addOption('git-path', help: 'Path of git package in repository');
Michael Goderbauer . unresolved

(here and below) Maybe add that this is only valid when source is git? (Similar to what you say for hosted-url)

Line 107, Patchset 15 (Latest): case _SourceKind.hosted:
versionConstraint = args.isEmpty ? 'any' : readArg();
}
if (args.isNotEmpty) {
Michael Goderbauer . unresolved

The `invocation` help line kinda implies that you could always optionally supply a version constraint argument. Not sure if we can somehow document that it only applies to hosted?

Line 361, Patchset 15 (Latest): 'A web search for "configure windows path" will show you how.',
Michael Goderbauer . resolved

😂

Line 376, Patchset 15 (Latest): print(result.stdout);
Michael Goderbauer . unresolved

Remove?

Line 389, Patchset 15 (Latest): : '(.bashrc, .bash_profile, .zshrc etc.)';
Michael Goderbauer . unresolved

For consistency with line above:

```suggestion
: '(.bashrc, .bash_profile, .zshrc, etc.)';
```
Line 408, Patchset 15 (Latest): _createHelperPackagePubspec(
Michael Goderbauer . unresolved

It wasn't immediately obvious to me what the purpose of the helper package is. Maybe document that in a code comment to help the next reader?

File pkg/dartdev/lib/src/commands/installed.dart
Line 24, Patchset 15 (Latest): help: 'Also list packages which are currently not active',
Michael Goderbauer . unresolved

Where can I as a reader of the help message learn more about what it means for a package to be active or not? Can we add a short description or some pointers here?

Line 24, Patchset 15 (Latest): help: 'Also list packages which are currently not active',
Michael Goderbauer . unresolved
```suggestion
help: 'Also list packages which are currently not active.',
```
Open in Gerrit

Related details

Attention is currently required from:
  • Daco Harkes
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Gerrit-Change-Number: 441581
Gerrit-PatchSet: 15
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Michael Goderbauer <goder...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Attention: Daco Harkes <dacoh...@google.com>
Gerrit-Comment-Date: Fri, 08 Aug 2025 14:14:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Daco Harkes (Gerrit)

unread,
Aug 11, 2025, 7:30:55 AM8/11/25
to Michael Goderbauer, Sigurd Meldgaard, Commit Queue, rev...@dartlang.org
Attention needed from Michael Goderbauer and Sigurd Meldgaard

Daco Harkes added 16 comments

File pkg/dartdev/lib/src/commands/build.dart
Line 133, Patchset 15: var target = args.option('target')!;
Michael Goderbauer . resolved

My understanding from line 104 is that `target` could potentially be null if the user doesn't specify the option, which would make this `!` throw an ugly exception. We should probably handle that null case nicer? Might be also worthwhile to add a test where it ends up being null.

Daco Harkes

Done

Line 224, Patchset 15: executables.first.$2,
Michael Goderbauer . resolved

Consider maybe a named tuple so this reads a little nicer?

Daco Harkes

Done

File pkg/dartdev/lib/src/commands/install.dart
Line 12, Patchset 15:import 'package:pub/src/source/git.dart';
Daco Harkes . resolved
Daco Harkes

Done

Line 44, Patchset 15: argParser.addOption('git-path', help: 'Path of git package in repository');
Michael Goderbauer . resolved

(here and below) Maybe add that this is only valid when source is git? (Similar to what you say for hosted-url)

Daco Harkes

Done

Line 107, Patchset 15: case _SourceKind.hosted:

versionConstraint = args.isEmpty ? 'any' : readArg();
}
if (args.isNotEmpty) {
Michael Goderbauer . resolved

The `invocation` help line kinda implies that you could always optionally supply a version constraint argument. Not sure if we can somehow document that it only applies to hosted?

Daco Harkes

I've added some description to the to the description field and a golden test to see how it looks.

Line 376, Patchset 15: print(result.stdout);
Michael Goderbauer . resolved

Remove?

Daco Harkes

Done

Line 389, Patchset 15: : '(.bashrc, .bash_profile, .zshrc etc.)';
Michael Goderbauer . resolved

For consistency with line above:

```suggestion
: '(.bashrc, .bash_profile, .zshrc, etc.)';
```
Daco Harkes

Done

Line 408, Patchset 15: _createHelperPackagePubspec(
Michael Goderbauer . resolved

It wasn't immediately obvious to me what the purpose of the helper package is. Maybe document that in a code comment to help the next reader?

Daco Harkes

Done

Line 450, Patchset 15: await sourcePackagePubspecFile.copy(appBundleDirectory.pubspec.path);
Sigurd Meldgaard . resolved

Consider using rename operations here, as they happen atomically.

And perhaps create the entire appBundle first in a temp-dir and then rename.

This requires that the temp-directory is colocated with the final destination, such that we don't have to rename across devices.

Daco Harkes

Done

File pkg/dartdev/lib/src/commands/installed.dart
Line 24, Patchset 15: help: 'Also list packages which are currently not active',
Michael Goderbauer . resolved
```suggestion
help: 'Also list packages which are currently not active.',
```
Daco Harkes

Done

Line 24, Patchset 15: help: 'Also list packages which are currently not active',
Michael Goderbauer . resolved

Where can I as a reader of the help message learn more about what it means for a package to be active or not? Can we add a short description or some pointers here?

Daco Harkes

Done

Line 121, Patchset 15: throw StateError('Unknown package source: ${lockInfo.source.name}');
Sigurd Meldgaard . resolved

Consider handling this more gracefully. The user could have a corrupt installation, we should report that nicely, not crash

Daco Harkes

Done

File pkg/dartdev/lib/src/commands/uninstall.dart
Line 32, Patchset 15: 'Wrong number of arguments, expected "<package>", got "${args.join(' ')}"',
Sigurd Meldgaard . resolved

This reads a bit funny with 0 arguments,

Daco Harkes

Done

File pkg/dartdev/lib/src/install/pub_formats.dart
Line 35, Patchset 15: void writeSync(File file) {
Sigurd Meldgaard . resolved

Please don't write lock files and package configs if you can avoid it.
That should be the job of pub.

Daco Harkes

also removed package graphs.

File pkg/dartdev/test/commands/help_test.dart
Sigurd Meldgaard . unresolved

Can we have these below the project? They seem

Daco Harkes

I think currently this is not possible, I've filed https://github.com/dart-lang/core/issues/901

File pkg/dartdev/test/native_assets/helpers.dart
Line 43, Patchset 15: // Don't fail on files being in use.
Sigurd Meldgaard . resolved

Consider retrying after a delay on windows

Daco Harkes

I think that will make the experience slower than necessary. And might not help with anything.

Open in Gerrit

Related details

Attention is currently required from:
  • Michael Goderbauer
  • Sigurd Meldgaard
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Gerrit-Change-Number: 441581
Gerrit-PatchSet: 16
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Michael Goderbauer <goder...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Attention: Michael Goderbauer <goder...@google.com>
Gerrit-Attention: Sigurd Meldgaard <sig...@google.com>
Gerrit-Comment-Date: Mon, 11 Aug 2025 11:30:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Daco Harkes <dacoh...@google.com>
Comment-In-Reply-To: Michael Goderbauer <goder...@google.com>
Comment-In-Reply-To: Sigurd Meldgaard <sig...@google.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Michael Goderbauer (Gerrit)

unread,
Aug 12, 2025, 8:02:02 AM8/12/25
to Daco Harkes, Sigurd Meldgaard, Commit Queue, rev...@dartlang.org
Attention needed from Daco Harkes and Sigurd Meldgaard

Michael Goderbauer voted and added 4 comments

Votes added by Michael Goderbauer

Code-Review+1

4 comments

File pkg/dartdev/lib/src/commands/install.dart
Line 25, Patchset 17 (Latest):You can specify three different values the <package> argument:
Michael Goderbauer . unresolved

This sentence is missing something, maybe:

Line 45, Patchset 17 (Latest): help: 'Path of git package in repository'
Michael Goderbauer . unresolved

Here and below: Doesn't this need a trailing whitespace in the string?

```suggestion
help: 'Path of git package in repository. '
```
Line 51, Patchset 17 (Latest): help: 'Git branch or commit to be retrieved'
Michael Goderbauer . unresolved

Same

File pkg/dartdev/test/native_assets/install_test.dart
Line 100, Patchset 17 (Latest): --git-path Path of git package in repositoryOnly applies when using a git url for <package>.
Michael Goderbauer . resolved

The test caught the missing white space :)

Open in Gerrit

Related details

Attention is currently required from:
  • Daco Harkes
  • Sigurd Meldgaard
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Gerrit-Change-Number: 441581
Gerrit-PatchSet: 17
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Michael Goderbauer <goder...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Attention: Daco Harkes <dacoh...@google.com>
Gerrit-Attention: Sigurd Meldgaard <sig...@google.com>
Gerrit-Comment-Date: Tue, 12 Aug 2025 12:01:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Daco Harkes (Gerrit)

unread,
Aug 12, 2025, 8:45:35 AM8/12/25
to Michael Goderbauer, Sigurd Meldgaard, Commit Queue, rev...@dartlang.org
Attention needed from Sigurd Meldgaard

Daco Harkes voted and added 3 comments

Votes added by Daco Harkes

Commit-Queue+1

3 comments

File pkg/dartdev/lib/src/commands/install.dart
Line 25, Patchset 17:You can specify three different values the <package> argument:
Michael Goderbauer . resolved

This sentence is missing something, maybe:

Daco Harkes

Done

Line 45, Patchset 17: help: 'Path of git package in repository'
Michael Goderbauer . resolved

Here and below: Doesn't this need a trailing whitespace in the string?

```suggestion
help: 'Path of git package in repository. '
```
Daco Harkes

Done

Line 51, Patchset 17: help: 'Git branch or commit to be retrieved'
Michael Goderbauer . resolved

Same

Daco Harkes

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Sigurd Meldgaard
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Gerrit-Change-Number: 441581
Gerrit-PatchSet: 18
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Michael Goderbauer <goder...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Attention: Sigurd Meldgaard <sig...@google.com>
Gerrit-Comment-Date: Tue, 12 Aug 2025 12:45:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Michael Goderbauer <goder...@google.com>
satisfied_requirement
open
diffy

Sigurd Meldgaard (Gerrit)

unread,
Aug 12, 2025, 9:28:33 AM8/12/25
to Daco Harkes, Michael Goderbauer, Commit Queue, rev...@dartlang.org
Attention needed from Daco Harkes

Sigurd Meldgaard added 2 comments

File pkg/dartdev/lib/src/commands/uninstall.dart
Line 14, Patchset 18 (Latest):Complete deletes all installed versions of <package> and all executables from
Sigurd Meldgaard . unresolved

Typo

File pkg/dartdev/lib/src/install/file_system.dart
Line 316, Patchset 18 (Latest):extension DirectoryExetnsion on Directory {
Sigurd Meldgaard . unresolved

Typo

Open in Gerrit

Related details

Attention is currently required from:
  • Daco Harkes
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Gerrit-Change-Number: 441581
Gerrit-PatchSet: 18
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Michael Goderbauer <goder...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Attention: Daco Harkes <dacoh...@google.com>
Gerrit-Comment-Date: Tue, 12 Aug 2025 13:28:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
open
diffy

Sigurd Meldgaard (Gerrit)

unread,
Aug 12, 2025, 9:28:43 AM8/12/25
to Daco Harkes, Michael Goderbauer, Commit Queue, rev...@dartlang.org
Attention needed from Daco Harkes

Sigurd Meldgaard voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Daco Harkes
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Gerrit-Change-Number: 441581
Gerrit-PatchSet: 18
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Michael Goderbauer <goder...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Attention: Daco Harkes <dacoh...@google.com>
Gerrit-Comment-Date: Tue, 12 Aug 2025 13:28:37 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Daco Harkes (Gerrit)

unread,
Aug 12, 2025, 9:32:57 AM8/12/25
to Sigurd Meldgaard, Michael Goderbauer, Commit Queue, rev...@dartlang.org

Daco Harkes voted and added 3 comments

Votes added by Daco Harkes

Commit-Queue+1

3 comments

File pkg/dartdev/lib/src/commands/uninstall.dart
Line 14, Patchset 18:Complete deletes all installed versions of <package> and all executables from
Sigurd Meldgaard . resolved

Typo

Daco Harkes

Done

Line 30, Patchset 18: Future<int> run() async {
Daco Harkes . unresolved

From a discussion with @sig...@google.com: We should delete the other versions of this package. This would align the behavior with `brew upgrade`. (`brew install` only applies to not yet installed packages, and `brew upgrade` upgrades the package deleting the previous version. We don't want two commands, so we do both in `dart install`.)

File pkg/dartdev/lib/src/install/file_system.dart
Line 316, Patchset 18:extension DirectoryExetnsion on Directory {
Sigurd Meldgaard . resolved

Typo

Daco Harkes

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Gerrit-Change-Number: 441581
Gerrit-PatchSet: 19
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Michael Goderbauer <goder...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Comment-Date: Tue, 12 Aug 2025 13:32:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Sigurd Meldgaard <sig...@google.com>
satisfied_requirement
open
diffy

Daco Harkes (Gerrit)

unread,
Aug 12, 2025, 10:56:06 AM8/12/25
to Sigurd Meldgaard, Michael Goderbauer, Commit Queue, rev...@dartlang.org

Daco Harkes voted and added 2 comments

Votes added by Daco Harkes

Commit-Queue+1

2 comments

Patchset-level comments
File-level comment, Patchset 20 (Latest):
Daco Harkes . resolved

Thanks Michael and Sigurd!

File pkg/dartdev/lib/src/commands/uninstall.dart
Line 30, Patchset 18: Future<int> run() async {
Daco Harkes . resolved

From a discussion with @sig...@google.com: We should delete the other versions of this package. This would align the behavior with `brew upgrade`. (`brew install` only applies to not yet installed packages, and `brew upgrade` upgrades the package deleting the previous version. We don't want two commands, so we do both in `dart install`.)

Daco Harkes

Done

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Gerrit-Change-Number: 441581
Gerrit-PatchSet: 20
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Michael Goderbauer <goder...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Comment-Date: Tue, 12 Aug 2025 14:56:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Daco Harkes <dacoh...@google.com>
satisfied_requirement
open
diffy

Daco Harkes (Gerrit)

unread,
Aug 13, 2025, 3:34:37 AM8/13/25
to Sigurd Meldgaard, Michael Goderbauer, Commit Queue, rev...@dartlang.org

Daco Harkes voted Commit-Queue+2

Commit-Queue+2
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Gerrit-Change-Number: 441581
Gerrit-PatchSet: 21
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Daco Harkes <dacoh...@google.com>
Gerrit-Reviewer: Michael Goderbauer <goder...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Comment-Date: Wed, 13 Aug 2025 07:34:32 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Commit Queue (Gerrit)

unread,
Aug 13, 2025, 4:34:03 AM8/13/25
to Daco Harkes, Sigurd Meldgaard, Michael Goderbauer, rev...@dartlang.org

Commit Queue submitted the change with unreviewed changes

Unreviewed changes

18 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: pkg/dartdev/test/native_assets/install_test.dart
Insertions: 51, Deletions: 19.

@@ -82,13 +82,15 @@
(
'install',
'''
-Install a Dart CLI tool for global use.
+Install or upgrade a Dart CLI tool for global use.

Install all executables specified in a package's pubspec.yaml executables
section (https://dart.dev/tools/pub/pubspec#executables) on the PATH. If the
executables section doesn't exist, installs all `bin/*.dart` entry points as
executables.

+If the same package has been previously installed, it will be overwritten.
+
You can specify three different values for the <package> argument:
1. A package name. This will install the package from pub.dev. (hosted)
The [version-constraint] argument can only be passed to 'hosted'.
@@ -125,7 +127,7 @@
'''
Remove a globally installed Dart CLI tool.

-Complete deletes all installed versions of <package> and all executables from
+Completely deletes all installed versions of <package> and all executables from
<package> placed on PATH.

Usage: dart uninstall <package>
@@ -449,7 +451,7 @@
final pubspecFile = File.fromUri(dartAppUri.resolve('pubspec.yaml'));
final pubspecContents = await pubspecFile.readAsString();
final pubspecContentsNew =
- pubspecContents.replaceFirst('dart_app', 'dart_app_renamed');
+ pubspecContents.replaceFirst('dart_app', 'a_different_name');
await pubspecFile.writeAsString(pubspecContentsNew);

// Trying to install an executable with the same name from a different
@@ -471,6 +473,35 @@
null,
environment,
);
+
+ // Using --overwrite leads to inactive versions.
+ // `dart installed --all` should also report the non-active versions.
+ for (final all in [true, false]) {
+ final installedResult = await _runDartdev(
+ fromDartdevSource,
+ 'installed',
+ [if (all) '--all'],
+ null,
+ environment,
+ );
+ final installedLines = installedResult.stdout
+ .split('\n')
+ .where((e) => e.isNotEmpty)
+ .toList();
+ if (all) {
+ expect(installedLines, hasLength(2));
+ expect(
+ installedLines,
+ contains(startsWith('dart_app')),
+ );
+ } else {
+ expect(installedLines, hasLength(1));
+ expect(
+ installedLines,
+ isNot(contains(startsWith('dart_app'))),
+ );
+ }
+ }
});
});
});
@@ -612,7 +643,8 @@
});
});

- skippableTest('dart installed --all', timeout: longTimeout, () async {
+ skippableTest('dart install uninstalls old versions', timeout: longTimeout,
+ () async {
await inTempDir((tempUri) async {
final binDir = Directory.fromUri(tempUri.resolve('install/bin'));

@@ -630,28 +662,36 @@
_packageDir.uri,
environment,
);
- await _runDartdev(
+ final installResult = await _runDartdev(
fromDartdevSource,
'install',
[_packageForTest, _packageVersion],
null,
environment,
);
+ expect(
+ installResult.stdout,
+ stringContainsInOrder(['Uninstalling ', _packageForTest]),
+ );

// `--all` should also report the non-active versions.
- for (final all in [true, false]) {
+ Future<List<String>> runInstalled() async {
final installedResult = await _runDartdev(
fromDartdevSource,
'installed',
- [if (all) '--all'],
+ ['--all'],
null,
environment,
);
- final installedLines = installedResult.stdout.split('\n');
- expect(installedLines.where((e) => e.isNotEmpty).length,
- equals(all ? 2 : 1));
+ final installedLines = installedResult.stdout
+ .split('\n')
+ .where((e) => e.isNotEmpty)
+ .toList();
+ return installedLines;
}

+ expect(await runInstalled(), hasLength(1));
+
// `uninstall` uninstalls all versions.
await _runDartdev(
fromDartdevSource,
@@ -660,15 +700,7 @@
null,
environment,
);
- final installedResult = await _runDartdev(
- fromDartdevSource,
- 'installed',
- ['--all'],
- null,
- environment,
- );
- final installedLines = installedResult.stdout.split('\n');
- expect(installedLines.where((e) => e.isNotEmpty), isEmpty);
+ expect(await runInstalled(), hasLength(0));
});
});

```
```
The name of the file: pkg/dartdev/lib/src/install/file_system.dart
Insertions: 1, Deletions: 1.

@@ -313,6 +313,6 @@
bool equals(ExecutableInBundle other) => file.path == other.file.path;
}

-extension DirectoryExetnsion on Directory {
+extension DirectoryExtension on Directory {
Directory get ensureEndWithSeparator => Directory.fromUri(uri);
}
```
```
The name of the file: pkg/dartdev/lib/src/commands/uninstall.dart
Insertions: 1, Deletions: 1.

@@ -11,7 +11,7 @@
static const cmdName = 'uninstall';
static const cmdDescription = '''Remove a globally installed Dart CLI tool.

-Complete deletes all installed versions of <package> and all executables from
+Completely deletes all installed versions of <package> and all executables from
<package> placed on PATH.''';

@override
```
```
The name of the file: pkg/dartdev/lib/src/commands/install.dart
Insertions: 26, Deletions: 1.

@@ -15,13 +15,16 @@

class InstallCommand extends DartdevCommand {
static const cmdName = 'install';
- static const cmdDescription = '''Install a Dart CLI tool for global use.
+ static const cmdDescription =
+ '''Install or upgrade a Dart CLI tool for global use.

Install all executables specified in a package's pubspec.yaml executables
section (https://dart.dev/tools/pub/pubspec#executables) on the PATH. If the
executables section doesn't exist, installs all `bin/*.dart` entry points as
executables.

+If the same package has been previously installed, it will be overwritten.
+
You can specify three different values for the <package> argument:
1. A package name. This will install the package from pub.dev. (hosted)
The [version-constraint] argument can only be passed to 'hosted'.
@@ -270,6 +273,26 @@
}
}

+ void _uniinstallAllPackageVersions(String packageName) {
+ final bundles =
+ DartInstallDirectory().allAppBundlesSync(packageName: packageName);
+
+ try {
+ for (final bundle in bundles) {
+ print('Uninstalling ${bundle.directory.path}.');
+ final links = bundle.executablesOnPathSync;
+ for (final link in links) {
+ print('Deleting ${link.entity.path}');
+ link.deleteSync();
+ }
+ print('Deleting ${bundle.directory.path}');
+ bundle.directory.deleteSync(recursive: true);
+ }
+ } on PathAccessException {
+ _installException('Deletion failed. The application might be in use.');
+ }
+ }
+
AppBundleDirectory _selectAppBundleDirectory(
_InstallCommandParsedArguments parsedArgs,
String packageName,
@@ -480,6 +503,8 @@
sourcePackagePubspecFile,
);

+ _uniinstallAllPackageVersions(packageName);
+
AppBundleDirectory appBundleDirectory = _selectAppBundleDirectory(
parsedArgs,
packageName,
```
```
The name of the file: pkg/dartdev/test/commands/help_test.dart
Insertions: 1, Deletions: 1.

@@ -80,7 +80,7 @@
Available commands:

Global
- install Install a Dart CLI tool for global use.
+ install Install or upgrade a Dart CLI tool for global use.
installed List globally installed Dart CLI tools.
uninstall Remove a globally installed Dart CLI tool.

```

Change information

Commit message:
[dartdev] `dart install`

This CL adds three new commands to `dart`:

```
Global
install Install a Dart CLI tool for global use.
installed List globally installed Dart CLI tools.
uninstall Remove a globally installed Dart CLI tool.
```

These commands are intended to replace `dart pub global` subcommands
while adding support for `hook/build.dart` and building packages in
AOT instead of running them with JIT.

Internal design doc: http://go/dart-install-cli.

Implementation details:
* The source of truth is the state of the file system. These commands
write and read directories, files, and symlinks.
* App bundles and symlinks are placed in `DART_DATA_HOME` as per
http://go/dart-data-home.
* On Unix systems we use symlinks and on Windows batchfiles to place
executables in the bin directory that point to an application
bundle. (These OS differences have been encapsulated in a single
class.)
* On Windows, when an application is running, trying to re-install it
will fail.

Test coverage:
* Installing from hosted, git, and local paths.
* Installing a package with hooks.
* Installing a package with hooks and user-defines.
* Surfacing build hook failures during install.
* Installing packages with conflicting executables names. This tests
`--overwrite` flag behavior.
* Installing a new or the same version, this should simply succeed.
* A warning is shown if the bin directory is not on the `PATH`.
* Running an installed app reports the correct exit code on exit.
* Listing all installed versions, including the versions not on
the`PATH`.
* Uninstalling, which uninstalls all versions.
* Re-installing while it is running.
* Uninstalling while it is running.

Out of scope for initial version:
* Saving the SDK version (to display in `dart installed`).
* Short-circuiting if re-installing an exactly installed version.
Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try
Reviewed-by: Sigurd Meldgaard <sig...@google.com>
Commit-Queue: Daco Harkes <dacoh...@google.com>
Reviewed-by: Michael Goderbauer <goder...@google.com>
Files:
  • M pkg/dartdev/lib/dartdev.dart
  • M pkg/dartdev/lib/src/commands/build.dart
  • A pkg/dartdev/lib/src/commands/install.dart
  • A pkg/dartdev/lib/src/commands/installed.dart
  • A pkg/dartdev/lib/src/commands/uninstall.dart
  • M pkg/dartdev/lib/src/core.dart
  • A pkg/dartdev/lib/src/install/file_system.dart
  • A pkg/dartdev/lib/src/install/pub_formats.dart
  • M pkg/dartdev/lib/src/utils.dart
  • M pkg/dartdev/pubspec.yaml
  • M pkg/dartdev/test/commands/help_test.dart
  • M pkg/dartdev/test/native_assets/helpers.dart
  • A pkg/dartdev/test/native_assets/install_test.dart
  • M pubspec.yaml
Change size: XL
Delta: 14 files changed, 2325 insertions(+), 89 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Sigurd Meldgaard, +1 by Michael Goderbauer
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I8f3a60d26e013957ce6fd7f52e564bcaaff30509
Gerrit-Change-Number: 441581
Gerrit-PatchSet: 22
Gerrit-Owner: Daco Harkes <dacoh...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages