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

Command can not be run in Windows #319

Closed
tredoe opened this issue May 4, 2020 · 8 comments
Closed

Command can not be run in Windows #319

tredoe opened this issue May 4, 2020 · 8 comments
Labels
state: duplicate Duplicates another issue.

Comments

@tredoe
Copy link

tredoe commented May 4, 2020

  • Task version: master
  • OS: windows 10

A command like - cmd: rm -r -fo "$home/foo/" cann't be run because task finds the command in $PATH

"rm": executable file not found in $PATH

But in Windows, they are in commands which are not in $PATH but they can be run from the shell.

The solution would be do not find the command in Windows systems.

@chris-garrett
Copy link
Contributor

Can you add a little bit more detail? When you say rm can be run from the shell what shell do you mean? msys? cygwin? wsl?

@tredoe
Copy link
Author

tredoe commented May 9, 2020

I mean Windows Power Shell

@tredoe
Copy link
Author

tredoe commented May 9, 2020

So, at Windows other solution would be to check if the command is an alias like del, erase, rd, rmdir, rm, ri; it if is not, then could be checked if it exist in $PATH.

@chris-garrett
Copy link
Contributor

This was a good ticket for me to dive into the code a little bit. I don't use powershell so I learned something today.

I wanted to reproduce what you are talking about:

chris@JUPITER C:\Users\chris\Desktop\projects\gojira\internals\task
$ ls
'ls' is not recognized as an internal or external command,
operable program or batch file.

chris@JUPITER C:\Users\chris\Desktop\projects\gojira\internals\task
$ task ls
"ls": executable file not found in $PATH
task: Failed to run task "ls": exit status 127

chris@JUPITER C:\Users\chris\Desktop\projects\gojira\internals\task
$ powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\chris\Desktop\projects\gojira\internals\task> ls

    Directory: C:\Users\chris\Desktop\projects\gojira\internals\task

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         5/9/2020  12:07 AM          11595 CHANGELOG.md
-a----         5/9/2020  12:07 AM           1101 LICENSE
-a----         5/9/2020  12:07 AM            731 README.md
-a----         5/9/2020  12:07 AM        5484032 task.exe
-a----         5/9/2020  12:07 AM        5738496 task.lin
-a----         5/9/2020  12:07 AM        6106672 task.mac
-a----         5/9/2020  11:32 AM            104 Taskfile.yml

PS C:\Users\chris\Desktop\projects\gojira\internals\task> .\task.exe ls
"ls": executable file not found in $PATH
task: Failed to run task "ls": exit status 127

I used this Taskfile.yml

version: '3'
silent: true
tasks:
  ls:
    desc: "testing ls"
    cmds:
      - ls -la

Digging into the code I can see that task uses mvdan/sh to execute cmd:.

According to this issue the author doesn't want to add support for this.

So that leaves you with a few alternative options:

  1. Use a different shell like msys, cygwin or maybe wsl
  2. Put *nix tools on your path. This is what I do personally since I haven't switched to wsl yet. When installing git I select the option to have the tools on the path overriding find etc. This makes windows a lot more usable for me. YMMV.

HTH

@andreynering
Copy link
Member

Hi @tredoe,

I'm closing this as a duplicate of #197.

We use mvdan/sh as the shell library and unfortunately it doesn't yet support some core builtins like rm, cp, ls, etc

@andreynering andreynering added the state: duplicate Duplicates another issue. label May 9, 2020
@sheldonhull
Copy link
Contributor

@andreynering this really snagged me quite a few times. Is there any solid reference on what isn't supported or maybe what core builtins are supported?

The main reason I switched to go-task over Make was cross platform functionality, but I've run into basic mkdir type commands that run fine in a powershell prompt not working. This would mean every single basic folder/directory creation would require me to wrap in OS specific handling which I really wanted to avoid.

This would be really useful to point to in the docs so folks know the OS specific limitations. Not sure if there is any reference yet that I missed.

@andreynering
Copy link
Member

@sheldonhull Please keep the discussion on #197 as this is a duplicated issue.

Also, keep in mind there's an upstream issue on mvdan/sh#93.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: duplicate Duplicates another issue.
Projects
None yet
Development

No branches or pull requests

4 participants