Cannot install any packages

package ‘digest’ successfully unpacked and MD5 sums checked
package ‘base64enc’ successfully unpacked and MD5 sums checked
Error in install.packages : cannot open file 'C:/Users/OneDrive/Documents/R/win-library/4.1/file6164384a2abb/rlang/help/figures/rlang.png': Permission denied

The problem is probably OneDrive. I'm unable to communicate with OneDrive outside of its GUI without a VPN connection.

Might help to set the package location to a local drive instead. I prefer my packages locally anyway since installing and loading them is noticeably faster locally than over a remote drive.

Dear Hayward,

Thank you for your great suggestion. I changed the myPath/ .libpath to local drive and it's now working.
It's strange that it doesn't work in OneDrive as initially, it worked on my system but I guess all the new windows laptop's default path for R is based on C:/Users/OneDrive/Documents/R.Win-library/4.1.

Thanks again for your help!