Skip to content

[breaking change] discontinue .packages file #48272

Closed
@mit-mit

Description

@mit-mit

Intended change in behaviour

When the commands dart pub get or flutter pub get are executed, pub resolves all dependencies, and downloads those dependencies to the local pub cache. It furthermore creates a mapping from each used package to their location on the local file system. Today this mapping is stored in two files:

  • .dart_tool/package_config.json
  • .packages (legacy, as of Dart 2.8.0)

The former of these is the file that the current SDKs rely on. The latter has until now been generated for backwards compatibility with older Dart SDKs. After the present breaking change is made, we'll change pub get to only generate the former (.dart_tool/package_config.json), and the Dart SDK will no longer be able to read the .packages file.

Rationale for making the change

The .packages file is left-over from older Dart SDKs and is not fully compatible with Dart 2.x SDKs (it, for example, doesn’t support language versioning). We're removing the generation of .packages to prevent having extraneous files in the file system, and to prevent corner-case bugs that may occur if both files are around, but in an inconsistent state.

Expected impact of this change.

Regular apps and packages that are written using Dart 2.x will not be impacted, as they rely on .dart_tool/package_config.json.

If you already have a .packages file, you can delete it. After upgrading your Dart SDK it will no longer be generated, and pub will delete it when pub get runs.

Developer tools that need to look up the packages used by a project, and their locations on the file system, will no longer be able to rely on the .packages file. Such tools should be upgraded to rely on the content of the package_config.json file. Rather than reading this file directly, we strongly recommend using the API for consuming it available in package:package_config.

If you are passing a .packages file to the dart command (dart --packages=.packages) you'll need to pass the package config instead (dart --packages=.dart_tool/package_config.json).

Steps for mitigating the change

If you for some reason depend on this legacy file, you will for one stable release be able to generate it by passing the flag --legacy-packages-file to dart pub get / flutter pub get. After one stable release, this flag will be removed, and all support for generating the legacy file be removed. Note however this this is only being offered for external tools that may depend on the .packages file; all tools offered by the Dart team will no longer support this .packages file.

Timeline

The change to no longer generate .packages, and to remove support for reading that file in tools offered by the Dart team / the Dart SDK, will be made in a dev-channel release of Dart 2.18.

The --legacy-packages-file flag -- which offers a temporary solution for retaining the generation of .packages for other legacy tools -- will be removed one release later in a dev-channel release of Dart 2.19.

Related issues

In the Dart 2.18 stable release:

In the following Dart 2.19 stable release:

Metadata

Metadata

Assignees

Labels

area-metaCross-cutting, high-level issues (for tracking many other implementation issues, ...).area-sdkUse area-sdk for general purpose SDK issues (packaging, distribution, …).breaking-change-requestThis tracks requests for feedback on breaking changes

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions