Menu

#3100 freecol fails to launch if ~/.config ~/.cache ~/.local/share are not present

Fixed_0.12.0
closed-fixed
nobody
None
1
2022-05-01
2017-10-24
No

freecol fails to launch if ~/.config ~/.cache ~/.local/share are not present

It would be good if freecol could create those directories by itself.

Tested on commit 4a9e496b4d1496973b36c3be7093fdec9f89fcf7

Discussion

  • Lone_Wolf

    Lone_Wolf - 2017-10-24

    Those folders are part of the XDG Base Directory specification .
    see https://specifications.freedesktop.org/basedir-spec/latest/

    Creating / maintaining those folders should be done by the xdg support in your OS, not by freecol.
    The xdg base dir spec has been around since 2003 and should be available in all linux variants , what OS / distro are you using ?

     
  • vasya novikov

    vasya novikov - 2017-10-24

    I'm using Arch / XFCE, but it's not really relevant because I run freecol in a jailed environment. The filesystem on ~ is a separate mount in the jail, which is initially empty.

    I wonder how XDG-compliant apps should behave if those dirs are non-existent. All programs I encountered so far just create everything they need.

    As far as I understand XDG, it tells where to store your files, but does not say you dirs should already be created.

    // As a side note, I like freecol be compliant to XDG specs regarding file placement and directory layout. It's just the question how to behave if they don't exist, yet.

     
    • Mike Pope

      Mike Pope - 2017-10-26

      According to the XDG spec:

      "If, when attempting to write a file, the destination directory is non-existant an attempt should be made to create it with permission 0700"

      However AFAICT it does not require the directory/s to be created on read.

      For Freecol, I think this means we need to tolerate the .config directory being absent, as we usually only read from it. The other two will need to be created on file write, which happens immediately in the case of the log file in .cache, and when the first auto/save file for the data directory.

       
  • Lone_Wolf

    Lone_Wolf - 2017-10-28

    sounds like a good solution, mike.

     
  • Mike Pope

    Mike Pope - 2017-11-11

    Should be fixed in git.c287b74.

     
  • Mike Pope

    Mike Pope - 2017-11-11
    • status: open --> closed-fixed
    • Group: Current --> Fixed_trunk
     
  • vasya novikov

    vasya novikov - 2017-11-11

    Sourceforge doesn't seem to allow commit lines commenting, so I'll comment here. Is it OK?:

      • } catch (IOException ioe) { / ignore / }

    Should we maybe log what's going on? Like logger.warn("Failed to set directory permissions for " + dir.toPath()) ? Or the System.out thing, anyway.

     

    Last edit: vasya novikov 2017-11-11
    • Mike Pope

      Mike Pope - 2017-11-11

      so I'll comment here. Is it OK?

      No worries.

      Should we maybe log what's going on

      That would be the usual practice, but not in this case:
      1. There is no logger available in FreeColDirectories, its routines are/can be called before we even configure the logger.
      2. I am struggling to think of a circumstance where you can successfully create the directory but then not be able to chmod.

       
  • Mike Pope

    Mike Pope - 2022-05-01
    • Group: Fixed_trunk --> Fixed_0.12.0
     

Log in to post a comment.