Skip to content
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
4 changes: 4 additions & 0 deletions examples/node-yarn-workspaces-nested/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.pnp.cjs
.pnp.loader.mjs
.yarn/install-state.gz
1 change: 1 addition & 0 deletions examples/node-yarn-workspaces-nested/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: pnp
36 changes: 36 additions & 0 deletions examples/node-yarn-workspaces-nested/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# node-yarn-workspaces-nested

Reproduces [#463](https://github.com/railwayapp/railpack/issues/463): a Yarn
Berry monorepo with a deeply-nested workspace package causes a phantom duplicate
directory inside the container, making `yarn install` fail.

## Structure

The workspace glob is `packages/**/*` (recursive), with a package at
`packages/prisma/timescaledb/`. The intermediate directory `packages/prisma/`
happens to be named `prisma`, which matches the `prisma` entry in
`SupportingInstallFiles`.

## The bug

`SupportingInstallFiles` returns both:

- `packages/prisma/timescaledb/package.json` (matched as a file)
- `packages/prisma` (matched as a directory named `prisma`)

This produces two copy commands in the build plan:

1. `copy packages/prisma/timescaledb/package.json` → creates
`/app/packages/prisma/timescaledb/`
2. `copy packages/prisma → packages/prisma` → because BuildKit uses
`CopyDirContentsOnly: false`, the directory `prisma/` is placed *inside*
`/app/packages/prisma/`, creating the phantom
`/app/packages/prisma/prisma/timescaledb/`

Yarn then sees two workspaces with the same name and fails:

```
Internal Error: Duplicate workspace name @wildmetrics/prisma-timescale:
/app/packages/prisma/timescaledb conflicts with
/app/packages/prisma/prisma/timescaledb
```
2 changes: 2 additions & 0 deletions examples/node-yarn-workspaces-nested/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { message } from "@wildmetrics/prisma-timescale";
console.log(message);
16 changes: 16 additions & 0 deletions examples/node-yarn-workspaces-nested/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "node-yarn-workspaces-nested",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"start": "node index.js"
},
"workspaces": [
"packages/**/*"
],
"dependencies": {
"@wildmetrics/prisma-timescale": "workspace:*"
},
"packageManager": "yarn@4.5.3"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const message = "hello from timescaledb package";
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@wildmetrics/prisma-timescale",
"version": "1.0.0",
"type": "module",
"main": "index.js"
}
5 changes: 5 additions & 0 deletions examples/node-yarn-workspaces-nested/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{
"expectedOutput": "hello from timescaledb package"
}
]
20 changes: 20 additions & 0 deletions examples/node-yarn-workspaces-nested/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!

__metadata:
version: 8
cacheKey: 10c0

"@wildmetrics/prisma-timescale@workspace:*, @wildmetrics/prisma-timescale@workspace:packages/prisma/timescaledb":
version: 0.0.0-use.local
resolution: "@wildmetrics/prisma-timescale@workspace:packages/prisma/timescaledb"
languageName: unknown
linkType: soft

"node-yarn-workspaces-nested@workspace:.":
version: 0.0.0-use.local
resolution: "node-yarn-workspaces-nested@workspace:."
dependencies:
"@wildmetrics/prisma-timescale": "workspace:*"
languageName: unknown
linkType: soft
Loading