Skip to content

joinEnv - Just like joinPath but with ; for windows else : #2406

Description

@solvingj

Description

Title basically says it all. Once it's possible to prepend paths to the PATH via env (ideally fixed in #2034) , it should have a native cross-platform syntax for doing it cleanly on windows or posix platforms.

env:
    PATH: "{{joinEnv "{{.TASKFILE_DIR}}/tools/bin" .PATH}}"

or perhaps

env:
    BIN_DIR: "{{joinPath {{.TASKFILE_DIR}} "tools" "bin"}}"
    PATH: "{{joinEnv .BIN_DIR .PATH}}"

Additionally, or alternatively, add a special variable: PATHSEP for platform specific path separation in env vars.

env:
    PATH: "{{{{.TASKFILE_DIR}}/tools/bin{{.PATHSEP}}{{.PATH}}"

Activity

  1. added
    good first issueIssues that are good for first-time contributors to pick up.
    os: windowsIssues that affect users on Windows.
    area: templatingChanges related to the templating engine.
    and removed
    state: needs triageWaiting to be triaged by a maintainer.
    on Sep 2, 2025
  2. andreynering commented on Sep 2, 2025

    @andreynering
    Member

    This sounds like an easy one. Open for community pull requests.

  3. pd93 commented on Sep 2, 2025

    @pd93
    Member

    Happy with this too. A couple of implementation notes:

    • Separators
      • Windows uses ;
      • Linux/MacOS use :
    • I think there is no harm in a "join" function and a variable being added.
    • PATHSEP is highly ambiguous. Something like PATH_ENV_SEPARATOR
      • I prefer clarity over short names
      • _ as a word separator in var names
    • Same for joinEnv. This should be something like joinPathEnv
      • Same reasons for naming as the variable
      • Naming lines up with the variable
    • We don't actually have a FILEPATH_SEPARATOR
      • This could be added for parity
      • Add both to the templating reference docs under system variables.
  4. solvingj commented on Sep 3, 2025

    @solvingj
    ContributorAuthor

    Agh... there's a func in there defined as os() which breaks importing os.PathListSep. How you want me to deal with it? Rename os()/arch() to goos()/goarch() perhaps?

  5. added 2 commits that reference this issue on Sep 3, 2025
    7058b3c
    fb73da5
  6. tysoncung commented on Oct 9, 2025

    @tysoncung

    I'm interested in working on this issue. Could you provide more context about what you're looking for? Any additional details about requirements or constraints would be helpful.

  7. solvingj commented on Oct 9, 2025

    @solvingj
    ContributorAuthor

    I'm interested in working on this issue. Could you provide more context about what you're looking for? Any additional details about requirements or constraints would be helpful.

    Thanks but the work is done. The implementation details were essentially obvious and confirmed by @andreynering and @pd93 . It's just a matter of them finding time to review and merge.

  8. CaelFrost commented on Oct 30, 2025

    @CaelFrost

    " Perhaps this PR is more effort than value."

    From the last comment on the PR by the reviewer.
    Am I to understand the meaning of this is they don't agree that adding this functionality is worthwhile?

  9. solvingj commented on Nov 1, 2025

    @solvingj
    ContributorAuthor

    The two people who green lit it were maintainers, the person who made that comment was a contributor. I think maintainers haven't had time to review/approve/merge feature PRs in a few months. Main commit history just has chores and fixes and such.

  10. added a commit that references this issue on Feb 4, 2026
    2e28fde
  11. solvingj commented on Feb 10, 2026

    @solvingj
    ContributorAuthor

    Hitting this again. Having to do this in all our taskfiles to prepend path to a known project-relative directory:

            echo "Prepending tools dir to path..."
            {{if eq OS "windows"}} SEP=";" {{else}} SEP=":" {{end}}
            export PATH=$(pwd)/tools/bin$SEP$PATH
            ....
    

    Thanks to mvdan, the export and $(pwd) both work on windows. It's just the PATHSEP problem now.

  12. added a commit that references this issue on Apr 20, 2026
    98c6cc5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: templatingChanges related to the templating engine.good first issueIssues that are good for first-time contributors to pick up.os: windowsIssues that affect users on Windows.

    Fields

    No fields configured for feature.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址