failed to preview Markdown

I am trying to preview the markdown but I was asked to install several packages. It successfully downloaded, while it said it was installed, I still cannot preview the markdown as expected. Every time I hit the preview button RStudio asks me to install the same package again.
the following is the output from the terminal.

** Installing R Package Dependencies for R Markdown: 'knitr', 'rmarkdown', 'stringi', 'stringr'
[1/4] Installing stringi...
trying URL 'https://cran.rstudio.com/src/contrib/stringi_1.6.2.tar.gz'
Content type 'application/x-gzip' length 7575370 bytes (7.2 MB)
==================================================
downloaded 7.2 MB

ERROR: failed to lock directory ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library’ for modifying
Try removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/00LOCK-stringi’
[2/4] Installing stringr...

The downloaded source packages are in
	‘/private/var/folders/t6/qy2rcbdx0g9_fv98q1g48v_h0000gn/T/RtmpzIZzxZ/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
also installing the dependency ‘stringi’

trying URL 'https://cran.rstudio.com/src/contrib/stringi_1.6.2.tar.gz'
Content type 'application/x-gzip' length 7575370 bytes (7.2 MB)
==================================================
downloaded 7.2 MB

trying URL 'https://cran.rstudio.com/src/contrib/stringr_1.4.0.tar.gz'
Content type 'application/x-gzip' length 135777 bytes (132 KB)
==================================================
downloaded 132 KB

ERROR: failed to lock directory ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library’ for modifying
Try removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/00LOCK-stringi’
[3/4] Installing knitr...
ERROR: dependency ‘stringi’ is not available for package ‘stringr’
* removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringr’

The downloaded source packages are in
	‘/private/var/folders/t6/qy2rcbdx0g9_fv98q1g48v_h0000gn/T/RtmpzIZzxZ/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
also installing the dependencies ‘stringi’, ‘stringr’

trying URL 'https://cran.rstudio.com/src/contrib/stringi_1.6.2.tar.gz'
Content type 'application/x-gzip' length 7575370 bytes (7.2 MB)
==================================================
downloaded 7.2 MB

trying URL 'https://cran.rstudio.com/src/contrib/stringr_1.4.0.tar.gz'
Content type 'application/x-gzip' length 135777 bytes (132 KB)
==================================================
downloaded 132 KB

trying URL 'https://cran.rstudio.com/src/contrib/knitr_1.33.tar.gz'
Content type 'application/x-gzip' length 892378 bytes (871 KB)
==================================================
downloaded 871 KB

ERROR: failed to lock directory ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library’ for modifying
Try removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/00LOCK-stringi’
ERROR: dependency ‘stringi’ is not available for package ‘stringr’
* removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringr’
ERROR: dependency ‘stringr’ is not available for package ‘knitr’
* removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/knitr’
[4/4] Installing rmarkdown...

The downloaded source packages are in
	‘/private/var/folders/t6/qy2rcbdx0g9_fv98q1g48v_h0000gn/T/RtmpzIZzxZ/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
also installing the dependencies ‘stringi’, ‘knitr’, ‘stringr’

trying URL 'https://cran.rstudio.com/src/contrib/stringi_1.6.2.tar.gz'
Content type 'application/x-gzip' length 7575370 bytes (7.2 MB)
==================================================
downloaded 7.2 MB

trying URL 'https://cran.rstudio.com/src/contrib/knitr_1.33.tar.gz'
Content type 'application/x-gzip' length 892378 bytes (871 KB)
==================================================
downloaded 871 KB

trying URL 'https://cran.rstudio.com/src/contrib/stringr_1.4.0.tar.gz'
Content type 'application/x-gzip' length 135777 bytes (132 KB)
==================================================
downloaded 132 KB

trying URL 'https://cran.rstudio.com/src/contrib/rmarkdown_2.9.tar.gz'
Content type 'application/x-gzip' length 3246617 bytes (3.1 MB)
==================================================
downloaded 3.1 MB

ERROR: failed to lock directory ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library’ for modifying
Try removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/00LOCK-stringi’
ERROR: dependency ‘stringi’ is not available for package ‘stringr’
* removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringr’
ERROR: dependency ‘stringr’ is not available for package ‘knitr’
* removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/knitr’
ERROR: dependencies ‘knitr’, ‘stringr’ are not available for package ‘rmarkdown’
* removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/rmarkdown’

The downloaded source packages are in
	‘/private/var/folders/t6/qy2rcbdx0g9_fv98q1g48v_h0000gn/T/RtmpzIZzxZ/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done


✔ Packages successfully installed.
Warning messages:
1: In utils::install.packages("stringi", repos = "https://cran.rstudio.com/") :
  installation of package ‘stringi’ had non-zero exit status
2: In utils::install.packages("stringr", repos = "https://cran.rstudio.com/") :
  installation of package ‘stringi’ had non-zero exit status
3: In utils::install.packages("stringr", repos = "https://cran.rstudio.com/") :
  installation of package ‘stringr’ had non-zero exit status
4: In utils::install.packages("knitr", repos = "https://cran.rstudio.com/") :
  installation of package ‘stringi’ had non-zero exit status
5: In utils::install.packages("knitr", repos = "https://cran.rstudio.com/") :
  installation of package ‘stringr’ had non-zero exit status
6: In utils::install.packages("knitr", repos = "https://cran.rstudio.com/") :
  installation of package ‘knitr’ had non-zero exit status
7: In utils::install.packages("rmarkdown", repos = "https://cran.rstudio.com/",  :
  installation of package ‘stringi’ had non-zero exit status
8: In utils::install.packages("rmarkdown", repos = "https://cran.rstudio.com/",  :
  installation of package ‘stringr’ had non-zero exit status
9: In utils::install.packages("rmarkdown", repos = "https://cran.rstudio.com/",  :
  installation of package ‘knitr’ had non-zero exit status
10: In utils::install.packages("rmarkdown", repos = "https://cran.rstudio.com/",  :
  installation of package ‘rmarkdown’ had non-zero exit status

solved by the following code

install.packages(“rmarkdown”, type =“mac.binary”)

see bbrew solution

This topic was automatically closed 7 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.