Thanks to visit codestin.com
Credit goes to github.com

Skip to content

csskit: Resolve platform binary using a directory walk, fixing npx.#771

Merged
keithamus merged 1 commit intomainfrom
csskit-resolve-platform-binary-using-a-directory-walk-fixing-npx
Jan 2, 2026
Merged

csskit: Resolve platform binary using a directory walk, fixing npx.#771
keithamus merged 1 commit intomainfrom
csskit-resolve-platform-binary-using-a-directory-walk-fixing-npx

Conversation

@keithamus
Copy link
Member

Currently npx [email protected] is broken. Running this on my mac I get:

Error: csskit binary not found for darwin-arm64
Please ensure the appropriate platform package is installed:
  npm install csskit-darwin-arm64

The problem is that npx will install dependencies "flat". We assume that the
binary is located in csskit's node_modules directory, but that isn't the
case here. For example npm i -g csskit will install:

  • /Users/<...>/node_modules/csskit/bin/csskit
  • /Users/<...>/node_modules/csskit/node_modules/csskit-darwin-arm64/bin/csskit

While npx csskit installs:

  • /Users/<...>/node_modules/csskit/bin/csskit
  • /Users/<...>/node_modules/csskit-darwin-arm64/bin/csskit

To fix this, this change incorporates a directory walk instead of a single
lookup. Starting from csskit's bin directory we check ../node_modules/...
to see if the package is installed there. This means we'll check for e.g.:

  • /Users/<...>/node_modules/csskit/node_modules/csskit-darwin-arm64/bin/csskit
  • /Users/<...>/node_modules/node_modules/csskit-darwin-arm64/bin/csskit
  • /Users/<...>/node_modules/csskit-darwin-arm64/bin/csskit
  • /Users/node_modules/csskit-darwin-arm64/bin/csskit

This directory walk means that for the npm i case, the first hit is going to
be correct - so it shouldn't take any longer to lookup in this case. For the
npx case, this will likely be the second hit, and so still should take a very
small amount of time. The continued directory walk might also help us for other
esoteric setups, though it's not strictly necessary (though also, it might be
tricky to add sufficient smarts to avoid these extra lookups).

Currently `npx [email protected]` is broken. Running this on my mac I get:

```
Error: csskit binary not found for darwin-arm64
Please ensure the appropriate platform package is installed:
  npm install csskit-darwin-arm64
```

The problem is that `npx` will install dependencies "flat". We assume that the
binary is located in `csskit`'s `node_modules` directory, but that isn't the
case here. For example `npm i -g csskit` will install:

- `/Users/<...>/node_modules/csskit/bin/csskit`
- `/Users/<...>/node_modules/csskit/node_modules/csskit-darwin-arm64/bin/csskit`

While `npx csskit` installs:

- `/Users/<...>/node_modules/csskit/bin/csskit`
- `/Users/<...>/node_modules/csskit-darwin-arm64/bin/csskit`

To fix this, this change incorporates a directory walk instead of a single
lookup. Starting from `csskit`'s `bin` directory we check `../node_modules/...`
to see if the package is installed there. This means we'll check for e.g.:

- `/Users/<...>/node_modules/csskit/node_modules/csskit-darwin-arm64/bin/csskit`
- `/Users/<...>/node_modules/node_modules/csskit-darwin-arm64/bin/csskit`
- `/Users/<...>/node_modules/csskit-darwin-arm64/bin/csskit`
- `/Users/node_modules/csskit-darwin-arm64/bin/csskit`

This directory walk means that for the `npm i` case, the first hit is going to
be correct - so it shouldn't take any longer to lookup in this case. For the
`npx` case, this will likely be the second hit, and so still should take a very
small amount of time. The continued directory walk might also help us for other
esoteric setups, though it's not strictly necessary (though also, it might be
tricky to add sufficient smarts to avoid these extra lookups).
@keithamus keithamus enabled auto-merge (squash) January 2, 2026 09:21
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All CI jobs have passed. Approving. (Build jobs were skipped - no Rust files changed)

@keithamus keithamus merged commit 473e517 into main Jan 2, 2026
11 checks passed
@keithamus keithamus deleted the csskit-resolve-platform-binary-using-a-directory-walk-fixing-npx branch January 2, 2026 09:21
github-actions bot pushed a commit that referenced this pull request Jan 2, 2026
## [0.0.12] - 2026-01-02

### Csskit
- csskit: Resolve platform binary using a directory walk, fixing `npx`. (#771) ([#771](#771))
- csskit: Tidy up bash script (#772) ([#772](#772))

[forcebuild]
@keithamus keithamus mentioned this pull request Jan 2, 2026
github-actions bot pushed a commit that referenced this pull request Jan 2, 2026
## [0.0.12] - 2026-01-02

### Csskit
- csskit: Resolve platform binary using a directory walk, fixing `npx`. (#771) ([#771](#771))
- csskit: Tidy up bash script (#772) ([#772](#772))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant