Unable to Install zoo and tidyverse

I'm unable to install the packages zoo and tidyverse on Rstudio. This is the error message that I've received:

Warning in install.packages :
error in running command
Warning in install.packages :
'tar' returned non-zero exit code 127
sh: tar: command not found
Error in install.packages : file ‘/var/folders/nw/ggs20txx4sxbhjfhrlg91nfr0000gn/T//RtmpItObUX/downloaded_packages/fastmap_1.1.1.tgz’ is not a macOS binary package

I have tried uninstalling and installing R and RStudio again as suggested from other previous questions I've seen, even older versions as well - R 4.2.3 and R 3.6.3. I have currently re-installed the latest compatible version for my laptop - R 4.3.1 (the one I initially started with)

For context, my laptop is a Macbook Pro mid-2014 running on macOS Big Sur 11.7.8. Any help wit h this error would be much appreciated. Also, if it's an issue with how old my laptop is, please let me know. Thanks!

This indicates that the $PATH that the RStudio program is using doesn't include /usr/bin, which is where the tar program is to be found. You can confirm this with

Sys.which("tar")

Using the system Terminal.app or iterm.App, try

which tar

and if the correct path, /usr/bin/tar is returned you should be able to open an R session in the terminal or in the separate R.app installed with R to do the install.packages().

Thanks! I've tried your solution and this is what I got:

On RStudio:

Sys.which("tar")
tar
""

On Terminal:
Bea$ which tar
-bash: which: command not found

I was not able to get the path returned to me, is there another way to troubleshoot this? Thank you.

In the terminal again

ls -l /usr/bin | grep which

which should get you similar to this

-rwxr-xr-x 1 root wheel 134208 Jun 15 03:08 which

Likewise

ls -l /usr/bin | grep tar

These should be present by default. Since they are not showing up with which then it is the $PATH environment to check next. Mine looks like

echo $PATH
/Users/ro/.volta/bin:/opt/homebrew/Cellar/python@3.10/3.10.9/bin:/Applications/CMake.app/Contents/bin:/opt/homebrew/bin:/Users/ro/.cargo/bin:/Applications/Julia-1.9.app/Contents/Resources/julia/bin/julia:/usr/local/go/bin:/usr/local/mysql-8.0.28-macos11-x86_64/bin:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/sbin:/Users/ro/.local/bin:/Library/TeX/Root/bin/universal-darwin:/Library/TeX/Root/bin/universal-darwin/pdflatex

somewhere there must be :/usr/bin:.

Do you how to edit your .zshrc to add it if it's missing?

Thank you! We might be getting somewhere now. Unfortunately, grep command cannot be found.

(base) Beas-MacBook-Pro-2:~ Bea$ ls -l /usr/bin | grep which

-bash: grep: command not found

(base) Beas-MacBook-Pro-2:~ Bea$ ls -l /usr/bin | grep tar

-bash: grep: command not found

However, when typing echo $PATH, I get below:

(base) Beas-MacBook-Pro-2:~ Bea$ echo $PATH

/opt/anaconda3/bin:/bin:/condabin:/usr/local/mysql/bin

I did install SQL a few years ago and may have manipulated some things that I don't quite remember. How can I correct the path for R?

And sorry I don't know how to edit my .zshrc if it is missing, would you be able to advise? Thanks so much for helping out.

Anaconda might be to blame. So, take a deep breath and we'll edit your $PATH from the terminal, using the nano editor. The commands of the bottom of its screen, such as ^X mean using the control key and the letter in combination.

First, as a just-in-case,

/usr/bin/cp .zshrc .zshrc.SAV

and if necessary to claw back to where you were

/usr/bin/mv .zshrc.SAV .zshrc

(note the leading period .

Now open for editing in your home directory

cd
/usr/bin/nano .zshrc

and look for the line like this one

export PATH="$PATH:opt/anaconda3/bin:/bin:/condabin:/usr/local/mysql/bin"

and edit it to read

export PATH="$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/sbin:opt/anaconda3/bin:/bin:/condabin:/usr/local/mysql/bin"

all in one line followed by at least one blank line

Save and exit and then check that it's there

/usr/bin/cat .zshrc

followed by

source .zshrc

and now try

which tar

Let me know?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.