Changing to non-standard directory in travis and keeping cache there

I wanted to use for windows certain folder c:\dev1, which expands to be as /c/dev1 when
using it from git bash. creating such directory is possible on windows machine, also on linux it’s possible as well, with specific set of commands:

sudo mkdir -p /c/dev1
sudo chown -R $USER:$USER /c/dev1
cd /c/dev1

(Steps can be executed anywhere,for example during script or before_cache build phase)

That is working ok, until you try to save and restore cache in same folder. Saving cache works ok, but unfortunately restoring cache does not work.

As a result I’ve ended up listing all supported cache folders, like this:

cache:
    directories:
    # Windows
    - /c/dev1/project/out
    # Linux
    - /home/travis/build/project/out

But of course this produces some warning in case if folder does not exists - when cache is saved.

Is it possible to specify folder per os name or be able to restore cache to different (non existing) folder ?

Please link to a build exposing how exactly this “does not work”.

Directories that are added to cache should be created as necessary at cache search&restore stage, there’s no need to create them manually.

You can specify cache: at job level – under matrix: include:.

That’s right. Or I have tried to do same thing via environment variable:

matrix:
  include:
  - os: linux
    env: BUILD_TYPE=Release
         BUILD_DIR=/home/travis/build

  - os: linux
    env: BUILD_TYPE=Debug
         BUILD_DIR=/home/travis/build

  - os: windows
    env: BUILD_TYPE=Release
         BUILD_DIR=/c/dev1

  - os: windows
    env: BUILD_TYPE=Debug
         BUILD_DIR=/c/dev1

git:
  clone: false

cache:
    directories:
    $BUILD_DIR/cppreflect/out

Thank you for fast reply.