Unable to access env variables when running on Windows
- [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
Thanks for the bug report, I will check it out.
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.