Skip to content

Some issues with mktemp coreutils command on WindowsΒ #2596

@fgimian

Description

@fgimian

Description

I used the following Taskfile.yml:

version: "3"
tasks:
  example:
    cmd: mktemp -d

Upon running task example, I see the following on Windows 11:

πŸ•™ [ 11:36:51 AM ] ❯ task example
task: [example] mktemp -d
task: Failed to run task "example": GetFileAttributesEx /tmp: The system cannot find the file specified.

Furthermore, when executing mktemp --help via the same task, I see:

Usage: mktemp [options] [template]
  -d    Make a directory (shorthand)
  -directory
        Make a directory
  -dry-run
        Do everything save the actual create
  -p string
        Tmp directory to use. If this is not set, TMPDIR is used, else /tmp (shorthand)
  -prefix string
        add a prefix
  -q    Quiet: show no errors (shorthand)
  -quiet
        Quiet: show no errors
  -s string
        add a prefix (shorthand, 's' is for compatibility with GNU mktemp
  -suffix string
        add a suffix to the prefix (rather than the end of the mktemp file)
  -tmpdir string
        Tmp directory to use. If this is not set, TMPDIR is used, else /tmp
  -u    Do everything save the actual create (shorthand)
task: Failed to run task "example": flag: help requested

I expected two differences:

  1. The appropriate temp directory on Windows should have been used by default (exposed via the $TEMP env var)
  2. The help should have shown -- before each option instead of a single - which doesn't work correctly

I worked around this as follows:

mktemp --tmpdir "$TEMP" -d

Version

3.46.3

Operating system

Windows 11 Pro

Experiments Enabled

No response

Example Taskfile

version: "3"
tasks:
  example:
    cmd: mktemp -d

Metadata

Metadata

Assignees

No one assigned

    Labels

    dep: u-root/u-rootIssues related to the upstream core utils used by Task.

    Type

    No fields configured for bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions