Comments (8)
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.
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.
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.
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 tounset
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.
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.
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.
Thanks for taking the time to give these nice explanations !
from envman.
Any time ;)
from envman.
Related Issues (20)
- Command not finishing HOT 3
- Set `env_bytes_limit_in_kb` and `env_list_bytes_limit_in_kb` to `0` make other scripts fail HOT 3
- need info loglevel and/or --verbose switch
- How to increase the per-env-var limit of envman HOT 1
- Secret env variables HOT 3
- envman fails when git commit message is too long HOT 6
- Variables passed from envman not working correctly HOT 6
- environment list size (100.048828125 KB) - max allowed size: 100 KB HOT 2
- How to debug envman? HOT 5
- How to make env vars available to JVMs? HOT 9
- Import path should be "github.com/sirupsen/logrus", not "github.com/Sirupsen/logrus" HOT 4
- Loading environment variable set? HOT 5
- Run's help fails on first run HOT 1
- Does this tool work on Windows? HOT 2
- Issue with special characters HOT 1
- [Feature] Install script
- Env Vars set using envman are not available in current step HOT 5
- Can we please have linux arm64 binary as well ? HOT 1
- Proposal: Adding aliases type for env variables
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from envman.