Skip to content

fix: remove EnvironmentFile from paperclip service - #1344

Merged
shunkakinoki merged 1 commit into
mainfrom
fix/paperclip-env-file
Apr 4, 2026
Merged

fix: remove EnvironmentFile from paperclip service#1344
shunkakinoki merged 1 commit into
mainfrom
fix/paperclip-env-file

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Apr 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove EnvironmentFile pointing to non-existent ~/.paperclip/instances/default/.env
  • No secrets needed in local_trusted mode — auth is handled at the Cloudflare tunnel / nginx ingress level

Problem

Service was crash-looping with Failed to load environment files: No such file or directory


Summary by cubic

Removed EnvironmentFile from the paperclip service to stop crash loops caused by a missing .env. This aligns with local_trusted mode where auth is handled at the edge.

  • Bug Fixes
    • Dropped EnvironmentFile reference to ${instanceDir}/.env to prevent “Failed to load environment files” and restart loops.
    • No secrets required in local_trusted; Cloudflare tunnel/nginx ingress handle auth.

Written for commit 4e4ca0a. Summary will update on new commits.

Copilot AI review requested due to automatic review settings April 4, 2026 09:48
@mesa-dot-dev

mesa-dot-dev Bot commented Apr 4, 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 4, 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 15 minutes and 21 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 15 minutes and 21 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: 727e3f11-7314-4f6d-b5c7-d8aaa480e640

📥 Commits

Reviewing files that changed from the base of the PR and between edea85b and 4e4ca0a.

📒 Files selected for processing (1)
  • home-manager/modules/paperclip/default.nix
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/paperclip-env-file

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 4, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Fixed a crash-looping paperclip service by removing a reference to a non-existent environment file.

What changed?

  • Removed the EnvironmentFile configuration from the paperclip service, which was pointing to ~/.paperclip/instances/default/.env.
  • This change is due to the local_trusted mode not requiring secrets, as authentication is handled by the Cloudflare tunnel or nginx ingress.

Description generated by Mesa. Update settings

@shunkakinoki
shunkakinoki merged commit a8645c8 into main Apr 4, 2026
34 checks passed
@shunkakinoki
shunkakinoki deleted the fix/paperclip-env-file branch April 4, 2026 09:49

@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.

No issues found across 1 file

@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 removes the EnvironmentFile configuration from the paperclip module. The reviewer suggests also removing the instanceDir variable definition, as it appears to be unused following this change.

"HOME=${homeDir}"
"PATH=${homeDir}/.local/bin:${homeDir}/.bun/bin:${homeDir}/.nix-profile/bin:${homeDir}/.local/share/pnpm:${homeDir}/.local/share/fnm/current/bin:${homeDir}/.npm-global/bin:/usr/local/bin:/usr/bin:/bin"
];
EnvironmentFile = "${instanceDir}/.env";

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

Removing the EnvironmentFile reference makes the instanceDir variable (defined on line 10) unused within this module. To maintain code cleanliness and avoid confusion, consider removing the instanceDir definition as well.

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

Removes a systemd user service EnvironmentFile reference in the Paperclip Home Manager module to stop the service from crash-looping when the expected .env file is missing on the kyber host.

Changes:

  • Remove EnvironmentFile = "${instanceDir}/.env"; from the Paperclip user service definition.

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

Comment on lines 37 to 41
Environment = [
"HOME=${homeDir}"
"PATH=${homeDir}/.local/bin:${homeDir}/.bun/bin:${homeDir}/.nix-profile/bin:${homeDir}/.local/share/pnpm:${homeDir}/.local/share/fnm/current/bin:${homeDir}/.npm-global/bin:/usr/local/bin:/usr/bin:/bin"
];
EnvironmentFile = "${instanceDir}/.env";
WorkingDirectory = "${homeDir}/.paperclip";

Copilot AI Apr 4, 2026

Copy link

Choose a reason for hiding this comment

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

instanceDir is now unused after removing EnvironmentFile. Consider removing the instanceDir let-binding (or using it elsewhere) to avoid suggesting there is still instance-specific state being referenced by this module.

Copilot uses AI. Check for mistakes.
Comment on lines 41 to 43
WorkingDirectory = "${homeDir}/.paperclip";
StandardOutput = "append:/tmp/paperclip/paperclip.log";
StandardError = "append:/tmp/paperclip/paperclip.log";

Copilot AI Apr 4, 2026

Copy link

Choose a reason for hiding this comment

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

The service logs to /tmp/paperclip/paperclip.log, but /tmp is typically cleared on reboot and the Home Manager activation hook won’t run at user-service start. This can cause the unit to fail if the directory is missing. Prefer creating the directory in the unit itself (e.g., RuntimeDirectory/StateDirectory + %t for the path, or an ExecStartPre mkdir) so it’s always present with correct ownership/permissions.

Copilot uses AI. Check for mistakes.
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