Skip to content

make install doesn't handle non-existent binary dir #84

@aozgaa

Description

@aozgaa

What happened?
make install tries to elevate at the install(1) subcommand If the PREFIX/DESTDIR doesn't exist, then fails anyways:

    @if [ -w "$(PREFIX)/bin" ]; then \
      install .build/release/$(BINARY) $(PREFIX)/bin/$(BINARY); \
    else \
      sudo install .build/release/$(BINARY) $(PREFIX)/bin/$(BINARY); \
    fi

From test(1):

    -w file       True if file exists and is writable.  True indicates only that the write flag is on.  The file is not writable on a read-only file system even if this test indicates true.

What did you expect?

I'd expect that the install rule either creates the dest dir using inherited permissions, or fails without trying to install/proceed further. In any case, the alternative convention chosen should be documented.

Conventionally, elevating would be taken of by running make itself elevated, something like

make build && sudo make install

But see #83 for why this isn't currently practical.

Steps to reproduce

  1. Case 1 -- PREFIX doesn't exist leads to spurious elevation, then failure anyways
% make install PREFIX=${HOME}/.does_not_exist  
0.9.20 → 0.9.21
swift build -c release
[1/1] Planning build
Building for production...
[5/5] Linking apfel
Build complete! (9.95s)
install: /Users/art/.does_not_exist/bin/INS@ogM8iL: No such file or directory
make: *** [install] Error 71
  1. Case 2 -- bin dir doesn't exist leads to spurious elevation, then failure anyways
    % mkdir -p ~/.does_exist
    % make install PREFIX=${HOME}/.does_exist
    0.9.21 → 0.9.22
    swift build -c release
    [1/1] Planning build
    Building for production...
    [5/5] Linking apfel
    Build complete! (9.43s)
    install: /Users/art/.does_exist/bin/INS@ZA8LZD: No such file or directory
    make: *** [install] Error 71
3) Case 3 -- bin dir exists leads user or admin install based on writeability:

% mkdir -p ~/.does_exist/bin
% make install PREFIX=${HOME}/.does_exist
0.9.22 → 0.9.23
swift build -c release
Building for production...
[5/5] Linking apfel
Build complete! (4.31s)
✓ installed: apfel v0.9.23



**Environment**
- macOS version: (`sw_vers`)

% sw_vers
ProductName: macOS
ProductVersion: 26.4
BuildVersion: 25E246

- apfel version: (`apfel --version`)

% apfel --version
apfel v0.9.22
% git log -1
commit 07b177f (tag: v0.9.18, origin/main, origin/HEAD, main)
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date: Sun Apr 12 11:37:02 2026 +0000

release v0.9.18
- Install method: built from source
- `apfel --model-info` output: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions