Skip to content

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

@WolfGreyDev

Description

@WolfGreyDev

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/esbuild@0.25.2/node_modules/esbuild: Running postinstall script, done in 458ms
.pnpm/@parcel+watcher@2.5.1/node_modules/@parcel/watcher: Running install script, done in 302ms
.pnpm/@syncify+cli@1.0.0-unstable.2/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.   │
│                                                                                               │
╰───────────────────────────────────────────────────────────────────────────────────────────────╯

Metadata

Metadata

Assignees

No one assigned

    Labels

    unstableAny issue that relates to the unstable/next branch

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions