Opened 4 weeks ago

Last modified 4 weeks ago

#60634 assigned defect

skaffold: usage: mktemp [-d] [-q] [-t prefix] [-u] template ...

Reported by: ryandesign (Ryan Schmidt) Owned by: breun (Nils Breunese)
Priority: Normal Milestone:
Component: ports Version: 2.6.2
Keywords: yosemite Cc:
Port: skaffold

Description

skaffold fails to build on Yosemite and probably earlier:

usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix 
make: *** [cmd/skaffold/app/cmd/statik/statik.go] Error 1

Change History (12)

comment:1 Changed 4 weeks ago by breun (Nils Breunese)

hack/generate-statik.sh calls mktemp -d: https://github.com/GoogleContainerTools/skaffold/blob/v1.10.1/hack/generate-statik.sh#L25

On Catalina that command creates a temporary directory and returns the name:

~ % mktemp -d
/var/folders/m7/7n1s8z9r8vlfjs008k8z7sr80000gn/T/tmp.Pj97B6FP

I don't have access to a Yosemite system, but apparently that is not a valid command on Yosemite? Any idea what a valid alternative command would be?

comment:2 Changed 4 weeks ago by kencu (Ken)

on 10.6.8:

$ /usr/bin/mktemp -d
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix 

$ /opt/local/libexec/gnubin/mktemp -d
/var/folders/I0/I0fOotq3ErGZHYxrmmWiqU+++TI/-Tmp-/tmp.7LRt9Brr61 

so coreutils fulfills the needs.

Last edited 4 weeks ago by kencu (Ken) (previous) (diff)

comment:3 Changed 4 weeks ago by breun (Nils Breunese)

Does anyone know until which macOS version coreutils is necessary to make mktemp -d work?

comment:4 Changed 4 weeks ago by kencu (Ken)

It would appear 10.10 and less <https://ports.macports.org/port/skaffold/summary>

Last edited 4 weeks ago by kencu (Ken) (previous) (diff)

comment:5 Changed 4 weeks ago by ryandesign (Ryan Schmidt)

It should hardly be difficult to rewrite the mktemp usage so that it is compatible with all operating systems (to wit: the template parameter is not optional). After all, macOS got by with that version of mktemp for a long time.

comment:6 Changed 4 weeks ago by kencu (Ken)

Yes, if you don't want to simply use coreutils, you can rewrite the code. There are always 10 ways to accomplish most anything.

Last edited 4 weeks ago by kencu (Ken) (previous) (diff)

comment:7 Changed 4 weeks ago by breun (Nils Breunese)

I've created a pull request upstream to explicitly add -t tmp to all calls in Skaffold scripts, which should fix this issue: https://github.com/GoogleContainerTools/skaffold/pull/4319

Last edited 4 weeks ago by breun (Nils Breunese) (previous) (diff)

comment:8 Changed 4 weeks ago by ryandesign (Ryan Schmidt)

The most portable solution is to use the template parameter, e.g.

mktemp -d ${TMPDIR:-/tmp}/skaffold.XXXXXX

You can check on your Mac whether that works with both macOS mktemp and the coreutils port's gmktemp which is what mktemp is on Linux. (It does for me.)

comment:9 Changed 4 weeks ago by breun (Nils Breunese)

Skaffold builds on Ubuntu 16.04 via Travis and there mktemp has even different behavior: it expects the prefix to contain Xs, whereas mktemp on Mac doesn't. I'd say the Mac's behavior makes more sense, because there it is actually a prefix, while on Ubuntu it is used as a template really.

Would the best solution then be for the Skaffold port to (only on Yosemite and older?) depend on coreutils and patching the scripts to replace all calls to mktemp with /opt/local/libexec/gnubin/mktemp?

comment:10 Changed 4 weeks ago by ryandesign (Ryan Schmidt)

No the best solution is to rewrite the mktemp usage so that it works everywhere, as in comment:8.

comment:11 Changed 4 weeks ago by breun (Nils Breunese)

I've updated my upstream pull request with that solution, but it's used in like 15 places in Skaffold scripts.

comment:12 Changed 4 weeks ago by breun (Nils Breunese)

The pull request has been merged upstream, so hopefully this will be fixed in the next upstream release.

Note: See TracTickets for help on using tickets.