air-verse / air

☁️ Live reload for Go apps
GNU General Public License v3.0
17.62k stars 804 forks source link

tmp directory is always created in project root #505

Open PhilThurston opened 10 months ago

PhilThurston commented 10 months ago

Right now even if you specify that the tmp directory is different from the project root air will still make a tmp directory in the current root. For example. If your air.toml is like this:

root = "."
testdata_dir = "testdata"
tmp_dir = "/tmp/air"

[build]
  args_bin = []
  bin = "/tmp/air/main"
  cmd = "go build --buildvcs=false -o /tmp/air/main ."
  delay = 1000
...

and you run with the docker container like so:

docker run -it \
    -w "/app" \
    -e "air_wd=/app" \
    -v "$(PWD)":/app \
    -v /tmp/air/go:/go/pkg/mod \
    -p 3000:3000 \
    cosmtrek/air -c .air.toml

the result is that not only will it make a tmp directory in your project root owned by the docker user (usually root) and it will also error out. It looks like this solution is partially resolved with this pull request #318 but that doesn't resolve the fact that air doesn't respect the config and still makes a temp directory where it wants to regardless of the settings listed.