mani icon indicating copy to clipboard operation
mani copied to clipboard

Unable to access env variables when running on Windows

Open stevenmldn opened this issue 3 years ago • 1 comments

  • [x] I have the latest version of mani
  • [x] I have searched through the existing issues

Info

  • OS

    • [ ] Linux
    • [ ] Mac OS X
    • [x] Windows
    • [ ] other
  • Shell

    • [ ] Bash
    • [ ] Zsh
    • [ ] Fish
    • [x] Powershell
    • [ ] other
  • Version: 0.21.0

Problem / Steps to reproduce

I am unable to access the environment variables defined at either the project or task level when running on Windows 10

projects:
  Repo-Manager:
    path: .

  Server:
    url: <Git URL>
    desc: The Server
    env:
      branch: test
    tags: [server]
   
tasks:
  test:
    desc: simple test task
    target:
      tags: [server]
    cmd:  echo $branch
  testInlineEnv:
    desc: simple test task
    env:
      branch: test
    target:
      tags: [server]
    cmd:  echo $branch

mani run test mani run testInlineEnv

stevenmldn avatar Jul 20 '22 11:07 stevenmldn

Thanks for the bug report, I will check it out.

alajmo avatar Jul 20 '22 13:07 alajmo

I tested it on windows 10 and it seems to work for me. Since you're using windows it will default to powershell, and powershell expects environment variables in a different format, see https://stackoverflow.com/questions/50861082/how-to-print-environment-variables-to-the-console-in-powershell.

In essence, switch to echo $env:branch and it should work. If you want to use bash (and have it installed), simply change the default shell:

projects:
  Repo-Manager:
    path: .

  Server:
    url: <Git URL>
    desc: The Server
    env:
      branch: test
    tags: [server]
  
# Default for all tasks
shell: bash

tasks:
  test:
    # Override for this task
    shell: bash
    desc: simple test task
    target:
      tags: [server]
    cmd:  echo $branch

  testInlineEnv:
    desc: simple test task
    env:
      branch: test
    target:
      tags: [server]
    cmd:  echo $branch

If there's any other issue, please re-open this issue.

alajmo avatar Sep 10 '22 16:09 alajmo