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

[3.39.0] Environment variable seen as command #1812

Closed
Firesphere opened this issue Sep 17, 2024 · 3 comments
Closed

[3.39.0] Environment variable seen as command #1812

Firesphere opened this issue Sep 17, 2024 · 3 comments

Comments

@Firesphere
Copy link

  • Task version:
    3.39.0

  • Operating system:
    MacOS Sonoma 14.6.1

  • Experiments enabled:
    TASK_X_MAP_VARIABLES=1

Having the following .env.local file:

PROJECTS='~/Projects/test-projects/'

And the following task:

tasks:
  project:binaries:watch:*: # This task is in the root because of watcher issues outside of the root Taskfile
    aliases: [s:b:w:*]
    vars:
      DAEMON: '{{index .MATCH 0}}'
      CALLTASK: 'demo:supervisor:reload:{{.DAEMON}}'
    env:
      BASEFOLDER: ${PROJECTS}
    sources: 
      - '{{.BASEFOLDER}}/build/**/*'
      - '{{.BASEFOLDER}}/src/**/*'
    watch: true
    cmds:
      - task: '{{.CALLTASK}}'

And the call copies the build binary to the docker container, and runs a supervisor reload

On 3.38.x, this was working fine.

On 3.39.0, I get the following error:

"{PROJECTS}": executable file not found in $PATH
task: Command "{PROJECTS}" failed: exit status 127

Same when using vars instead of env, or trying to do echo ${PROJECTS} as a command. Each option tells me the command {PROJECTS}

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Sep 17, 2024
@Firesphere Firesphere changed the title Environment variable seen as command [3.39.0] Environment variable seen as command Sep 17, 2024
@vmaerten
Copy link
Member

Hi !
Can you try to provide a minimal reproduction example ?

I am on linux (and Zsh) and it seems to work fine :

❯ TASK_X_MAP_VARIABELS=1 taskd -d ../reproductions/github/1812 project:binaries:watch:test                                                          
task: Started watching for tasks: project:binaries:watch:test
task: Task "demo:supervisor:reload:test" does not exist
task: Failed to run task "project:binaries:watch:*": task: Task "demo:supervisor:reload:test" does not exist

@vmaerten vmaerten added state: awaiting response Waiting for issue author to respond. state: can't repro Not enough information was given to reproduce the issue described. and removed state: needs triage Waiting to be triaged by a maintainer. labels Sep 18, 2024
@Firesphere
Copy link
Author

Archive.zip
Here you go, I am pretty sure this should cover the entire scenario :)

When running task prj:bin:w:test (I've shortened the task naming, for easier typing :D ), I get

$: TASK_X_MAP_VARIABLES=1 task prj:bin:w:test             
task: Started watching for tasks: prj:bin:w:test
"{PROJECTS}": executable file not found in $PATH
task: Command "{PROJECTS}" failed: exit status 127

I just upgraded to MacOS 15.0.0, but it still occurs.

@task-bot task-bot removed the state: awaiting response Waiting for issue author to respond. label Sep 19, 2024
@vmaerten vmaerten removed the state: can't repro Not enough information was given to reproduce the issue described. label Sep 21, 2024
@vmaerten
Copy link
Member

With TASK_X_MAP_VARIABLES=1, the $ is used to declare dynamic variable (cf : https://taskfile.dev/experiments/map-variables/#dynamic-variables)
So, with map variable experiment proposal 1 it's the expected behavior.

Please note that this is an experiment and it may change in the future.

I am not sure with you need env but according to your example, this should work :

tasks:
  project:binaries:watch:*: # This task is in the root because of watcher issues outside of the root Taskfile
    aliases: [s:b:w:*]
    vars:
      DAEMON: '{{index .MATCH 0}}'
      CALLTASK: 'demo:supervisor:reload:{{.DAEMON}}'
      BASEFOLDER:  '{{.PROJECTS}}'
    sources: 
      - '{{.BASEFOLDER}}/build/**/*'
      - '{{.BASEFOLDER}}/src/**/*'
    watch: true
    cmds:
      - task: '{{.CALLTASK}}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants