issue installing package

Hi everyone.
I'm facing an issue with any R package I try to install.
If I try to install dplyr typing
install.packages("dplyr")
I get this error


Such error happens with any R package.
Does anyone know how to fix this problem?

Thank you very much

What version of MacOS are you using? What happens if you open the Terminal and type

which tar

(then Enter)?

Hi. Thanks for your reply.
My macOS is Monterey version 12.6 and if I type which tar in the terminal I get
/usr/bin/tar .
It turned out there was a problem with my bash and after fixing it seems to work now.