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

Build issue with yarn 2 when not in git or svn context #14042

Open
pebowman opened this issue Feb 24, 2021 · 4 comments
Open

Build issue with yarn 2 when not in git or svn context #14042

pebowman opened this issue Feb 24, 2021 · 4 comments

Comments

@pebowman
Copy link

Describe the bug
I found that a local build of storybook worked fine, but the same thing refused to build in Docker. After much hair-pulling, I discovered that it did work if the compilation occurred in the context of a git repo. The .git directory was quite reasonably being excluded from the Docker image.

In getProjectRoot(), the root is found by looking for a .git, .svn or node_modules directory, with process.cwd() as as fallback. However, in a Docker environment, there will be no .git or .svn and in yarn 2, there is no node_modules. It appears yarn 2 is presenting the cwd as a zip file.

This results in the following in the generated webpack:

module: {
  rules: [
    {
      test: /\.(mjs|tsx?|jsx?)$/,
      use: [ redacted ],
      include: [
        'D:\\react\a\\.yarn\\$virtual\\@storybook-core-virtual-0a602ea853\\0\\cache\\@storybook-core-npm-6.1.18-f25c70fd19-ac341dcf78.zip\\'

With .git present, it's

include: [ 'D:\\react\\a' ]

To Reproduce
Build in yarn 2 after deleting or renaming .git

Expected behavior
Build is successful

System
Repeatable on Windows/Ubuntu on WSL/node:current-alpine Docker image

@DerGary
Copy link

DerGary commented Nov 25, 2021

I'm having the same Issue, cost me about a day to figure this out. As a Workaround, creating an empty .git directory inside the docker build seems to work:

RUN mkdir .git

@stale
Copy link

stale bot commented Jan 9, 2022

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@dobesv
Copy link
Contributor

dobesv commented Jan 25, 2023

Note: If you run into this problem, you can create a folder named .svn in your project to trick storybook into using that to detect the project root.

@stale stale bot removed the inactive label Jan 25, 2023
@dobesv
Copy link
Contributor

dobesv commented Jan 25, 2023

in yarn 2, there is no node_modules. It appears yarn 2 is presenting the cwd as a zip file

Actually there's a node_modules folder in the ZIP file that getProjectRoot is detecting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants