Skip to content

fix: use global bun paperclipai with pino override - #1353

Merged
shunkakinoki merged 2 commits into
mainfrom
fix/paperclip-global-bun-override
Apr 5, 2026
Merged

fix: use global bun paperclipai with pino override#1353
shunkakinoki merged 2 commits into
mainfrom
fix/paperclip-global-bun-override

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Apr 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Use ~/.bun/bin/paperclipai (global install) for the systemd service
  • Propagate overrides from ~/dotfiles/package.json to ~/.bun/install/global/package.json during npm-globals install
  • This forces pino@9.14.0 in the global install, fixing the pino-http crash

How it works

  1. install-npm-globals.sh runs bun install --global as before
  2. Then reads overrides from dotfiles package.json
  3. Merges them into ~/.bun/install/global/package.json
  4. Runs bun install in the global dir to apply the override

Tested

10/10 requests returned 200 with ~/.bun/bin/paperclipai after applying the override.


Summary by cubic

Switch the Paperclip service to the global ~/.bun/bin/paperclipai and force pino@9.14.0 via overrides to stop the pino-http crash.

  • Bug Fixes
    • Propagate overrides from ~/dotfiles/package.json to ~/.bun/install/global/package.json, run bun install to apply them, and add tests to confirm the overrides are applied in the global dir.
    • Update systemd ExecStart to use ~/.bun/bin/paperclipai.

Written for commit cd91d04. Summary will update on new commits.

Propagate overrides from dotfiles package.json to ~/.bun/install/global/
so the global binary resolves pino@9.14.0 correctly.
Copilot AI review requested due to automatic review settings April 5, 2026 00:54
@mesa-dot-dev

mesa-dot-dev Bot commented Apr 5, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@coderabbitai

coderabbitai Bot commented Apr 5, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@shunkakinoki has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 58 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 3 minutes and 58 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09364b72-fae6-493e-b26f-c5f8ca018de1

📥 Commits

Reviewing files that changed from the base of the PR and between f358ab0 and cd91d04.

📒 Files selected for processing (3)
  • home-manager/modules/npm-globals/install-npm-globals.sh
  • home-manager/modules/paperclip/default.nix
  • spec/npm_globals_spec.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/paperclip-global-bun-override

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mesa-dot-dev

mesa-dot-dev Bot commented Apr 5, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Fixes a pino-http crash by updating the paperclipai service to use the globally installed Bun version and enforcing pino@9.14.0 via dependency overrides.

What changed?

  • home-manager/modules/npm-globals/install-npm-globals.sh: Modified to extract overrides from ~/dotfiles/package.json, inject them into Bun's global package.json (~/.bun/install/global/package.json), and then re-run bun install in that directory to apply the overrides.
  • home-manager/modules/paperclip/default.nix: The ExecStart path for the paperclipai systemd service was updated to homeDir/.bun/bin/paperclipai, shifting from a Node.js-based execution to a global Bun-based one.

Description generated by Mesa. Update settings

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="home-manager/modules/npm-globals/install-npm-globals.sh">

<violation number="1" location="home-manager/modules/npm-globals/install-npm-globals.sh:58">
P2: The new jq expression overwrites existing global `overrides` instead of merging, which can silently drop previously configured override rules.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

if [ -n "$OVERRIDES" ]; then
GLOBAL_PKG="${HOME}/.bun/install/global/package.json"
if [ -f "$GLOBAL_PKG" ]; then
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&

@cubic-dev-ai cubic-dev-ai Bot Apr 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: The new jq expression overwrites existing global overrides instead of merging, which can silently drop previously configured override rules.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/modules/npm-globals/install-npm-globals.sh, line 58:

<comment>The new jq expression overwrites existing global `overrides` instead of merging, which can silently drop previously configured override rules.</comment>

<file context>
@@ -49,4 +49,17 @@ if [ -n "$DEPS" ]; then
+if [ -n "$OVERRIDES" ]; then
+  GLOBAL_PKG="${HOME}/.bun/install/global/package.json"
+  if [ -f "$GLOBAL_PKG" ]; then
+    jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
+      mv "${GLOBAL_PKG}.tmp" "$GLOBAL_PKG"
+    (cd "${HOME}/.bun/install/global" && bun install 2>/dev/null || true)
</file context>
Suggested change
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
jq --argjson overrides "$OVERRIDES" '.overrides = ((.overrides // {}) + $overrides)' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
Fix with Cubic

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements dependency overrides for global Bun installations and updates the paperclipai service to use the Bun-managed binary path. The review feedback recommends ensuring the shell script handles file manipulation failures gracefully to maintain consistency and suggests quoting the service execution path as a best practice for systemd units.

Comment on lines +58 to +59
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
mv "${GLOBAL_PKG}.tmp" "$GLOBAL_PKG"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The jq and mv commands should handle failures gracefully to remain consistent with the error handling pattern used elsewhere in this script. This ensures that a failure in patching the global package.json (due to permissions or an invalid global manifest) does not halt the entire home-manager activation process.

Suggested change
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
mv "${GLOBAL_PKG}.tmp" "$GLOBAL_PKG"
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
mv "${GLOBAL_PKG}.tmp" "$GLOBAL_PKG" || true
References
  1. Maintain consistency with established patterns for writing scripts that are extracted from Nix expressions.

Service = {
Type = "simple";
ExecStart = "${homeDir}/dotfiles/node_modules/.bin/paperclipai run --no-repair";
ExecStart = "${homeDir}/.bun/bin/paperclipai run --no-repair";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Wrapping the ExecStart path in double quotes is a best practice for systemd units to ensure the command is correctly parsed if the path contains spaces, even if unlikely in this specific environment.

      ExecStart = "\"${homeDir}/.bun/bin/paperclipai\" run --no-repair";

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates Paperclip’s systemd user service to run the globally-installed Bun paperclipai binary and enhances the npm-globals installer to propagate dependency overrides into Bun’s global install to avoid pino-http/pino incompatibilities.

Changes:

  • Switch Paperclip systemd user service ExecStart to ~/.bun/bin/paperclipai.
  • Extend install-npm-globals.sh to copy overrides from ~/dotfiles/package.json into Bun’s global package.json and re-run bun install there.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
home-manager/modules/paperclip/default.nix Points the Paperclip service at the Bun global paperclipai binary.
home-manager/modules/npm-globals/install-npm-globals.sh Applies dotfiles overrides to Bun global install and re-installs to enforce versions (e.g., pino).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +58 to +59
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
mv "${GLOBAL_PKG}.tmp" "$GLOBAL_PKG"

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

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

The PR description says the dotfiles overrides are merged into the global package.json, but this jq filter replaces the entire .overrides object. If the global file already has overrides (or Bun adds some in the future), they will be lost. Consider merging instead of overwriting (e.g., combine existing .overrides with the new overrides).

Copilot uses AI. Check for mistakes.
Comment on lines +58 to +61
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
mv "${GLOBAL_PKG}.tmp" "$GLOBAL_PKG"
(cd "${HOME}/.bun/install/global" && bun install 2>/dev/null || true)
echo "Applied dependency overrides to global install"

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

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

This block runs under set -e, but the jq ... > tmp && mv ... pipeline isn't protected by || true / error handling. If jq fails (e.g., corrupted global package.json), the whole activation will abort, unlike the earlier best-effort bun install --global ... || true. Consider making the override-application step best-effort as well (or emit an explicit error and continue).

Suggested change
jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"${GLOBAL_PKG}.tmp" &&
mv "${GLOBAL_PKG}.tmp" "$GLOBAL_PKG"
(cd "${HOME}/.bun/install/global" && bun install 2>/dev/null || true)
echo "Applied dependency overrides to global install"
GLOBAL_PKG_TMP="${GLOBAL_PKG}.tmp"
if jq --argjson overrides "$OVERRIDES" '.overrides = $overrides' "$GLOBAL_PKG" >"$GLOBAL_PKG_TMP" &&
mv "$GLOBAL_PKG_TMP" "$GLOBAL_PKG"; then
(cd "${HOME}/.bun/install/global" && bun install 2>/dev/null || true)
echo "Applied dependency overrides to global install"
else
rm -f "$GLOBAL_PKG_TMP"
echo "Warning: failed to apply dependency overrides to global install, continuing"
fi

Copilot uses AI. Check for mistakes.
@shunkakinoki
shunkakinoki merged commit 8319a74 into main Apr 5, 2026
31 checks passed
@shunkakinoki
shunkakinoki deleted the fix/paperclip-global-bun-override branch April 5, 2026 01:01
shunkakinoki added a commit that referenced this pull request Apr 5, 2026
* feat: add paperclip service (#1342)

* feat: add paperclip service

- Systemd service on kyber: runs `paperclipai run` via bun, depends on docker-postgres
- Config via builtins.toJSON: external postgres on kyber, embedded on macOS
- Setup script creates paperclip database on docker-postgres
- Makefile target: `make systemctl-paperclip`

* fix: add shellcheck disable and shell test coverage for paperclip

* fix: correct shellcheck disable directive syntax

* refactor: use config.template.json pattern for paperclip

* refactor: rename setup.sh to hydrate.sh for paperclip

* test: add auto-switch hook tests and update coverage spec

* fix: remove EnvironmentFile from paperclip service (#1344)

* fix: paperclip authenticated mode and required config fields (#1345)

* fix: remove EnvironmentFile from paperclip service

* fix: use authenticated mode on kyber, add required meta/logging fields

* fix: add allowedHostnames for paperclip.shunkakinoki.com

* fix: format config template json

* fix: use trust auth for docker-postgres (#1346)

POSTGRES_HOST_AUTH_METHOD=trust removes password auth for all
connections. The password kept going out of sync after crash recovery,
causing paperclip and other services to fail with 'password
authentication failed'. Safe since postgres is only reachable from
the host.

* fix: use k8s postgres via DATABASE_URL, remove docker-postgres dep, add authenticated mode (#1347)

* fix: use bun runtime for paperclip (pino-http node crash), k8s postgres via DATABASE_URL (#1348)

* fix: use nix-profile bun path for paperclip service (#1350)

* fix: add caret prefix to paperclipai dependency (#1349)

* fix: use extra-substituters to avoid untrusted user warnings (#1351)

* fix: run paperclip from cloned repo via pnpm dev:once (#1352)

* fix: run paperclip from cloned repo via pnpm dev:once

The global bun install flattens pino@10 + pino-http@10.5 together,
but pino-http needs pino@9. The repo lockfile resolves this correctly
with nested dependencies. Running from the repo avoids the crash.

* fix: use bun run server/src/index.ts instead of pnpm dev:once

* fix: pin pino@9.14.0 override, run paperclipai from dotfiles node_modules

The bun flat hoisting was resolving pino@10 which is incompatible
with pino-http@10.5. Pinning pino to 9.14.0 via overrides matches
the paperclip repo's lockfile resolution and fixes the crash.

* fix: use global bun paperclipai with pino override (#1353)

* fix: use global ~/.bun/bin/paperclipai with pino override

Propagate overrides from dotfiles package.json to ~/.bun/install/global/
so the global binary resolves pino@9.14.0 correctly.

* test: add tests for npm-globals dependency overrides

* fix: resolve GitHub Actions failures and code review issues

- Fix non-portable \s regex to [[:space:]] in auto-switch.sh (shfmt compat)
- Add jq dependency check alongside cswap
- Use printf instead of echo for safer output
- Fix claude-swap version from >=1.1.5 (non-existent) to >=0.7.1
- Add auto-switch.sh to Nix deployment config (default.nix)
- Sort covered_scripts list alphabetically in coverage_spec.sh

https://claude.ai/code/session_012GyQBesQGF1asTfKebWyLM

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants