Global `@syncify/cli` installation fails due to missing `postinstall` execution
Branch: next
When installing @syncify/cli globally via pnpm add @syncify/cli@unstable -g, if you've previously installed the package and removed it, the postinstall script is not executed. This causes an error loop when running sy init and sy doctor.
Steps to Reproduce
- Install the package globally
pnpm add @syncify/cli@unstable -g- Not sure if you'll need to use the package, in my case I ran through the
sy initprocedure
- Not sure if you'll need to use the package, in my case I ran through the
- Remove the package globally
pnpm remove @syncify/cli -g - Reinstall the package globally
pnpm add @syncify/cli@unstable -g - Run
sy init
test-init-140425-1 sy init
โโ Syncify ~ 12:35:25
โ
โ v1.0.0-unstable.0
โ
โ ERROR
โ
โ Syncify is missing core reference files. Please report this issue on the github
โ repo, https://github.com/panoply/syncify/issues). This error may be due to a
โ corrupted installation which prevented postinstall hooks from firing.
โ How to fix?
โ Programmatic generation of core references may resolve this issue. Use the sy
โ doctor command and syncify will try and fix the problem. If the error persists,
โ please ensure read/write access permissions allow for directory and file
โ generation within /Users/wolfgreydev/.syncify location.
โ
โโ Syncify ~ 12:35:26
- Following the instructions, running
sy doctor
test-init-140425-1 sy doctor
โโ Syncify ~ 12:35:33
โ
โ v1.0.0-unstable.0
โ
โ UNKNOWN PROJECT
โ
โ Syncify cannot run from this location as it is unknown. The necessary files and
โ references that would auto-confirm this directory as a valid project could not
โ be located.
โ
โ /Users/wolfgreydev/Sites/shopify/playground/syncify-unstable/test-init-140425-1
โ
โ โ no credentials
โ โ no targets
โ โ no config file
โ
โ How to fix?
โ Run the sy init command if you would like to make this directory a Syncify
โ project. You can alternatively provide the necessary files/references. For more
โ information visit the setup guide: https://syncify.sh/setup/
โ
โโ Syncify ~ 12:35:34
Expected Behavior
The postinstall script should run automatically during global installation.
Solution
As of pnpm v10.0.0, lifecycle scripts aren't automatically run and need to be approved. See here for more about this
After global installation, run pnpm approve-builds -g
โ test-init-140425-1 pnpm approve-builds -g
โ Choose which packages to build (Press <space> to select, <a> to toggle all, <i> to invert selection) ยท @parcel/watcher, @syncify/cli, esbuild
โ The next packages will now be built: @parcel/watcher, @syncify/cli, esbuild.
Do you approve? (y/N) ยท true
.pnpm/[email protected]/node_modules/esbuild: Running postinstall script, done in 458ms
.pnpm/@[email protected]/node_modules/@parcel/watcher: Running install script, done in 302ms
.pnpm/@[email protected]/node_modules/@syncify/cli: Running postinstall script, done in 287ms
(Select at minimum @syncify/cli from the options)
Suggested Improvements
-
Documentation: Add clear instructions about
pnpm approve-builds -gfor global installs. -
sy doctorEnhancement: Check ifpostinstallran and suggest runningapprove-buildsif missing.
Additional Context
The warning shown after global installation:
+ @syncify/cli 1.0.0-unstable.2
โญ Warning โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ Ignored build scripts: @parcel/watcher, @syncify/cli, esbuild. โ
โ Run "pnpm approve-builds -g" to pick which dependencies should be allowed to run scripts. โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Another idea, we could drop the postinstall script completely and handle this through a new sy install command instead.
Since pnpm is forcing us to use that extra approve-builds step anyway, moving everything under Syncify's own CLI would:
- Make behavior consistent across all package managers
- Give us more control over the install process
- Remove the dependency on postinstall hooks working correctly
Simplified workflow:
-
pnpm add @syncify/cli -g(normal install) -
sy install(handles all setup)
Feels cleaner than having to explain the pnpm-specific workaround to everyone.