storybook
storybook copied to clipboard
[Bug]: `upgrade` command always throws `UpgradeStorybookToSameVersionError` when using `pnpx`
Describe the bug
Running pnpm dlx storybook@next upgrade in @storybook/addon-onboarding throws UpgradeStorybookToSameVersionError
, although the project uses Storybook dependencies with the version 7.1.0-alpha.38. Everything works fine when using npx storybook@next
upgrade.
To Reproduce
-
npx storybook@latest sandbox
- cd into sandbox
-
pnpm install
-
pnpx storybook@next upgrade
- Get error
System
No response
Additional context
Originally posted by @valentinpalkovic in https://github.com/storybookjs/storybook/discussions/25692#discussioncomment-8230065
This happens because we use require.resolve('@storybook/cli/package.json')
to get the actual package path, and then check the version
field in the package.json
. However require.resolve
in pnpx
will get its own package and not the one in the actual working directory.
We need to change the logic to the package manager's CLI what version is installed in CWD (eg. pnpm why @storybook/cli
), and then parse that output to determine the current version.
yarn dlx
with Yarn 1 works, but 2+ has a similar issue where it can't detect the existing version so it just assumes v0.0.0
Hah, I just noticed this as well when using pnpm dlx sb@latest upgrade
in my project and came to see if there was already an issue about it. Thanks for filing it!
I also saw that npx
is a bit wonky too, because it tells me:
Upgrading Storybook from version 0.0.0 to version 7.6.10.
When my current version is really 7.6.0-alpha.6
@IanVS could you try with npx [email protected] upgrade
from #25752 ? I've tested it with all the different executors and it works for me, but I haven't run into the issue using npx
like you have, so you might have another setup that I'd like to see work too.
This is what I see with that canary:
╭─────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Upgrading Storybook from version 7.6.0 to version 0.0.0-pr-25752-sha-424630b7.. │
│ This is a pre-release version. │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────╯
same for me