Skip to content

DOTFILES_PATH uses pwd instead of the Makefile directory #76

Description

@SebastienElet

DOTFILES_PATH is derived from the current working directory, not from the location of the
Makefile, so invoking make from elsewhere points 25 symlinks at a directory that does not exist.

Evidence

Makefile:10-11:

# DOTFILES_PATH should be ~/.dotfiles when installed normally
DOTFILES_PATH:=$(shell pwd)

The comment states the assumption and does not enforce it. DOTFILES_PATH is the source side of
every link rule — Makefile:122, 147, 320, 353-357, 365, 373-379, 384-392, 402-411,
470, 519-521, 662, 664, 689, 695, 706, 717.

  • make -C ~/.dotfiles all is safe: make changes directory before reading anything, so pwd is
    correct.
  • make -f ~/.dotfiles/Makefile all from any other directory is not: pwd is the caller's
    directory, and every ln -s points there.

The second form is exactly what a script would write, and #61 proposes adding a make
invocation to scripts/upgrade — so this becomes reachable the moment that lands, if -C is
forgotten.

Fix

Derive it from the makefile itself, which is correct under every invocation:

DOTFILES_PATH:=$(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))

$(lastword $(MAKEFILE_LIST)) must be read at the top of the file, before any include, which is
where the current line already sits.

Verification

cd /tmp && make -f ~/.dotfiles/Makefile -n ~/.tmux.conf

must print a ln -s whose source is ~/.dotfiles/tmux/.tmux.conf, not /tmp/tmux/.tmux.conf.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions