Skip to content

Commit

Permalink
Add section about stray files (#6274)
Browse files Browse the repository at this point in the history
In support of dart-lang/pub#4446

---------

Co-authored-by: Eric Windmill <[email protected]>
Co-authored-by: Marya <[email protected]>
  • Loading branch information
3 people authored Jan 8, 2025
1 parent 30e7188 commit 832f5a7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
{ "source": "/go/flutter-upper-bound-deprecation", "destination": "https://github.com/flutter/flutter/issues/68143", "type": 301 },
{ "source": "/go/macros", "destination": "/language/macros", "type": 301 },
{ "source": "/go/pub-workspaces", "destination": "/tools/pub/workspaces", "type": 301 },
{ "source": "/go/workspaces-stray-files", "destination": "/guides/workspaces#stray-files", "type": 301 },
{ "source": "/go/non-promo-conflicting-getter", "destination": "/tools/non-promotion-reasons#getter-name", "type": 301 },
{ "source": "/go/non-promo-conflicting-non-promotable-field", "destination": "/tools/non-promotion-reasons#field-name", "type": 301 },
{ "source": "/go/non-promo-conflicting-noSuchMethod-forwarder", "destination": "/tools/non-promotion-reasons#nosuchmethod", "type": 301 },
Expand Down
41 changes: 41 additions & 0 deletions src/content/tools/pub/workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,47 @@ To use pub workspaces, all your workspace packages (but not your dependencies)
must have an SDK version constraint of `^3.6.0` or higher.
:::

<a name='stray-files'></a>
## Stray files

When you migrate an existing monorepo to use Pub workspaces, there will
be existing "stray" `pubspec.lock` and `.dart_tool/package_config.json` files
adjacent to each pubspec. These shadow the `pubspec.lock` and
`.dart_tool/package_config.json` files placed next to the root.

Therefore, `pub get` will delete any `pubspec.lock` and
`.dart_tool/package_config.json` located in directories between the root and
(including) any workspace package.

```plaintext
/
pubspec.yaml # Root
packages/
pubspec.lock # Deleted by `pub get`
.dart_tool/package_config.json # Deleted by `pub get`
foo/
pubspec.yaml # Workspace member
pubspec.lock # Deleted by `pub get`
.dart_tool/package_config.json # Deleted by `pub get`
```

If any directory between the workspace root and a workspace package contains a
"stray" `pubspec.yaml` file that is not member of the workspace, `pub get` will
report an error and fail to resolve. This is because resolving such a `pubspec.yaml` would
create a `.dart_tool/package_config.json` file that shadows the one at the root.

For example:

```plaintext
/
pubspec.yaml # Root `workspace: ['foo/']`
packages/
pubspec.yaml # Not workspace member => error
foo/
pubspec.yaml # Workspace member
```


## Interdependencies between workspace packages

If any of the workspace packages depend on each other, they will automatically
Expand Down

0 comments on commit 832f5a7

Please sign in to comment.