Ubuntu 上让 Paseo 开机自启,并拿到正常环境变量

缘起

Paseo 需要常驻运行。它启动后会继续拉起 agent、终端、OpenCode server 等子进程。这些子进程能不能找到 pnpm、lark-cli、bun、node,取决于 Paseo daemon 启动时拿到的环境变量。

我们平时打开终端时通常没问题,因为终端会启动 zsh,zsh 会读取 ~/.zshrc。很多开发工具路径都写在那里。

但 Paseo 如果由 Ubuntu 的 systemd 自动启动,默认不会读取 ~/.zshrc。于是就会出现:普通终端里能找到 lark-cli,Paseo agent 里却找不到。

这不是工具没安装,而是 Paseo 的启动环境没有走你的 zsh 初始化流程。

思路

在 paseo.service 的 systemd drop-in 里覆盖 ExecStart,让 Paseo 通过 zsh -ilc 启动,从而加载 ~/.zshrc 后再运行 daemon。

最终配置

先确认 Paseo 的真实路径:

zsh -ilc 'command -v paseo'

假设输出是:

/home/joey/.local/share/pnpm/nodejs_current/bin/paseo

创建 drop-in 目录:

mkdir -p ~/.config/systemd/user/paseo.service.d

写入配置:

cat > ~/.config/systemd/user/paseo.service.d/10-login-zsh-env.conf <<'EOF'
[Service]
Environment=HOME=/home/joey
Environment=SHELL=/usr/bin/zsh
ExecStart=
ExecStart=/usr/bin/zsh -ilc 'exec /home/joey/.local/share/pnpm/nodejs_current/bin/paseo daemon start --foreground'
EOF

其中 /home/joey 和 paseo 路径按实际机器替换。

ExecStart= 空行必须保留,用来清掉原 service 里的旧启动命令。

重新加载 systemd 配置:

systemctl --user daemon-reload

启用用户服务自启:

systemctl --user enable paseo.service

重启 Paseo:

systemctl --user restart paseo.service

如果希望用户未登录时也能启动:

sudo loginctl enable-linger "$USER"

注意事项

这个方案会让 Paseo 继承 ~/.zshrc 里所有 export 出来的变量,包括 token、代理、API key 等

7 个赞