berry icon indicating copy to clipboard operation
berry copied to clipboard

[Bug?]: Workspace not found (.) when running in Dockerfile

Open eliw00d opened this issue 4 years ago • 5 comments

Self-service

  • [ ] I'd be willing to implement a fix

Describe the bug

I get the following error when running yarn workspaces focus in a Dockerfile:

#8 2.572 ➤ YN0000: ┌ Resolution step                              
#8 2.796 ➤ YN0001: │ Error: serviceA@workspace:.: Workspace not found (.)                                                      
#8 2.796     at ie.getWorkspaceByCwd (/.yarn/releases/yarn-berry.cjs:2:359726)
#8 2.796     at n.resolve (/.yarn/releases/yarn-berry.cjs:2:409069)
#8 2.796     at n.resolve (/.yarn/releases/yarn-berry.cjs:2:343129)
#8 2.796     at n.resolve (/.yarn/releases/yarn-berry.cjs:2:343129)
#8 2.796     at /.yarn/releases/yarn-berry.cjs:2:363456
#8 2.796     at Module.w (/.yarn/releases/yarn-berry.cjs:2:424073)
#8 2.796     at d (/.yarn/releases/yarn-berry.cjs:2:363419)
#8 2.796     at /.yarn/releases/yarn-berry.cjs:2:364948
#8 2.796 ➤ YN0000: └ Completed in 0s 224ms
#8 2.797 ➤ YN0000: Failed with errors in 0s 229ms

To reproduce

Dockerfile

FROM node:fermium-alpine

COPY . .

RUN yarn workspaces focus serviceA

where . is something like:

.yarn
.yarnrc.yml
backend/services/serviceA/package.json // workspace
backend/package.json // worktree
frontend/applications/applicationA/package.json // workspace
frontend/package.json // worktree
package.json // worktree
yarn.lock

Environment

#8 9.160   System:
#8 9.160     OS: Linux 5.10 Alpine Linux
#8 9.160     CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
#8 9.160   Binaries:
#8 9.160     Node: 14.17.1 - /tmp/xfs-e2f7d520/node
#8 9.160     Yarn: 2.4.2 - /tmp/xfs-e2f7d520/yarn
#8 9.160     npm: 6.14.13 - /usr/local/bin/npm

Additional context

No response

eliw00d avatar Jun 28 '21 22:06 eliw00d

I ended up getting around this by setting WORKDIR to something other than /, such as /app:

FROM node:fermium-alpine

WORKDIR /app

COPY . .

RUN yarn workspaces focus serviceA

eliw00d avatar Jul 06 '21 20:07 eliw00d

I'll reopen since we should fix that bug

merceyz avatar Jul 15 '21 23:07 merceyz

Hi! 👋

This issue looks stale, and doesn't feature the reproducible label - which implies that you didn't provide a working reproduction using Sherlock. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it or you edit your first post to include a formal reproduction (you can use the playground for that).

Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolutions). It helps us help you! 😃

If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the upholded label. Thanks for helping us triaging our repository! 🌟

yarnbot avatar Aug 15 '21 00:08 yarnbot

Hi team,

Is there any follow-up action to this issue? Recently I met this problem again. I am using Yarn v4.7.0 to build docker image within a multi-workspace monorepo.

Hen3y avatar Mar 27 '25 02:03 Hen3y

Hi team,

Is there any follow-up action to this issue? Recently I met this problem again. I am using Yarn v4.7.0 to build docker image within a multi-workspace monorepo.

I moved all local packages from dependencies to devDependencies in the workspace I am trying to do docker build and this issue disappeared.

Hen3y avatar Apr 21 '25 15:04 Hen3y