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
300
votes
12 answers

Adding an .env file to a React project

I'm trying to hide my API Key for when I commit to GitHub, and I've looked through the forum for guidance, especially the following post: How do I hide an API key in Create React App? I made the changes and restarted Yarn. I'm not sure what I'm…
Biii
  • 3,041
  • 4
  • 9
  • 8
300
votes
17 answers

Test process.env with Jest

I have an application that depends on environmental variables like: const APP_PORT = process.env.APP_PORT || 8080; And I would like to test that for example: APP_PORT can be set by a Node.js environment variable. or that an Express.js application…
Tomasz Mularczyk
  • 34,501
  • 19
  • 112
  • 166
295
votes
18 answers

Why does sudo change the PATH?

This is the PATH variable without sudo: $ echo 'echo $PATH' | sh /opt/local/ruby/bin:/usr/bin:/bin This is the PATH variable with sudo: $ echo 'echo $PATH' | sudo sh /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin As…
Michiel de Mare
  • 41,982
  • 29
  • 103
  • 134
294
votes
6 answers

javac is not recognized as an internal or external command, operable program or batch file

I am experiencing an error while trying to compile Java programs. I am on Windows (this is a Windows-specific problem) and I have the latest JDK installed. I have attempted a solution involving the PATH variable, but the error persists. Console…
user987137
  • 2,957
  • 3
  • 14
  • 3
278
votes
6 answers

Why does an SSH remote command get fewer environment variables then when run manually?

I have a command that runs fine if I ssh to a machine and run it, but fails when I try to run it using a remote ssh command like : ssh user@IP Comparing the output of "env" using both methods resutls in different environments. When I…
Tom Feiner
  • 20,656
  • 20
  • 48
  • 51
276
votes
16 answers

How to set environment variables in Jenkins?

I would like to be able to do something like: AOEU=$(echo aoeu) and have Jenkins set AOEU=aoeu. The Environment Variables section in Jenkins doesn't do that. Instead, it sets AOEU='$(echo aoeu)'. How can I get Jenkins to evaluate a shell command…
Noel Yap
  • 18,822
  • 21
  • 92
  • 144
266
votes
6 answers

What is a good practice to check if an environmental variable exists or not?

I want to check my environment for the existence of a variable, say "FOO", in Python. For this purpose, I am using the os standard library. After reading the library's documentation, I have figured out 2 ways to achieve my goal: Method 1: if "FOO"…
251
votes
9 answers

How do I get and set Environment variables in C#?

How can I get Environnment variables and if something is missing, set the value?
Mister Dev
  • 10,021
  • 12
  • 41
  • 33
250
votes
11 answers

Command line to remove an environment variable from the OS level configuration

Windows has the setx command: Description: Creates or modifies environment variables in the user or system environment. So you can set a variable like this: setx FOOBAR 1 And you can clear the value like this: setx FOOBAR "" However, the…
anon
248
votes
3 answers

How to comment in laravel .env file?

I am working on a project in Laravel where I am storing some settings in .env file setting like few parameters for testing purpose and few parameters are for live working so I was just checking that is there any way to comment in .env file of…
Akshay Khale
  • 8,151
  • 8
  • 50
  • 58
242
votes
11 answers

Passing bash variable to jq

I have written a script to retrieve certain value from file.json. It works if I provide the value to jq select, but the variable doesn't seem to work (or I don't know how to use it). #!/bin/sh #this works *** projectID=$(cat file.json | jq -r…
asidd
  • 2,961
  • 2
  • 10
  • 9
240
votes
24 answers

Setting environment variable in react-native?

I am using react-native to build a cross-platform app, but I do not know how to set the environment variable so that I can have different constants for different environments. Example: development: BASE_URL: '', API_KEY: '', staging: …
Damon Yuan
  • 3,683
  • 4
  • 23
  • 31
236
votes
15 answers

Environment variable is too large on Windows 10

I have recently upgraded to Windows 10 from Windows 8.1. Now I wanted to set an environment variable for my new installation of Apache Maven. Each time I created the user variable, things were fine. However, I also need to create the system variable…
olasammy
  • 6,676
  • 4
  • 26
  • 32
231
votes
13 answers

Setting PATH environment variable in OSX permanently

I have read several answers on how to set environment variables on OSX permanently. First, I tried this, How to permanently set $PATH on Linux/Unix but I had an error message saying no such file and directory, so I thought I could try …
patti_jane
  • 3,293
  • 5
  • 21
  • 26
225
votes
7 answers

Setting a system environment variable from a Windows batch file?

Is it possible to set a environment variable at the system level from a command prompt in Windows 7 (or even XP for that matter). I am running from an elevated command prompt. When I use the set command (set name=value), the environment variable…
Santhosh
  • 6,547
  • 15
  • 56
  • 63