When publishing either on Service Studio, Service Center or even when deploying to another environment on LifeTime, an error occurs that states:
The process cannot access the file because it is being used by another process
This error occurs in the compilation stage and the publication process fails.
This error is caused by concurrency when two or more different processes try to access and lock the same file. A quick action you can take is to wait a few minutes and then try to publish again.
So that you can troubleshoot the cause and prevent this from happening again, we'll list the most common causes, in order.
The presented causes and their respective solutions apply to self-managed OutSystems environments. This is not expected to occur while publishing on an OutSystems cloud environment. However, if that's ever the case, contact OutSystems Support.
This is the most common cause for this error.
Antivirus software may perform regular scans on the Platform Server's files and while doing so, locks the files. Antivirus checks can be triggered when the Platform Server is generating new source code during publication. If the Platform Server accesses a file that's locked by an antivirus, this error occurs.
OutSystems recommends to exclude some folders from antivirus scanning. Make sure that those folders are on the exclusions list. If they aren't, add them and retry the publication.
Various other processes from third party software may also lock OutSystem files while the Platform Server is trying to access them.
Identifying the process and the program running it allows you to act on it, either by killing the process or reconsidering the use of those programs. While the way to tackle it highly varies with the program at hand, these tools provide the information necessary to make a decision.