0

i'm fairly new to using Makefiles to write commands for me.

I have made a Makefile to run and format a Flask app. The contents are

run:
    .\venv\Scripts\python.exe app.py
format:
    prettier -w .\templates\
    prettier -w .\static\
    autopep8 --in-place --aggressive --aggressive .\app.py
    

make run works as expected probably because I have the virutal environment in the same directory. Running make format

❯ make format
prettier -w .\templates\
prettier -w .\static\
autopep8 --in-place --aggressive --aggressive .\app.py
[warn] Ignored unknown option --in-place.
[warn] Ignored unknown option --aggressive=.\app.py.
[error] No files matching the pattern were found: ".\templatesprettier".
[error] No files matching the pattern were found: ".\staticautopep8".
Makefile:4: recipe for target 'format' failed
make: *** [format] Error 2

But executing the contents of format manually works perfectly fine. So I'm guessing it is some sort of issue from the makefile not having access to these global scrips?

How would I go about fixing this, and is there perhaps an alternative way I can do this (w/o makefile) which is better suited to my task

user15032172
  • 55
  • 1
  • 6
  • I suspect make accepts Win based paths. make comes from the Unix world and it does its job well there. Moving it to Win, one way ist to use minGW or Linux subsystem. Have you taken into account one of those? – woodz Apr 05 '21 at 22:33
  • It's usually better to use POSIX directory separators (forward slash, `/`) rather than DOS separators (backward slash) when working in makefiles. Most Windows tools will accept either one. However, within a recipe like this backslash may work. If you start a brand new cmd.com window, cd to the directory here but do _nothing_ else, then type `autopep8 --in-place --aggressive --aggressive .\app.py` does it work? That's basically what make does. Maybe you have to set up your virtualenv before you can run this command. – MadScientist Apr 05 '21 at 23:35
  • all of the commands worked when just typing into the terminal. With the make file the autopep8 one worked but the prettier one did not work. I found a way to fix it which was to cd into the folder then do the command i.e `cd templates && prettier -w *.html` and that fixed not, not sure why the original way i had didnt work even though it worked in the terminal by typing it manually :P – user15032172 Apr 06 '21 at 12:12

0 Answers0