Skip to content

Failure to resolve XDG dirs produces unhelpful error messages

To reproduce

Mangle your entry in /etc/passwd so getpwuid will fail. Run env - target/debug/arti proxy

Expected output

An error message explaining that your home directory could not be determined because your uid doesn't appear to be listed in the password database. (Similarly, other kinds of trouble should be properly reported too.)

Actual output

target/debug/arti: error: identify default config file locations: Couldn't determine XDG Project Directories, needed to resolve a path; probably, unable to determine HOME directory

(assuming !1480 (merged) is merged)

Analysis

The error message is from tor_config::path::Error::NoProjectDirs, which is a unit variant. It is a unit variant because we are using directories to find the XDG directories (eg, the config directory) and directories doesn't return errors but just says None.

I have filed upstream ticket #85 for the API problem in directories.

This error is generated on Android if the default configuration paths are ever used, because directories returns None on Android. That's upstream ticket #83. (For this reason I have added the Sponsor 101 label which seemed the best one to represent that this affects Android.)

Our options would seem to be:

  1. Use something else instead of directories. I investigated and at the time of writing the only libraries that do better at this are microxdg and xdg, and even those give rather vague error messages.
  2. Use a default value of our own if directories says None. This seems hazardous.
  3. Work on this upstream in directories or one of the competitor crates (look for directories-next and dirs, too).