Giter VIP home page Giter VIP logo

Comments (8)

viktorbenei avatar viktorbenei commented on June 3, 2024

envman stores the env vars, it does not export them automatically after an add

try:

envman add --key foo --value "bar"
envman run bash -c 'echo $foo'

if you'd have any questions just let us know! ;)

from envman.

gaultierq avatar gaultierq commented on June 3, 2024

yep, but I was wondering why not exporting it after storing it ?
from the doc :

This is the same as you would manually set all the environments, one by one with export KEY=value (in bash) before calling the command.

from envman.

viktorbenei avatar viktorbenei commented on June 3, 2024

yeah, it might be a bit too bloated, but it's connected to the previous paragraph in the readme, namely:

... and when you call envman run the next time the environments in the .envstore file will be loaded for the command ...
This is the same as you would manually set all the environments, one by one with export KEY=value (in bash) before calling the command.

So something like

# set env
export KEY=value
# run command
command

roughly the same as

# set env
envman add --key KEY --value "value"
# run command
envman run command

Feel free to send a PR for the readme if you have an idea to make this more straightforward! :)

from envman.

viktorbenei avatar viktorbenei commented on June 3, 2024

for:

but I was wondering why not exporting it after storing it ?

answer is the next paragraph:

envman makes it easy to switch between environment sets and to isolate these environment sets from each other - you don't have to unset environments, the specified environment set will only be available for that single run of envman / the command and won't affect subsequent calls of the command or envman.

basically you can have a dir structure like:

.
├── env1
│   └── .envstore.yml
└── env2
    └── .envstore.yml

and if you cd into env1 and envman add an env there, and run an envman run there then only the envs added in that dir will be available for the envman run command. If you switch to env2 dir and envman run there that will have a completely separate, "isolated" set of env vars.

P.S.: it's also possible to just have separate envstore files in the same directory, and switching between the env sets by defining which one to load:

# init two separate env sets
envman --path=./env1.yml init
envman --path=./env2.yml init

# add env to env1
envman --path=./env1.yml add --key KEY1 --value val1
# add env to env2
envman --path=./env2.yml add --key KEY2 --value val2

# run command with env1 env set
envman --path=./env1.yml run COMMAND

from envman.

gaultierq avatar gaultierq commented on June 3, 2024

understood ! this is very clear !
A possible enhancement would be to add a option to let then added env be available in the current process. It would change the cumbersome:

    BUILD_VERSION=${BUILD_VERSION:-$(resolveNextVersion "branch=$BUILD_BRANCH")}
    envman add --key BUILD_VERSION --value $BUILD_VERSION

into

    envman add --key BUILD_VERSION --value ${BUILD_VERSION:-$(resolveNextVersion "branch=$BUILD_BRANCH")}

from envman.

viktorbenei avatar viktorbenei commented on June 3, 2024

unfortunately that's harder than you'd expect, simply because of how env vars work in shells

there's no simple way of exposing env vars in a cross shell compatible way, and env vars exposed by a (sub)process are NOT available in the parent process - the shell itself is a process too! It's pretty much the same as if you'd start a new bash session from another, set an env var then exit - the env var will no longer be available:

# open clean terminal/command line - most likely it'll be a bash shell session
# now start a new session as child (bash login session):
bash -l
# set env var with export
export KEY=value
# test it - it works here
echo $KEY

# now exit the inner bash shell
exit
# you're back to the outer/parent one; try to print the same env
echo $KEY
# no longer available

from envman.

gaultierq avatar gaultierq commented on June 3, 2024

Thanks for taking the time to give these nice explanations !

from envman.

viktorbenei avatar viktorbenei commented on June 3, 2024

Any time ;)

from envman.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.