How can you use a Chef recipe to set an environment variable?

If you need an env var set strictly within the Chef process, you can use ENV[‘foo’] = ‘bar‘ since it’s a ruby process. If you need to set one for an execute provider, Chef exposes an environment hash: execute ‘Bootstrap the database’ do cwd “#{app_dir}/current” command “#{env_cmd} rake db:drop db:create db:schema:load RAILS_ENV=#{rails_env}” environment ‘HOME’ => … Read more

How do I modify the PATH environment variable when running an Inno Setup Installer?

The path in the registry key you gave is a value of type REG_EXPAND_SZ. As the Inno Setup documentation for the [Registry] section states there is a way to append elements to those: On a string, expandsz, or multisz type value, you may use a special constant called {olddata} in this parameter. {olddata} is replaced … Read more

Temporarily modify the current process’s environment

I suggest you the following implementation: import contextlib import os @contextlib.contextmanager def set_env(**environ): “”” Temporarily set the process environment variables. >>> with set_env(PLUGINS_DIR=u’test/plugins’): … “PLUGINS_DIR” in os.environ True >>> “PLUGINS_DIR” in os.environ False :type environ: dict[str, unicode] :param environ: Environment variables to set “”” old_environ = dict(os.environ) os.environ.update(environ) try: yield finally: os.environ.clear() os.environ.update(old_environ) EDIT: more … Read more

Supervisor and Environment Variables

Referencing existing env vars is done with %(ENV_VARNAME)s See: https://github.com/Supervisor/supervisor/blob/master/supervisor/skel/sample.conf Setting multiple environment variables is done by separating them with commas See: http://supervisord.org/subprocess.html#subprocess-environment Try: environment=PYTHONPATH=/opt/mypypath:%(ENV_PYTHONPATH)s,PATH=/opt/mypath:%(ENV_PATH)s

Environment variable not recognized [not available] for [Run] programs in Inno Setup

The processes created for executing entries from the [Run] section inherits the environment block of its parent process, which is the installer itself. So you have to set the environment variable to the installer and let it inherit to your executed application. How to do that is shown in the below script: [Run] Filename: “{app}\temp\installation_files\license.exe”; … Read more

Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan/macOS Sierra/Mojave?

Create an environment.plist file in ~/Library/LaunchAgents/ with this content: <?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”> <plist version=”1.0″> <dict> <key>Label</key> <string>my.startup</string> <key>ProgramArguments</key> <array> <string>sh</string> <string>-c</string> <string> launchctl setenv PRODUCTS_PATH /Users/mortimer/Projects/my_products launchctl setenv ANDROID_NDK_HOME /Applications/android-ndk launchctl setenv PATH $PATH:/Applications/gradle/bin </string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> You can add many launchctl commands inside the … Read more