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

[Bug]: storybook init fails to setup dependencies correctly when --skip-install install is set in ci/cd pipeline #27096

Closed
manuel3108 opened this issue May 11, 2024 · 4 comments · Fixed by #28226

Comments

@manuel3108
Copy link

manuel3108 commented May 11, 2024

Describe the bug

This is the package.json that was produced by the storybook cli:

{
  "name": "storybook-missing-packages-repro",
  // ...
  "scripts": {
    // ...
    "storybook": "storybook dev -p 6006",
    "build-storybook": "storybook build"
  },
  "devDependencies": {
    "@sveltejs/vite-plugin-svelte": "^3.0.2",
    "svelte": "^4.2.12",
    "vite": "^5.2.0",
    "@chromatic-com/storybook": "^1.3.5"
  }
}

The initializer only added @chromatic-com/storybook for whatever reason, and skips adding all other packages, although the cli output says Getting the correct version of 9 packages. Therefore I would expect to see 9 additional packages in my package.json

Only happens if --skip-install is set. Otherwise everything works correctly.

To Reproduce

Here is a simple github workflow to try it out: https://github.com/manuel3108/storybook-missing-packages-repro/blob/test-2/.github/workflows/pr.yml

name: Pull requests
# ...
jobs:
    test:
        timeout-minutes: 30
        runs-on: ubuntu-latest
        steps:
           # ...

            - name: cat package.json
              run: cat package.json

            - name: add storybook
              run: npx storybook init --skip-install

            - name: cat package.json
              run: cat package.json

You can find the latest workflow output here: https://github.com/manuel3108/storybook-missing-packages-repro/actions/runs/9045619764/job/24855552856

System

Storybook Environment Info:

  System:
    OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (4) x64 AMD EPYC 7763 64-Core Processor
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.12.2 - /opt/hostedtoolcache/node/20.12.2/x64/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.5.0 - /opt/hostedtoolcache/node/20.12.2/x64/bin/npm <----- active
    pnpm: 9.1.0 - /opt/hostedtoolcache/node/20.12.2/x64/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.60

Additional context

No response

Tasks

No tasks being tracked yet.
@vanessayuenn
Copy link
Contributor

@manuel3108 thanks for opening this issue. Can you clarify your expectation of running init with the --skip-install flag? The behaviour you described seems expected to me but I want to make sure I would like to understand your usecase.

@manuel3108
Copy link
Author

@vanessayuenn As of my understanding --skip-install should only skip the installation of dependencies to the local system, aka running (p)npm install. But I would still expect it that with this flag the package.json file is updated correctly, which is not currently the case as it's only adding 1 out of 9 required dependencies to this file.

As of this point I'm not 100% what exectly causes this issue, as I am unable to reproduce this locally at all, running a windows machine. I suspect the env variable CI with value true might play a role in this.

@benmccann
Copy link
Contributor

It looks like it tries to run the install before and after setting up storybook. I guess the storybook setup must somehow depend on the libraries being installed

if (!options.skipInstall) {

@manuel3108
Copy link
Author

Thanks to @AdrianGonz97 who fortunately found out that somehow this bug has already fixed in the next version. He was not able to find any related commits / PR that explicitly fixed that, but we can confirm that this does not happen when using next.

I have updated the sample workflow provided above to use next and then everything started working as expected. The bug is therefore fixed and I'm going to close this issue.

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

Successfully merging a pull request may close this issue.

4 participants