Closed airtonix closed 2 years ago
Why did you guys remove the steps to manually install storybook into a project.
so ways to fix this problem:
npx --package <storybook-package-that-provides-the-sb-command sb init
so it turns out that the storybook team naively expected no one else on earth to publish a package providing a binary called sb
...
for those who want to run the sb
command properly:
npx --package @storybook/cli sb init
@airtonix any chance you can figure out which package is installing the binary called sb
?
@shilman There might be a way utilising vscodes javascript debugging tool and breakpoints in npx itself... not heaps hopeful on this outcome.
even if we discover who it was... it feels like a thing that will keep happening, since NPM.js only protects against package name squatting.
@airtonix what version of npm are you running?
So far I'm not able to reproduce this. We do own the npm package called sb
, which is how this currently works for most users.
What if you run:
more ./node_modules/.bin/sb
@shilman yeah but doesn't npx works like this ?
sb
exist in some node_modules/.bin ?sb
exist on the PATHsb
so in my case Fedora 34 provides a /usr/bin/sb
:
$ yum provides /usr/bin/sb
...snips butt loads of dnf update spam...
lrzsz-0.12.20-53.fc34.x86_64 : The lrz and lsz modem communications programs
Repo : @System
Matched from:
Filename : /usr/bin/sb
lrzsz-0.12.20-53.fc34.x86_64 : The lrz and lsz modem communications programs
Repo : fedora
Matched from:
Filename : /usr/bin/sb
But it illustrates a problem with the documentation:
/usr/bin/sb
,PATH=${HOME}/bin;${PATH}
in their profile ( and they are amazing at naming things so call a custom tool ~/bin/sb
🤷🏻 you can't control this.yep, earlier i didn't have @storybook/cli
installed, but now that I do, npx sb ...
always uses the cli you created.
if i step outside of the repo or clear my npm cache (I think), then npx goes back to resolving sb
from /usr/bin/sb
@airtonix when I run:
$ which ncdu
/usr/local/bin/ncdu
However, when I run:
$ npx ncdu
Need to install the following packages:
ncdu
Ok to proceed? (y)
...
It downloads and installs https://www.npmjs.com/package/ncdu, which is a different program.
EDIT: it looks like it downloads the package and then perhaps executes the existing binary from /usr/local/bin
🤦
@shilman have you ever downloaded that package before?
i'm spinning up a newly created directory with a version of node i've never used before via asdf and wiping my ~/.npm
i think the easiest way to avoid this annoying behaviour and time sink it would bring for you is to update documentation so that any mention of npx sb ...
is changed to npx --package @storybook/cli sb ...
i can't reproduce anymore is keeps wanting to correctly install an sb
package
Yeah, we also have the package storybook
, so I think we're going to switch to that instead:
npx storybook init
This will have the same problem, if somebody installs a binary called storybook
in their path. But I think that's a much lower possibility than sb
, which looks like it's a built-in utility in some linux distributions
@shilman did you want to leave this issue open? or are you actioning this somewhere else ?
Tracking at #17934 and closing this. Thanks so much @airtonix for helping debug this!!! 🙏
@airtonix if you type npx sb@latest init
does that fix it?
but
sb
is actually :