xargs on windows: No such file or directory

6,442

I use the Gnu on Windows port of the Unix tools and get a similar problem to this but the error message is always Invalid argument, e.g.

> printf "Hello World!" | xargs printf "%s %s"
xargs: printf: Invalid argument

One solution appears to be to use the "proverbial" extra level of indirection, for example a shell such as cmd.exe, to actually invoke the command:

> printf "Hello World!" | xargs cmd /c printf "%s %s"
Hello World!
Share:
6,442

Related videos on Youtube

gerrod
Author by

gerrod

Updated on September 18, 2022

Comments

  • gerrod
    gerrod over 1 year

    I wanted to resync the tags on my local git repository with the ones on our remote server, using this answer provided on StackOverflow:

    git tag -l | xargs git tag -d
    git fetch --tags
    

    I've got git for windows portable installed which includes xargs from FindUtils for Windows (as best I can tell).

    When I run the first part of the command, all I get is:

    xargs: git: No such file or directory

    If I modify the command to run:

    git tag -l | xargs echo
    

    It correctly "echos" the tags for me. So, my only conclusion is that xargs for some reason can't resolve executables from the path.

    How can I get xargs to properly execute what's passed to it (without resorting to passing the full path to git.exe?)

    • itslittlejohn
      itslittlejohn over 6 years
      Did you ever resolve this issue? I'm seeing the same thing
    • gerrod
      gerrod over 6 years
      Nope, never got to the bottom of it :-|
    • itslittlejohn
      itslittlejohn over 6 years
      Running the exact command in git bash worked fine, so I went with that. ¯_(ツ)_/¯