MacOS – Mac App Store: We could not complete your purchase – Unknown Error

mac-appstoremacosxcode

I am using a Macbook Pro (2018, 13 inch, 2.3ghz i5) from work, and the previous user had installed Xcode and a few other apps through their apple account. I have since deleted Xcode, but whenever I try to download Xcode again through the app store, or any app for that matter, I get the message "We could not complete your purchase – Unknown Error". I have signed out and in, restarted several times, and looked in the Error Console. The console gives the error "Purchase failed with error: " and I can't find more.
error message
Any help would be greatly appreciated so that I can finally get back to work!

Best Answer

Quit your App Store application if it is open. Launch the terminal application and type the following command:

open $TMPDIR/../C/com.apple.appstore/

A folder named com.apple.appstore will open. Move all the files present in it to Trash. Restart your mac and launch the App Store again. Problem solved!