Cannot open output file, permission denied
So I keep getting this error when trying to compile C code using CodeBlocks.
cannot open output file [filename.exe] permission denied
It only started today, and it’s sporadic and inconsistent. It usually goes away if I shut CodeBlocks down and restart the project, but not always. Sometimes it even goes away when I just press F9 (build & run) several times. I always check Task Manager, but there are never any .EXEs running with my file’s name, or anything related to it.
I’ve also noticed that if this problem occurs and I then try to delete the .EXE manually or otherwise interact with it, Windows tells me I need administrator permission to do so (this is a private PC, and as far as I know I am an administrator on it).
The first time it occurred, the only thing I had added to the code beyond what was in the previous version was a debugging report sent to cout – hardly anything arcane. It sometimes occurs even when no code was changed from a previous version.
What could this be? It’s not game-breaking, yet, but it’s irritating and I’d rather it didn’t get worse.
EDIT: This is old by now, but just in case anyone else is having similar problems, the workaround I currently use is just to consistently delete [filename.exe] before trying to run the code again. This avoids the problem, though it is annoying.
Ioerror: [errno 13] permission denied when trying to open hidden file in "w" mode
Here are the detailed differences:-
“r” Open text file for reading. The stream is positioned at the
beginning of the file.
“r ” Open for reading and writing. The stream is positioned at
beginning of the file.
“w” Truncate file to zero length or create text file for writing.
The stream is positioned at the beginning of the file.
“w ” Open for reading and writing. The file is created if it does
exist, otherwise it is truncated. The stream is positioned at
the beginning of the file.
“a” Open for writing. The file is created if it does not exist.
stream is positioned at the end of the file. Subsequent writes
to the file will always end up at the then current end of file,
irrespective of any intervening fseek(3) or similar.
“a ” Open for reading and writing. The file is created if it does
exist. The stream is positioned at the end of the file. Subse-
quent writes to the file will always end up at the then current
end of file, irrespective of any intervening fseek(3) or similar.
From python documentation – http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files:-
On Windows, ‘b’ appended to the mode opens the file in binary mode, so
there are also modes like ‘rb’, ‘wb’, and ‘r b’. Python on Windows
makes a distinction between text and binary files; the end-of-line
characters in text files are automatically altered slightly when data
is read or written. This behind-the-scenes modification to file data
is fine for ASCII text files, but it’ll corrupt binary data like that
in JPEG or EXE files. Be very careful to use binary mode when reading
and writing such files. On Unix, it doesn’t hurt to append a ‘b’ to
the mode, so you can use it platform-independently for all binary
So if you are using
w mode, you are actually trying to create a file and you may not have the permissions to do it.
r is the appropriate choice.
If you are in a situation where you do not yet know where your
.picasi.ini exists or not and your windows user has file creation permissions in that directory and you want to append new information instead of starting at the beginning of the file (a.k.a “append”), then
a will be the appropriate choice.
It has nothing to do with whether your file is hidden or not.
Make sure you have a key that is being used
The ssh-add command should print out a long string of numbers and letters. If it does not print anything, you will need to generate a new SSH key and associate it with GitHub.
Tip: On most systems the default private keys (~/.ssh/id_rsa and ~/.ssh/identity) are automatically added to the SSH authentication agent. You shouldn’t need to run ssh-add path/to/key unless you override the file name when you generate a key.
Should the sudo command be used with git?
You should not be using the sudo command with Git. If you have a very good reason you must use sudo, then ensure you are using it with every command (it’s probably just better to use su to get a shell as root at that point).
Verify the public key is attached to your account
You must provide your public key to GitHub to establish a secure connection.
If you don’t see your public key in GitHub, you’ll need to add your SSH key to GitHub to associate it with your computer.
Warning: If you see an SSH key you’re not familiar with on GitHub, delete it immediately and contact GitHub Support, for further help. An unidentified public key may indicate a possible security concern. For more information, see “Reviewing your SSH keys.”