Screenshots don't write file

Solution 1:

tl;dr

Open the terminal and write

defaults write com.apple.screencapture location ~/Desktop
defaults write com.apple.screencapture target file
killall SystemUIServer

Explanation

Being on Mac OS 10.14 (Mojave), I ran into the same issue. At one point the screenshot shortcuts 'would not work' anymore. (I was able to save a screenshot to clipboard using Cmd+Shift+Ctrl+3, but it wouldn't work to save a screenshot to the desktop anymore.)

Looking at the output of defaults read com.apple.screencapture in the terminal, I noticed a target = clipboard; being set:

{
    "last-messagetrace-stamp" = "568547998.720744";
    location = "/Users/kim/Desktop/";
    target = clipboard;
}

Changing the target back to file (defaults write com.apple.screencapture target file) and restarting the SystemUIServer (killall SystemUIServer) would restore the expected behaviour.

It looks like the new screenshot controls which were introduced in Mojave overwrite the target setting (Cmd+Shift+5, see the official apple support page for more information). When selecting "Clipboard" in the "Save to" menu, the target in com.apple.screencapture will also be set to clipboard. For some reason, this setting will then also affect the "take screenshot to file" shortcuts.

Note: Of course, you could also reset the target setting in the new screenshot controls. Just choose any folder location in the "Save to" option (e.g. Desktop, Documents or any other location) and the target should be set to file again.

Solution 2:

That sounds to me like a misconfiguration of the target directory, perhaps it was changed at some point or the location is no longer valid. You mention having changed the target directory but didn't mention how. My guess is that the target directory was not entered correctly. Please verify it using the method below.

Determining the target location

  1. Open Terminal and type: defaults read com.apple.screencapture location
  2. Check that the directory returned by the above command is a valid/accessible location on your mac by navigating to it through the Finder or using the command: open /path/to/returned/location - replacing the example path here with that which was returned by the above command.
  3. If all was successful, you should see those screenshots from earlier, in that folder. If not, try the commands in the next section.

What next?
If you had no success with the commands above, try changing the default location to which screenshots are saved.

In Terminal, type:
defaults write com.apple.screencapture location /path/to/new/location hit the enter/return key to execute the command. Note that it is best to drag the folder into the Terminal window for the correct path to be entered - this is where most mistakes happen. For changes to take effect, the SystemUIServer needs to be restarted with the killall SystemUIServer command.

By default, the target location for screenshots is the desktop at /Users/[username]/Desktop.

Any unknown combination of events could have lead to the initial change so sometimes verifying and telling the system where to put the data once more is the quickest fix.

I would be interested in following up with you on this, let me know if that was helpful or if you require any more information.