pulumi: yarn workspaces + nested pulumi project + local package reference = "Could not include required dependency"
Here’s a gutted project structure that matches what I’m trying to get working:
https://github.com/brandonbloom/pulumi-workspaces-repro
In short, there are three packages: “core”, “local”, and “cloud”. The bulk of the code is implemented in “core” and local development primarily operates via ts-node-dev
running “local/index.ts”, which imports “core”. Then, there is a “cloud” package, which hosts the Pulumi bits, which also reuses core. Yarn creates a single top-level node_modules
directory, and attempting to import core produces this error: Could not include required dependency 'example-core'
As a workaround, I’ve added an index.ts
file that does require('./packages/cloud')
in the root and moved the Pulumi *.yaml
files to the root as well. Now pulumi up
works if you omit -C packages/cloud
, but I’d like to keep the Pulumi files contained to their package.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 20
- Comments: 22 (6 by maintainers)
Commits related to this issue
- Enable workaround for Yarn workspaces for inline functions See https://github.com/pulumi/pulumi/issues/2661\#issuecomment-939531284 for context. Bascially, yarn workspaces rely on symlinks for monor... — committed to liamawhite/pulumi by liamawhite 3 years ago
- Enable workaround for Yarn workspaces for inline functions (#8215) See https://github.com/pulumi/pulumi/issues/2661\#issuecomment-939531284 for context. Bascially, yarn workspaces rely on symlinks... — committed to pulumi/pulumi by liamawhite 3 years ago
- WIP DynamoDB from Lambda Two issues: 1. Pulumi can't bundle dependencies from node_modules in the project root. See https://github.com/pulumi/pulumi/issues/2661 Creating a symlink from node_mod... — committed to skill-collectors/guesstimator by dave-burke 2 years ago
- WIP DynamoDB from Lambda Two issues: 1. Pulumi can't bundle dependencies from node_modules in the project root. See https://github.com/pulumi/pulumi/issues/2661 Creating a symlink from node_mod... — committed to skill-collectors/guesstimator by dave-burke 2 years ago
- WIP DynamoDB from Lambda Two issues: 1. Pulumi can't bundle dependencies from node_modules in the project root. See https://github.com/pulumi/pulumi/issues/2661 Creating a symlink from node_mod... — committed to skill-collectors/guesstimator by dave-burke 2 years ago
- WIP DynamoDB from Lambda Two issues: 1. Pulumi can't bundle dependencies from node_modules in the project root. See https://github.com/pulumi/pulumi/issues/2661 Creating a symlink from node_mod... — committed to skill-collectors/guesstimator by dave-burke 2 years ago
- WIP DynamoDB from Lambda Two issues: 1. Pulumi can't bundle dependencies from node_modules in the project root. See https://github.com/pulumi/pulumi/issues/2661 Creating a symlink from node_mod... — committed to skill-collectors/guesstimator by dave-burke 2 years ago
- Call DynamoDB from Lambda Two issues: 1. Pulumi can't bundle dependencies from node_modules in the project root. See https://github.com/pulumi/pulumi/issues/2661 Creating a symlink from node_mo... — committed to skill-collectors/guesstimator by dave-burke 2 years ago
- Call DynamoDB from Lambda Two issues: 1. Pulumi can't bundle dependencies from node_modules in the project root. See https://github.com/pulumi/pulumi/issues/2661 Creating a symlink from node_mo... — committed to skill-collectors/guesstimator by dave-burke 2 years ago
- Call DynamoDB from Lambda Two issues: 1. Pulumi can't bundle dependencies from node_modules in the project root. See https://github.com/pulumi/pulumi/issues/2661 Creating a symlink from node_mo... — committed to skill-collectors/guesstimator by dave-burke 2 years ago
I think you should just go to packages/cloud and run
yarn add ...
with all pulimi packages that you are going to use in that directory instead of just hoping that it will be requires from rootLooked into this a little today.
It appears the issue is that we use https://github.com/npm/read-package-tree to read the local
package.json
and recursively walk dependencies and theirpackage.json
s to find the transitive dependencies of a package. However,read-pacakge-tree
does not handle Yarn Workspaces. It assumes that wherever thepackage.json
file is, thenode_modules
next to it will contain all of the child modules that are directdependencies
of thatpackage.json
.https://github.com/npm/read-package-tree/blob/master/rpt.js#L109
We will likely either need to maintain a fork of
read-package-tree
that handles this case, or abandonread-package-tree
and find a way to construct these dependencies more directly.@vvo this only works for Yarn v1. This option is gone for Yarn v2.
Facing the same issue here in a yarn workspaces + lerna monorepo. I have a
common
package where I have shared code. I’m getting the sameCould not include required dependency '@project/common'
error. Is there plans to add support for this?Following this as well, we’ve had in other solutions to really work hard to get around this. Having first class support for this would be a huge win over many other platform.
@DanNeish I’ve now switched my approach and am building out an NX plugin to make it easy to use Pulumi in an nx.dev mono repo.
I am now trying to create a small pulumi program for each service in the mono repo, then working towards being able to
nx affected:up
to deploy the appropriate stacks which have changes using NX’s impact analysis.Has there been any movement on this issue?
As it stands it does not seem like pulumi works with yarn workspaces.