Skip to content

Make btcpay-update.sh work from a non-interactive shell - #1189

Merged
NicolasDorier merged 2 commits into
btcpayserver:masterfrom
artofbitcoin:fix/update-non-interactive-shell
Oct 16, 2026
Merged

NicolasDorier merged 2 commits into
btcpayserver:masterfrom
artofbitcoin:fix/update-non-interactive-shell

Conversation

@artofbitcoin

Copy link
Copy Markdown
Contributor

Why

Fixes #1188. Running btcpay-update.sh from a non-interactive shell (cron, ssh host 'cd … && ./btcpay-update.sh', pct exec) fails in two places, both because that shell's PATH is usually /sbin:/bin:/usr/sbin:/usr/bin:

  1. After git pull, the script re-executes itself with exec "btcpay-update.sh", which is only found if /usr/local/bin (where the symlink lives) is on PATH.
  2. docker_compose_update installs /usr/local/bin/docker-compose, and the later docker-compose calls in helpers.sh can't find it. The command -v docker-compose check also misses it, so the binary is reinstalled on every run.

Implementation

  • btcpay-update.sh re-executes ./btcpay-update.sh. The script has already changed into $BTCPAY_BASE_DIRECTORY/btcpayserver-docker, so this runs the freshly pulled copy, as before.
  • helpers.sh puts /usr/local/bin at the front of PATH when it isn't there. That covers btcpay-update.sh, btcpay-setup.sh and the other scripts that source it, and the tools install_tooling links into that directory.
  • tests/environment-test.sh sources helpers.sh in a clean environment with PATH=/usr/bin:/bin and checks that /usr/local/bin ends up on it.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 73c53a50-9885-4e68-af39-c63ea2422071
📥 Commits

Reviewing files that changed from the base of the PR and between cc57300 and e368dea.

📒 Files selected for processing: 3
  • btcpay-update.sh
  • helpers.sh
  • tests/environment-test.sh

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

The update script now invokes itself through a relative path. helpers.sh adds /usr/local/bin to PATH when it is missing, and an environment test checks this behavior in a clean shell.

Changes: Non-interactive update fixes

Layer / File(s) Summary
Recursive update invocation
btcpay-update.sh
The recursive update command now invokes ./btcpay-update.sh.
PATH setup and regression test
helpers.sh, tests/environment-test.sh
helpers.sh prepends /usr/local/bin to PATH only when it is absent. The environment test checks that sourcing helpers.sh adds the directory when the shell starts with a restricted PATH.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to e368d

The non-interactive update path makes /usr/local/bin available before Compose operations, with no actionable merge risk established in the reviewed changes.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description check Passed The description clearly explains the non-interactive shell failures and the changes that fix them.
Title check Passed The title clearly summarizes the primary change: making btcpay-update.sh work from non-interactive shells.
Linked Issues check Passed The changes satisfy the coding requirements in [#1188]. btcpay-update.sh changes the post-git pull self-reexecution to exec ./btcpay-update.sh --skip-git-pull after changing to the repository di…
Out of Scope Changes check Passed The reviewed changes stay within [#1188]. The self-reexecution fix, PATH initialization, and the environment test directly address non-interactive update execution. No unrelated behavior or files are …
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

I’m a rabbit with a patch to share,
I hop through PATH and find tools there.
The script can call itself once more,
And tests check paths from shell to door.
I nibble carrots, pleased with the change,
Then bound away across the range.

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

@artofbitcoin
artofbitcoin marked this pull request as ready for review October 15, 2026 15:21
@NicolasDorier
NicolasDorier merged commit 632a8b5 into btcpayserver:master Oct 16, 2026
5 checks passed
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.

btcpay-update.sh fails in non-interactive shells: bad exec self-call + docker-compose not on PATH

2 participants