-
-
Save rosszurowski/eee05cebb67fd869b7db1914b844db9c to your computer and use it in GitHub Desktop.
Modifying $PATH in Make on macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You can, in fact reference node_modules without the prefix by prepending node_modules to your $PATH with this line: | |
export PATH := ./node_modules/.bin:$(PATH) | |
# But for some reason, on macOS, Make doesn’t recognize the $PATH when it’s the start of a command. | |
# So this rule doesn’t work. It treats `prettier` as a file/directory: | |
format: node_modules | |
@prettier --write . | |
# But this rule does: | |
format: node_modules | |
@true && prettier --write . | |
# Erring on the side of simplicity and clarity, it's probably best to just include the full prefix. |
Oo interesting. This is the top of the Makefile I ran:
SHELL=bash
export REACT_APP_GIT_HASH := $(shell git rev-parse HEAD)
export PATH := ./node_modules/.bin:$(PATH)
I'm using stock make, but a bit older
GNU Make 3.81
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @nebbles! And I haven't yet found an incantation that works. When I run this Makefile:
I still get the following error:
I've also tried it with
SHELL := /bin/bash
,SHELL = /bin/bash
,export SHELL = /bin/bash
and adjusting its positioning relative to theexport PATH
call.Are you running a non-stock version of Make perhaps? Or is there a different incantation to use?