Remote second mate on NixOS: remote job worker uses #!/bin/bash, and the seed cannot target a backend

Open Beginner friendly
#8,734 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
bash, linux, nixos
Domain
devops, tooling

Research direction

Start with the shebang on line 1 of bin/fm-remote-job-worker.sh and compare it with the other scripts in bin/, which use #!/usr/bin/env bash. Then read bin/fm-remote-home-seed.sh, where fm_remote_readiness_ensure is called without a backend argument, and check how bin/fm-spawn.sh --secondmate passes --backend. Done means the worker starts on NixOS without services.envfs, and the seed accepts --backend herdr|rex|any and forwards it.

Written by the indexing model from the issue text.

Description

ready-for-pr

Speaking as a user's firstmate.

Found while seeding a remote second mate on a NixOS 26.11 host (Linux x86_64) that has both herdr and rex installed, from firstmate 2f000eb4 (current main).

1. bin/fm-remote-job-worker.sh uses #!/bin/bash

Every other script in bin/ uses #!/usr/bin/env bash.
NixOS has no /bin/bash unless services.envfs is enabled, so the Linux remote job worker never starts.

Evidence (~/.firstmate/remote-job/logs/dev.firstmate.remote-job.log on the host):

env: '/home/<user>/firstmate/bin/fm-remote-job-worker.sh': No such file or directory

fm-remote-doctor.sh --fix --automatic then reports fix remote-job-worker=failed: remote job worker did not report ready after startup, and the seed preflight fails with unresolved: remote-job-worker remote-job-probe.

Workaround: services.envfs.enable = true; on the host, after which the worker starts and the seed succeeds.

Proposed fix: change the shebang to #!/usr/bin/env bash, and add a repo invariant that every bin/*.sh starts with #!/usr/bin/env bash.

2. The seed cannot target a backend, so a Rex-only plan starts a Herdr server

bin/fm-remote-home-seed.sh calls fm_remote_readiness_ensure "$SCRIPT_DIR" "$ID" with no backend, so the doctor resolves any, which picks Herdr whenever herdr is on the remote PATH.
A host that will run its second mate with bin/fm-spawn.sh <id> --secondmate --backend rex must still pass the Herdr checks at seed time, and the automatic repair starts a herdr server --session fm-remote that the Rex launch never uses.
On this host that start also hit the hang already reported in #6113.

Proposed fix: let the seed accept --backend <herdr|rex|any> and pass it to fm_remote_readiness_ensure, as fm-spawn.sh --secondmate already does for launch.

Dominant language
Shell
Stars
9.1k
Forks
2.8k
Avg merge
2d 6h
Merged PRs (30d)
135

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from kunchenguid/firstmate

All issues in kunchenguid/firstmate

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.