I’ve been working with OpenCV and two times already, the Robot.java file has stopped working.
I’m not sure what’s causing this, but I would be writing code, and then once I try to save the Robot.java file, it says that I can’t. However, I would still be able to save all the other files. Additionally, I also wouldn’t be able to delete the file, from the File Explorer or Git Bash. The error for Git Bash when I try to delete the entire repository from my computer with rm -rf would be rm: cannot remove ‘…Robot.java’: File exists.
Also, since I have a Mac that’s been dual booted to Windows and have the file saved in an SD card, I tried going to my Mac (I work on the code from my Windows) and deleting it there. However, the first time I restarted back to my Mac, the SD card wasn’t there, even after I took it out and put it back in again. After a few hours though, I restarted my laptop again, and the SD card would show up. The first time this happened, I was able to delete it from here.
This time, I didn’t though, since I wanted to keep it and use it to provide a better description of my problem here, but then, when I went back to my Windows after another few hours, Robot.java was “fixed”, meaning that I can now open, save, and delete it. However, all the code there has been erased.
I was just wondering what could be causing this problem, since every time it’s happened, I haven’t been doing anything special or weird. Is there a way I can prevent this from happening again?
I don’t know what the problem is, but it sounds like it might be that the file somehow went read only. Can you run “ls -l” in Git Bash next time it happens?
Another possibility is that there are random whitespace characters in the file name. That seems unlikely though as the file wouldn’t compile in that case.
I would bet that you are having weird and intermittent file access problems on the SD card removable drive.
You do have a couple of different options with your dual boot. If you have any extra hard drive space on any of your volumes, you could just create a small partition with a file system that is accessible (and writable) by both operating systems. ExFat (or even FAT32) would be sufficient enough to have a simple scratch space where you could write the files from both sides if needed. Then you wouldn’t have the oddness of the removable drive going in and out (potentially).
Potentially, I would think more than that, it’s really related to the intermittent file access that can happen on a removable drive (SD Card) that VS Code may not do well with.
Shot in the dark, but do you have the file open in any sort of editor? It could be the result of a file lock in Windows. I know I’ve had weird issues on occasion like this in the past at work when accessing Windows Files from the Windows Subsystem for Linux that are also open in another editor. I know tools exist that can check if a file is locked, and remove that lock, but I don’t have my work machine handy to check what it is called.