I am getting the following error while performing a system wide upgrade i.e. sudo pacman -Syu
error: failed to commit transaction (conflicting files)
r: /usr/lib/R/library/foreign/COPYRIGHTS exists in filesystem
r: /usr/lib/R/library/rpart/Meta/vignette.rds exists in filesystem
r: /usr/lib/R/library/rpart/NEWS.Rd exists in filesystem
r: /usr/lib/R/library/rpart/doc/index.html exists in filesystem
r: /usr/lib/R/library/rpart/doc/longintro.R exists in filesystem
r: /usr/lib/R/library/rpart/doc/longintro.Rnw exists in filesystem
r: /usr/lib/R/library/rpart/doc/longintro.pdf exists in filesystem
r: /usr/lib/R/library/rpart/doc/usercode.R exists in filesystem
r: /usr/lib/R/library/rpart/doc/usercode.Rnw exists in filesystem
r: /usr/lib/R/library/rpart/doc/usercode.pdf exists in filesystem
r: /usr/lib/R/library/survival/doc/sourcecode.pdf exists in filesystem
Errors occurred, no packages were upgraded
You probably didn't use pacman to install 'r', thus the files listed above are not present in the local database. I believe you can safely run 'pacman -Syyu --force' to upgrade the package properly and get rid of the error message in the future.
I believe it is strongly advised not to use --force, especially for a system-wide upgrade. But it could be ok to use it only for the specific package that is causing this problem.
In this case you could use pacman -Qo to check if one of those files belong to a package or not.
If you indeed installed those from a third party source, it may be cleaner to delete the whole directorie(s) you copied manually instead of using --force on the new package, so that there are no leftover files.