Sometimes I also face this issue, Firstly is your device sync to onedrive?
otherwise usually restarting the uipath works for me.
If your device is sync to onedrive so what happens is that sometimes the project in background is getting sync and the same time when we try to publish it give this error. This is my own observation.
You are using a Cloud Orchestrator or an On-Premise one?
Can you check if you can see more details about the encountered error in the Event Viewer logs? (Path is Start > Event viewer > Windows Logs > Application)