Skip to content

SBT >= 1.4.5 removes its parent's temporary directories on MacOS #6931

@note

Description

@note

steps

First create the minimal SBT project with:

mkdir -p minimal-sbt-project/project && echo "sbt.version=1.6.2" > minimal-sbt-project/project/build.properties

Then, run the following script:

#!/bin/bash

# Exit on any failure
set -e

COUNT=10

for i in $(seq $COUNT); do
        FILE=`mktemp -d`
        stat "$FILE"
        sbt -version
        stat "$FILE"
done

problem

On my machine it consistently fails with:

> ./now.sh
16777232 21034573 drwx------ 2 michal staff 0 64 "Jun 23 16:01:42 2022" "Jun 23 16:01:42 2022" "Jun 23 16:01:42 2022" "Jun 23 16:01:42 2022" 4096 0 0 /var/folders/kv/xdkw5txn6kv5b58gvztphzdm0000gn/T/tmp.gNNuDyDk
sbt version in this project: 1.6.2
sbt script version: 1.6.2
stat: /var/folders/kv/xdkw5txn6kv5b58gvztphzdm0000gn/T/tmp.gNNuDyDk: stat: No such file or directory

Sometimes it fails after a few iterations, but COUNT=10 is enough to make it fail consistently on my machine.

expectation

I would expect SBT not to delete the directory created with mktemp -d

notes

I know it may look ridiculous to even suspect SBT here which wasn't passed the file in the first place, but I have a number of reasons to believe that's the case:

  • if I change sbt.version to e.g. 1.3.13 (or anything prior 1.3.13) the problem goes away. The problem persists for any sbt version greater or equal to 1.4.5. I am not sure about <1.4.0, 1.4.4> version range as those versions don't work on my machine because of the architecture (I have M1)
  • if you think that there's something about the script - I am able to reproduce it consistently just by executing commands sequentially

another observations

My MacOS version: 12.4. I had this problem before updating from 12.1 as well
Chip: Apple M1 Pro

Happens for all JDKs I tried:

openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

openjdk version "1.8.0_322"
OpenJDK Runtime Environment (build 1.8.0_322-b06)
OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)

openjdk version "11.0.13" 2021-10-19 LTS
OpenJDK Runtime Environment (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM (build 11.0.13+8-LTS, mixed mode)

It happens only for temporary directories. Namely, if you change mktemp -d to mktemp script works just fine.

It doesn't seem to be related to anything that sbt does on its exit, I see the file gone already after opening interactive sbt.

While it's easy to reproduce on my laptop, none of 2 people I asked for running it on MacOS had this issue.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions