This could be caused by software (either a stuck GTA process or an antivirus) having a lock on the file, not allowing FiveM to access it for reading or writing. Additionally, this issue could also be caused if the file being accessed is in a directory that requires administrative permissions (such as Program Files to name an example).
Possible solutions
If the process is stuck, restart your computer.
If this keeps occurring
If this keeps occurring, another process may be getting a handle to one of the files FiveM is trying to access and you may need to figure out why. In that case you may need to use Resource Monitor, which comes bundled with Windows 7, 8, 10 and 11.
Steps on finding the responsible lock using Resource Monitor
- Press Win+R and type in resmon.
- Click on Ok.
- When resmon is open, click on the CPU tab.
- Under associated handles search for server-cache-priv
- Take a look at the Image column, if a process that is not named "FiveM_b(GameBuild)_GTAProcess.exe" (for example "FiveM_b2545_GTAProcess.exe") is not the one holding a lock on the file, then it's possible that the responsible process has been identified.
If you have identified the process that is causing the file lock, you may need to disable or terminate that process in order to release the lock on the file, this can be done by clicking the process under Associated Handles, followed by right click and clicking on End Process.
If you have recently installed new software, such as an antivirus program, and it is causing a file lock issue, you may be able to disable the specific feature or setting that is responsible for the lock. Check the program's documentation or settings to see if there is an option to disable this feature. For the non-knowledgeable user, it's advisable to do this prior to resorting to other methods such as services.msc or disabling incorrect Startup applications due to user error and causing more issues.
As a last resort
As a last resort, you may try disabling the process from running at startup if it's set up as a Windows service (services.msc), which will prevent it from executing again the next time Windows starts. It may also be set as a Startup application (msconfig.exe Windows 7 or lower) or Run/RunOnce subkeys which are usually located under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion" registry key (regedit).