-
Notifications
You must be signed in to change notification settings - Fork 220
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
Prefer using a platform package over postinstalls #1217
Comments
Since the logic of postinstall script is kept as simple as possible, we will probably never need to forward these buggy config values via npm.
In our case, the CLI binaries are hosted on GitHub releases instead of npm registry. This means the postinstall script doesn't depend on installing another nested OS specific package, hence avoiding the network configuration issue.
Unfortunately there's no workaround to this as long as we rely on postinstall script. However, I would argue this is a minor issue because our postinstall script is open source, version controlled, and very readable due to its simplicity. There are other popular installation methods which execute a bash script from a https source which seems way more suspicious.
We started using postinstall script precisely to support yarn because it's very popular among our users. Since node itself is supposed to provide cross platform compatibilities, I doubt it will be a high priority for package managers in the node ecosystem to support these Also, we have introduced CI checks for these installation scripts to ensure they don't break. It would be unnecessarily complex to publish OS specific npm packages and maintain the same level of integrity via CI. |
You'd think that, but that's not quite true. For example:
That's the case of all the other projects who used to do the same (a lot) / still do (rarer). The security problem isn't really your script in itself, but that it makes it more difficult for projects to adopt safer practices. In other words, users of the
They already do. I should know it, I maintain Yarn! 🙂 As I mentioned, both Esbuild and SWC, and as such Next.js, already follow this pattern - we thus made sure that all package managers would support this pattern. Both npm, pnpm, & Yarn do (and given how widespread are those packages in the ecosystem, we have tests to prevent regressions).
I understand it'd be a change compared to how you currently publish things. In my opinion, it's still something I'd recommend you to consider: while it usually works, I never saw postinstall scripts that didn't lead to frustration for users. |
It would be nice if supabase would at least be installed with Ignoring scripts in a project or user-level config is a good default to use. These days it breaks so few packages that I had forgotten the whole thing, and that error came to be a bit of a head-scratcher. |
Is your feature request related to a problem? Please describe.
The Supabase package currently runs a postinstall script to download the binary for the current platform. This strategy should be avoided: postinstall scripts are dangerous, but also very inconvenient (they are unstable, slow, don't work well with caches, disable optimizations in package managers).
For more details, see this thread, which is fairly detailed: evanw/esbuild#1621.
Describe the solution you'd like
Instead, you should use the same strategy as tools like
esbuild
orswc
. It's been documented in detail in the thread I mentioned, but to give you an idea, you'd have to do the following:@supabase/cli-<platform>
package, each one with the relevant bin for the given platformos
,cpu
, and possiblylibc
fields from thepackage.json
accordinglysupabase
package, remove the postinstall script and instead list the platform packages in theoptionalDependencies
field.bin
field ofsupabase
should point to a JS script that would check which platform package is installed, and execute its accompanying native bin usingchild_process.spawn
.As a result, package managers will only download the single package
Additional context
I wonder if perhaps Yarn could implement something to make publishing such packages easier. You don't use Yarn though, so I don't know if that would help you.
The text was updated successfully, but these errors were encountered: