Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go run filling up /tmp folder on Linux (Fedora 40) #68094

Closed
ad-on-is opened this issue Jun 20, 2024 · 3 comments
Closed

go run filling up /tmp folder on Linux (Fedora 40) #68094

ad-on-is opened this issue Jun 20, 2024 · 3 comments

Comments

@ad-on-is
Copy link

ad-on-is commented Jun 20, 2024

Go version

go version go1.22.4 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/adonis/.cache/go-build'
GOENV='/home/adonis/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/adonis/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/adonis/go'
GOPRIVATE=''
GOPROXY='direct'
GOROOT='/usr/lib/golang'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib/golang/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2427802048=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I'm running a script that watches for file changes, and then executes go run main.go

watchexec -r -e go -- go run main.go serve --http 0.0.0.0:8090

Obviously since this builds and runs multiple times, go seems to create a new folder under /tmp/go-buildxxxxx storing the built executable, which in my case has 32MB

What did you see happen?

This results in an accumulation of unnecessary go-buildxxxx folders overfilling tmpfs volume on Fedora 40.

$: df -h
Filesystem                                       Size  Used Avail Use% Mounted on
tmpfs                                             16G   16G   0G   100% /tmp

Deleting all go-build* folders from /tmp brings /tmp down to 1% in my case.

What did you expect to see?

go run should not create multiple /tmp/go-buildxxxx folders when executing the build command multiple times within the same project. Or it should at least clean them up when the process is terminated.

@gabyhelp
Copy link

@seankhliao
Copy link
Member

go run does clean up directories if given the opportunity, you should probably be using a signal like SIGINT. see also #40467

Closing as an issue with third party tooling.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jun 20, 2024
@ad-on-is
Copy link
Author

@seankhliao Thx... I did some more investigation, and adding SIGINT to the command solves the issue indeed.

watchexec -r -e go --stop-signal SIGINT -- go run main.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants