Skip to content
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

Add section about stray files #6274

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 are migrating an existing mono-repo to use Pub workspaces, there will
be existing "stray" `pubspec.lock` and `.dart_tool/package_config.json` files
adjacent to each pubspec. These would shadow the `pubspec.lock` and
`.dart_tool/package_config.json` 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, as 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
Loading