Skip to content

Commit 832f5a7

Browse files
sigurdmericwindmillMaryaBelanger
authored
Add section about stray files (#6274)
In support of dart-lang/pub#4446 --------- Co-authored-by: Eric Windmill <eric@ericwindmill.com> Co-authored-by: Marya <111139605+MaryaBelanger@users.noreply.github.com>
1 parent 30e7188 commit 832f5a7

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

firebase.json

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
{ "source": "/go/flutter-upper-bound-deprecation", "destination": "https://github.com/flutter/flutter/issues/68143", "type": 301 },
180180
{ "source": "/go/macros", "destination": "/language/macros", "type": 301 },
181181
{ "source": "/go/pub-workspaces", "destination": "/tools/pub/workspaces", "type": 301 },
182+
{ "source": "/go/workspaces-stray-files", "destination": "/guides/workspaces#stray-files", "type": 301 },
182183
{ "source": "/go/non-promo-conflicting-getter", "destination": "/tools/non-promotion-reasons#getter-name", "type": 301 },
183184
{ "source": "/go/non-promo-conflicting-non-promotable-field", "destination": "/tools/non-promotion-reasons#field-name", "type": 301 },
184185
{ "source": "/go/non-promo-conflicting-noSuchMethod-forwarder", "destination": "/tools/non-promotion-reasons#nosuchmethod", "type": 301 },

src/content/tools/pub/workspaces.md

+41
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,47 @@ To use pub workspaces, all your workspace packages (but not your dependencies)
107107
must have an SDK version constraint of `^3.6.0` or higher.
108108
:::
109109

110+
<a name='stray-files'></a>
111+
## Stray files
112+
113+
When you migrate an existing monorepo to use Pub workspaces, there will
114+
be existing "stray" `pubspec.lock` and `.dart_tool/package_config.json` files
115+
adjacent to each pubspec. These shadow the `pubspec.lock` and
116+
`.dart_tool/package_config.json` files placed next to the root.
117+
118+
Therefore, `pub get` will delete any `pubspec.lock` and
119+
`.dart_tool/package_config.json` located in directories between the root and
120+
(including) any workspace package.
121+
122+
```plaintext
123+
/
124+
pubspec.yaml # Root
125+
packages/
126+
pubspec.lock # Deleted by `pub get`
127+
.dart_tool/package_config.json # Deleted by `pub get`
128+
foo/
129+
pubspec.yaml # Workspace member
130+
pubspec.lock # Deleted by `pub get`
131+
.dart_tool/package_config.json # Deleted by `pub get`
132+
```
133+
134+
If any directory between the workspace root and a workspace package contains a
135+
"stray" `pubspec.yaml` file that is not member of the workspace, `pub get` will
136+
report an error and fail to resolve. This is because resolving such a `pubspec.yaml` would
137+
create a `.dart_tool/package_config.json` file that shadows the one at the root.
138+
139+
For example:
140+
141+
```plaintext
142+
/
143+
pubspec.yaml # Root `workspace: ['foo/']`
144+
packages/
145+
pubspec.yaml # Not workspace member => error
146+
foo/
147+
pubspec.yaml # Workspace member
148+
```
149+
150+
110151
## Interdependencies between workspace packages
111152

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

0 commit comments

Comments
 (0)