Error in contrib.url(repos, "source") :

https://community.rstudio.com/t/can-not-run-knit-in-rmarkdown/85954?u=nisha

I am getting the same error and at the end it was not really explained how the error was solved can anyone help me with this?

There's discussion on this reply helping diagnose the issue.

What happens when you take cderv's advice there?

That is,

This is not an error with Rmarkdown, it is an error with R saying you don't have any CRAN repo configure. If you have a call to install.package or else in your Rmd doc, it could cause the error.

Just configure a cran mirror if you haven't one. Are you using RStudio IDE BTW?