task icon indicating copy to clipboard operation
task copied to clipboard

expanding of home dir (~) is not working

Open i4o opened this issue 9 years ago • 7 comments

Simple task like hugo should generate site. It clearly takes bit longer in my case and 2nd following task cannot sync, as directory ~/myblog/site is not yet created. Is there a way for 2nd task to wait for 1st task to finish?

But maybe there is issue with longer running tasks, as alone task gen doesn't seen to work properly, it never finishes.

Taskfile.yml

gen:
desc: hugo generate site
dir: ~/myblog
cmds:
- hugo

upload:
desc: rsync to server
cmds:
- rsync -avz --delete ~/myblog/site/* blog.xxx.net:/srv/blog.xxx.net/

default: cmds: - task: gen - task: upload

i tried this first, didn't work either

default: deps: [gen, upload]

i4o avatar Oct 15 '17 17:10 i4o

Your first example is correct, the second task should wait for the first one to complete.

Hard to say with the given information why the second didn't run. Maybe the first error or hang?

I'm closing this since questions are supposed to be asked in the chat room.

andreynering avatar Oct 15 '17 17:10 andreynering

In my original description I stated first task run, it just takes time for 1st task to finish. 2nd task never waited long enough. I assume you are running go routines with short timeout? I was trying to migrate from fabric to task, no issues to run the same command via fabric task. Slightly confusing is also that task won't let you know about stdout of subtasks, so I don't know, what's going on.

i4o avatar Oct 15 '17 18:10 i4o

@i4o Can you please give more information?

  • OS
  • Task version
  • Output while running default

Just to make it clear: the below will run serially:

default:
  cmds:
    - task: gen
    - task: upload

The below concurrently, so it's not what you want in this case:

default:
  deps: [gen, upload]

I assume you are running go routines with short timeout?

There's no timeout for running commands. It returns when the command finishes or error.

I was trying to migrate from fabric to task, no issues to run the same command via fabric task.

I don't know what Fabric is. Can you link it and (if relevant) paste configuration?

Slightly confusing is also that task won't let you know about stdout of subtasks, so I don't know, what's going on.

Stdout and stderr of commands are redirected while running it. Did you try to run these commands directly on console?

andreynering avatar Oct 15 '17 19:10 andreynering

I guess I found out how to make it run. My shell is fish[1]. When I switched to bash and run task I did get expected output. Sorry, it didn't occur to me it's shell agnostic. Reading your help even suggested task is using github.com/mvdan/sh. Maybe it's bug in mvdan/sh.

[1] ... https://fishshell.com/

Regarding version, I did go get on Friday. I would expect it to be reasonably current, unless your pace is hectic :).

$task  --version                                                                                    
Task version: master

I'm running Ubuntu 16.04.3 LTS

$ uname -a
Linux ico-ThinkPad-X230 4.4.0-96-generic #119-Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Did you try to run these commands directly on console?

Ofcourse I did. hugo command just takes a while to respond. There is no output initially for maybe 2-3 secs. Next run is about 400 ms, it's probably building some kind of cache. fabric[2] is task runner in python. Not really relevant, but it's doing the same, running task one after another.
[2] ... http://www.fabfile.org/

What's important, when i1st task finishes it creates site directory, where are generated html files.

Error I was seeing is non-existent site directory, while running 2nd task. It appears not to be waiting long enough.

But now I'm trying to run single task gen, I don't get that site dir. It won't finish. Actually it returns immediatelly, it puts out hugo and that's it.

[hugo] ... gohugo.io ( static site generator in golang )

i4o avatar Oct 15 '17 19:10 i4o

@i4o Did you find to solve the issue?

I think there's a chance that the dir (~/myblog) is causing the issue. Can you try moving the Taskfile to the myblog directory, commenting dir: ~myblog and running it?

andreynering avatar Oct 16 '17 10:10 andreynering

I think there's a chance that the dir (~/myblog) is causing the issue

You are correct.

I was running task from ~/myblog directory anyway, but was planning to move Taskfile.yml elsewhere, so I put there dir. When I removed dir directive it was running as expected.

I tried then to move Taskfile.yml elsewhere, just to change ~ for full path in dir: /home/user/myblog and it still worked. Clearly I have to be carefull with dir.

Thank you for your help.

i4o avatar Oct 16 '17 19:10 i4o

Expanding of home dir has being fixed at master: https://github.com/go-task/task/commit/baac067a1a0aa0d387b60a19977c901a3863fe97

andreynering avatar Nov 02 '17 12:11 andreynering