Home > Software engineering >  Updating R and RScript in the command line to match newly installed version
Updating R and RScript in the command line to match newly installed version

Time:09-27

I had a difficult time searching for an answer on this, so I thought I'd reach out here for help. I updated R to 4.2.1 and update RStudio as well, but I found that the R in my mac's terminal is still using the old version (3.5.1). Does anyone know why this might be and how I can change the R and Rscript command in my terminal to be using the latest version of R?

Thank you :)

CodePudding user response:

I might have just found a workaround.

Instead of running R or Rscript, I can run /usr/local/bin/R or /usr/local/bin/Rscript. This will load the most recent version of R/Rscript.

CodePudding user response:

Using the feedback from user2554330's comment, I added the following to my .bash_profile.

# Setting PATH for R 4.2.1 
PATH="/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/bin:${PATH}"
export PATH

Then I ran source ~/.bash_profile. Now R and, I assume Rscript, run the correct version.

I still find the PATH variable confusing tbh, but this problem is solved at least.

Thanks user2554330!

Edit: I should mention that /usr/local/bin/R/ is an alias that points to /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/bin/R, which is how I found this path for R. Same for Rscript.

  • Related