0

I just got a new M1 mac with macOS Catalina at my workplace, and I'm having trouble when running R from the command line (actually, when running it from a Makefile). I'm relatively new to the shell so there's probably something I'm missing here.

I want to run R projects using a Makefile. I installed R 3.6 using a downloaded package, and while it does run when I type R in the Terminal, it does not when I write a Makefile that calls R CMD BATCH scr.R.

The only thing I know is that it seems to be using different shells. While the terminal uses zsh (echo ${SHELL} gives /bin/zsh), when I run it through a Makefile, it uses /bin/sh, which points to bash: sh --version > GNU bash, version 3.2.57(1)-release ....

I tried installing R with homebrew and it did work, but it's not my ideal solution because a) I want R 3.6 and getting previous versions in homebrew is a bit of a headache, and b) I don't want to install the packages twice.

I also tried changing the /bin/sh symlink so it points to /bin/zsh, but it didn't work either.

Even if I add SHELL := zsh at the beginning fo the Makefile, I still get a similar error: zsh:1: command not found: R.

So my question is: what is exactly going on here? Why do I get a different output when using the Terminal than when calling the commands via a Make? And how can I fix this?

Thanks.

P.S. I forgot to mention. The "normal" R installation from CRAN works on the Terminal because I added an alias to .zshrc. But the shell that runs with Make doesn't seem to read this config file.

1 Answer 1

0

Just FYI, I solved by adding the R home address (find it typing R.home() in R) to the PATH. This should work:

sudo echo "/Library/Frameworks/R.framework/Resources" >> /etc/paths

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .