syncify icon indicating copy to clipboard operation
syncify copied to clipboard

Global `@syncify/cli` installation fails due to missing `postinstall` execution

Open WolfGreyDev opened this issue 8 months ago โ€ข 1 comments

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

  1. 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 init procedure
  2. Remove the package globally pnpm remove @syncify/cli -g
  3. Reinstall the package globally pnpm add @syncify/cli@unstable -g
  4. 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
  1. 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

  1. Documentation: Add clear instructions about pnpm approve-builds -g for global installs.
  2. sy doctor Enhancement: Check if postinstall ran and suggest running approve-builds if 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.   โ”‚
โ”‚                                                                                               โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

WolfGreyDev avatar Apr 17 '25 12:04 WolfGreyDev

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:

  1. pnpm add @syncify/cli -g (normal install)
  2. sy install (handles all setup)

Feels cleaner than having to explain the pnpm-specific workaround to everyone.

WolfGreyDev avatar Apr 22 '25 09:04 WolfGreyDev