0

I would like to create a requirements_all.txt file using make commands. I am using Anaconda.

I have tried the following but none have worked as intended.

requirements_all.txt:
    conda list --export

This displays all of the packages I have installed in the terminal window, and does not create requirements_all.txt.

requirements_all.txt:
    @echo conda list --export

This displays @echo conda list --export in the terminal window, and does not create requirements_all.txt.

requirements_all.txt:
    @echo conda list --export > requirements_all.txt

This created a file called requirements_all.txt containing conda list --export.

Graham B
  • 11
  • 3
  • 1
    how about the last one, without the @echo? – merv Jan 06 '23 at 17:37
  • @merv that worked, thank you! I thought that unless you use `PHONY`, `make` creates the file by default. Why does it not work in this case? – Graham B Jan 06 '23 at 17:41
  • 1
    I'm not sure where you got this idea, but it's not right. Make recipes are shell scripts. They do exactly the same thing that would happen if you entered that command to your shell prompt, nothing more and nothing less (ob.exception: make will expand all make variables before sending the recipe to the shell). If your shell commands make a file, the file will be made. If they don't, it won't. – MadScientist Jan 06 '23 at 17:47
  • @MadScientist Thank you for commenting again, you've been helping me a lot recently! To answer your question, I got that idea from this post. The first 2 sentences of the top answer "By default, Makefile targets are "file targets" - they are used to build files from other files. Make assumes its target is a file, and this makes writing Makefiles relatively easy:" https://stackoverflow.com/questions/2145590/what-is-the-purpose-of-phony-in-a-makefile – Graham B Jan 06 '23 at 18:12
  • I think you're reading too much into those sentences. They just say that make "assumes a target is a file". That's not the same thing as "make redirects all output of the recipe to create a file with the name of the target". – MadScientist Jan 06 '23 at 18:41
  • You're right, I did misunderstand. Thanks for helping again. I know I'm asking a lot of "noob" questions, but I have nobody else to ask. No coworkers who code, no friends who code. I am sorry if these questions are too basic for stack overflow. – Graham B Jan 06 '23 at 19:02

0 Answers0