I ran into this problem when I was trying to save my sketches a second time. The first time saving was fine, but the second time, and any other attempts would fail.
The problem was that I was saving my sketches to the Arduino library folder. You cannot modify sketches that are in the library, for good reason.
So I am now saving my sketches to the folder arduino/my_sketches, and am no longer having any problem.
Retrieving data ...