Questions tagged [environment-variables]

Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.

Environment variables are a set of dynamic-named values that can affect the way running processes will behave on a computer. They can be said in some sense to create the operating environment in which a process runs. For example, an environment variable with a standard name can store the location that a particular computer system uses to store temporary files—this may vary from one computer system to another. A process which invokes the environment variable by (standard) name can be sure that it is storing temporary information in a directory that exists and is expected to have sufficient space.

https://en.wikipedia.org/wiki/Environment_variable

13704 questions
195
votes
4 answers

ARG or ENV, which one to use in this case?

This could be maybe a trivial question but reading docs for ARG and ENV doesn't put things clear to me. I am building a PHP-FPM container and I want to give the ability for enable/disable some extensions on user needs. Would be great if this could…
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
193
votes
4 answers

In Gradle, is there a better way to get Environment Variables?

In several Tasks, I reference jars in my home folder. Is there a better way to get Environment Variables than ENV = System.getenv() HOME = ENV['HOME'] task copyToServer(dependsOn: 'jar', type: Copy) { from 'build/libs/' into HOME +…
192
votes
10 answers

Display all environment variables from a running PowerShell script

I need to display all configured environment variables in a PowerShell script at runtime. Normally when displaying environment variables I can just use one of the following at the shell (among other techniques, but these are simple): gci env:* ls…
codewario
  • 19,553
  • 20
  • 90
  • 159
192
votes
9 answers

Is it secure to store passwords as environment variables (rather than as plain text) in config files?

I work on a few apps in rails, django (and a little bit of php), and one of the things that I started doing in some of them is storing database and other passwords as environment variables rather than plain text in certain config files (or in…
jay
  • 12,066
  • 16
  • 64
  • 103
191
votes
3 answers

How can I set an environment variable only for the duration of the script?

On Linux (Ubuntu 11.04 (Natty Narwhal)) in Bash, is it possible to temporarily set an environment variable that will only be different from the normal variable for the duration of the script? For example, in a shell script, making an application…
suchipi
  • 1,911
  • 2
  • 12
  • 3
184
votes
4 answers

Reading and writing environment variables in Python?

My python script which calls many python functions and shell scripts. I want to set a environment variable in Python (main calling function) and all the daughter processes including the shell scripts to see the environmental variable set. I need to…
user749632
  • 1,989
  • 2
  • 12
  • 5
182
votes
20 answers

Gradle finds wrong JAVA_HOME even though it's correctly set

When trying to run gradle, I get the following error: # gradle ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/default-java Please set the JAVA_HOME variable in your environment to match the location of your Java…
James Barnett
  • 5,039
  • 3
  • 15
  • 18
177
votes
5 answers

How to get the PATH environment-variable separator in Python?

When multiple directories need to be concatenated, as in an executable search path, there is an os-dependent separator character. For Windows it's ';', for Linux it's ':'. Is there a way in Python to get which character to split on? In the…
Mark Ransom
  • 299,747
  • 42
  • 398
  • 622
175
votes
8 answers

Allowed characters in Linux environment variable names

What characters are allowed in Linux environment variable names? My cursory search of man pages and the web did only produce information about how to work with variables, but not which names are allowed. I have a Java program that requires an…
Christian Semrau
  • 8,913
  • 2
  • 32
  • 39
173
votes
7 answers

How to read environment variables in Scala

In Java, reading environment variables is done with System.getenv(). Is there a way to do this in Scala?
summerbulb
  • 5,709
  • 8
  • 37
  • 83
169
votes
5 answers

Set a persistent environment variable from cmd.exe

I have to set environment variables on different windows machines, but I don't want to be bothered changing them manually by getting on the properties screen of "My Computer" I want to do it from the command line, with a batch file. As far as I…
0x26res
  • 11,925
  • 11
  • 54
  • 108
163
votes
12 answers

How to set environment variables in PyCharm?

I have started to work on a Django project, and I would like to set some environment variables without setting them manually or having a bash file to source. I want to set the following variables: export…
lmiguelvargasf
  • 63,191
  • 45
  • 217
  • 228
162
votes
8 answers

Modifying PATH with fish shell

I'm currently playing around with the fish shell and I'm having some trouble wrapping my head around how the PATH variable is set. For what it's worth, I'm also using oh-my-fish. If I echo my current path I get: ➜ fish echo $PATH /usr/local/bin…
Paymahn Moghadasian
  • 9,301
  • 13
  • 56
  • 94
158
votes
5 answers

What is the use of python-dotenv?

Need an example and please explain me the purpose of python-dotenv. I am kind of confused with the documentation.
Dev Jalla
  • 1,910
  • 2
  • 13
  • 21
158
votes
6 answers

In Python script, how do I set PYTHONPATH?

I know how to set it in my /etc/profile and in my environment variables. But what if I want to set it during a script? Is it import os, sys? How do I do it?
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080