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

USER_WORKING_DIR is concatenating "C:/" to the path in Windows #1205

Closed
stevensgarcia opened this issue Jun 4, 2023 · 1 comment · Fixed by #1309
Closed

USER_WORKING_DIR is concatenating "C:/" to the path in Windows #1205

stevensgarcia opened this issue Jun 4, 2023 · 1 comment · Fixed by #1309
Labels
area: variables Changes related to variables. os: windows Issues that affect users on Windows. type: bug Something not working as intended.

Comments

@stevensgarcia
Copy link

Hi,

I'm using a main Taskfile which includes a vagrant_taskfile.yml.

# Windows
# C:\Users\Usuario\taskfiles\Taskfile.yml
version: '3'

includes:
  vagrant: 
    taskfile: ./vagrant_taskfile.yml

I've experienced this concatenating issue with {{.USER_WORKKING_DIR}} before in Linux and solved it using this config:

# Linux
# /home/user/taskfiles/vagrant_taskfile.yml
ssh:
    dir: "../../../{{.USER_WORKING_DIR}}"
    cmds:
      - vagrant ssh

This works perfectly OK in Linux. However in Windows 10 Pro Powershell it fails:

# Windows - PowerShell
# Execution context: C:\Users\Usuario\Documents\Vagrant_Projects\demo

task: [main:vagrant:ssh] vagrant ssh
task: Failed to run task "main:vagrant:ssh": could not stat: CreateFile C:\C:\Users\Usuario\Documents\Vagrant_Projects\demo: The filename, directory name, or volume label syntax is incorrect.

⚠️ Please note the concatenated C:\ at the beginning of the execution path. This is the problem. ⚠️

No matter how I play with the hierarchy path ../../, those parent dirs will be removed, but that C:\ will remain attached to the path, so the command wont work. Not to mention that if I only use {{.USER_WORKING_DIR}} it will concatenate the main and current context paths together ending with the old problem.

# Windows
# C:\Users\Usuario\taskfiles\vagrant_taskfile.yml
ssh:
    dir: "../../../{{.USER_WORKING_DIR}}"
    cmds:
      - vagrant ssh
# Windows - PowerShell
# Execution context: C:\Users\Usuario\Documents\Vagrant_Projects\demo

task: [main:vagrant:ssh] vagrant ssh
task: Failed to run task "main:vagrant:ssh": could not stat: CreateFile C:\Users\Usuario\taskfiles\C:\Users\Usuario\Documents\Vagrant_Projects\demo: The filename, directory name, or volume label syntax is incorrect.

Here you can see both paths got concatenated. As mentioned in the beginning, this can be solved usign dir: "../../../{{.USER_WORKING_DIR}}" in Linux.

Any suggestions to fix this in Windows?

PS: All other commands that don't require .USER_WORKING_DIR work like a charm in windows so far.

Thank you very much.

  • Task version: v3.19.1 (h1:2KMJk6mDBacSPuFxPFvlvvHJwGZtU/hN2ENZpaFqR5s=)
  • Operating system: Windows 10 Pro, Powershell
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Jun 4, 2023
@andreynering andreynering added type: bug Something not working as intended. os: windows Issues that affect users on Windows. and removed state: needs triage Waiting to be triaged by a maintainer. labels Jun 17, 2023
@andreynering
Copy link
Member

This is a curious bug, indeed. The problem may be on mvdan/sh or somewhere on our code.

andreynering added a commit that referenced this issue Aug 18, 2023
andreynering added a commit that referenced this issue Aug 18, 2023
Closes #1046
Closes #1205
Closes #1250
Closes #1293
Closes #1274
Closes #1309

Co-authored-by: Marcus Spading <ms@fragmentum.net>
@andreynering andreynering added the area: variables Changes related to variables. label Aug 18, 2023
andreynering added a commit that referenced this issue Aug 26, 2023
Closes #1046
Closes #1205
Closes #1250
Closes #1293
Closes #1274
Closes #1309
Closes #1312

Co-authored-by: Marcus Spading <ms@fragmentum.net>
andreynering added a commit that referenced this issue Aug 26, 2023
Closes #1046
Closes #1205
Closes #1250
Closes #1293
Closes #1274
Closes #1309
Closes #1312

Co-authored-by: Marcus Spading <ms@fragmentum.net>
andreynering added a commit that referenced this issue Aug 26, 2023
Closes #1046
Closes #1205
Closes #1250
Closes #1293
Closes #1274
Closes #1309
Closes #1312

Co-authored-by: Marcus Spading <ms@fragmentum.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: variables Changes related to variables. os: windows Issues that affect users on Windows. type: bug Something not working as intended.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants