Skip to content

fix(install): create $(PREFIX)/bin on the sudo path - #152

Merged
rn7s2 merged 1 commit into
mainfrom
fix/install-sudo-mkdir-bin
Oct 20, 2026
Merged

rn7s2 merged 1 commit into
mainfrom
fix/install-sudo-mkdir-bin

Conversation

@rn7s2

@rn7s2 rn7s2 commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Problem

make install fails on a machine without /usr/local/bin:

Need sudo to write to /usr/local/bin
Password:
install: /usr/local/bin/INS@bHQl6a: No such file or directory
install: /usr/local/bin/INS@MhPIrz: No such file or directory
ln: /usr/local/bin/evo: No such file or directory
make: *** [install] Error 1

Cause

The install rule creates $(PREFIX)/bin only in its unprivileged branch. That mkdir -p is also the test for whether the directory is writable, so when it fails for lack of permission the sudo branch is taken without ever retrying it:

if [ -w $(PREFIX)/bin ] || mkdir -p $(PREFIX)/bin 2>/dev/null && [ -w $(PREFIX)/bin ]; then
  ...
else
  echo "Need sudo to write to $(PREFIX)/bin";
  sudo install -m 755 build/evo-agent $(PREFIX)/bin/evo-agent;   # dir never created

install(1) needs the destination directory to already exist — it writes a temp file (INS@xxxxxx) beside the target and renames it. With no /usr/local/bin, that temp file's path does not exist, hence the INS@…: No such file or directory errors. The ln after it fails for the same reason, and the non-zero exit aborts make.

This is the common case on macOS: Homebrew on Apple Silicon installs to /opt/homebrew and leaves /usr/local an empty, root-owned directory. On such a machine a fresh checkout could never complete the README.md quick start (make install, "enter your password if prompted") — the sudo path was the only one available, and it was broken.

Fix

Create the directory in the privileged branch too:

 	  echo "Need sudo to write to $(PREFIX)/bin"; \
+	  sudo mkdir -p $(PREFIX)/bin; \
 	  sudo install -m 755 build/evo-agent $(PREFIX)/bin/evo-agent; \

BSD install on macOS has no -D, so an explicit mkdir is the portable fix.

Verification

Reproduced the exact failure with a stand-in sudo that runs the command as the invoking user against a read-only PREFIX, then confirmed the patched rule completes:

Need sudo to write to /tmp/rootsim2/bin
$ ls -la /tmp/rootsim2/bin
lrwxr-xr-x  evo -> evo-swarm
-rwxr-xr-x  evo-agent
-rwxr-xr-x  evo-swarm
$ /tmp/rootsim2/bin/evo --version
evo-swarm 0.1.0

The direct-write branch (writable PREFIX) was already correct and still works.

Co-authored-by: EvoAgent evo@ruiqilei.com

The install rule creates $(PREFIX)/bin only in its unprivileged branch:
the `mkdir -p` there is also the test, so when it fails for lack of
permission the sudo branch is taken without ever retrying it.  install(1)
needs the destination directory to exist -- it writes a temp file beside
the target -- so on a machine without /usr/local/bin every file fails as

    install: /usr/local/bin/INS@bHQl6a: No such file or directory

and the following `ln` fails the same way, aborting make.

That is the common case on macOS: Homebrew on Apple Silicon installs to
/opt/homebrew and leaves /usr/local an empty root-owned directory, so a
fresh checkout's `make install` could never succeed.

Create the directory with sudo before installing into it.  BSD install on
macOS has no -D, so an explicit mkdir is the portable fix.

Co-authored-by: EvoAgent <evo@ruiqilei.com>
@rn7s2
rn7s2 merged commit 0a7b6ce into main Oct 20, 2026
2 of 3 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.

1 participant