Questions tagged [environment-variables]

Environment variables are used to create shared settings that persist between invocations of applications. They are used to provide information such as paths to important directories, user information and other information programs need for common tasks.

Filter by
Sorted by
Tagged with
1
vote
0answers
41 views

Launchctl setenv in Terminal.app vs iTerm

If I use launchctl setenv FOO BAR in Terminal.app, after closing and reopening the app, the variable FOO is correctly set. If I do the same thing in iTerm, nothing happens. Why?
0
votes
0answers
37 views

Setting global variables with macOS Catalina

I use the environment.plist method to setup global variables in macOS. I have this template in ~/Library/LaunchAgents <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ...
0
votes
1answer
67 views

Run script at sunrise time

I'm trying to set my hackintosh pc to turn on at every sunrise and to run iTunes as the macOS boots up using bash or AppleScript without 3rd-party apps. I reached the point in my script when I need ...
4
votes
2answers
49 views

Ran export TMPDIR=~/tmp/ and it broke my node app, can I revert the tmp folder to the default folder?

Hey I ran export TMPDIR=~/tmp/ and it changed my temp folder. I was trying to get a Go backend working and an article suggested it. I was a little trigger happy and now this is causing issues with a ...
0
votes
0answers
25 views

Why do my environment variables keep getting wiped out in Mac OS Catalina?

I am currently using MacOS Catalina, and every time my computer boots up from having shut down the environment variables get wiped out. I literally have to manually run export FOO=bar each time my ...
1
vote
0answers
107 views

How to set an environment variable working on both bash and GUI?

Considering the current version of macOS being Catalina, I am looking for a way to set permanently an environment variable for both: bash and GUI applications. I have searched online for a while, but ...
0
votes
2answers
354 views

Setting GUI Visible Environment Variables with OS Catalina

I need to set a number of Environment variables that can be seen by GUI apps (i.e. Xcode). When running from a terminal this is trivial and is simply a case of adding a. number of export commands to ...
2
votes
1answer
518 views

ZSH: .zprofile, .zshrc, .zlogin - What goes where?

Now that I've upgraded to Catalina and I am using the new ZSH shell, I've noticed that ~/.bash_profile has been replaced with ~/.zprofile and since installing iTerm2 shell integration, it added a ~/....
0
votes
0answers
17 views

How do I set a system wide environment variable on macOS?

I have a Java web application that runs on Tomcat, and the web application attempts to read a configuration filename from a system environment variable (ex. MYAPP_CONFIG_FILE). How do I set such a ...
0
votes
2answers
34 views

How do I use ls command with a variable for a directory in zsh?

I set a variable named $G2_HW_sci. This is the output with echo. user@192 SS % echo $G2_HW_sci ~/Documents/trabalho/SS/G2/science/homework/student_work/ Then I tried to ...
0
votes
0answers
29 views

Where does zsh get the values of LANG & LC_CTYPE if it is not in .zshrc?

Where does zsh get the values of LANG & LC_CTYPE if it is not in .zshrc ? I check my ~/.zshrc and it didn't set them, but if I run printenv I find they were both set, although not the values I ...
1
vote
1answer
29 views

environment variable edit error

I have been trying to edit my environment variables. I referred to the sites but its not working. I should mention that I am very new to Mac and I'm using it because my workplace has it. When I enter ...
1
vote
1answer
387 views

Using Node.js without admin rights - sh: node: command not found

I've been following this guide (https://theshravan.net/blog/how-to-use-node-and-npm-without-installation-or-admin-rights/) to try to use Node.js on my work computer. The guide is for windows but most ...
0
votes
2answers
248 views

How to use Node.js without admin rights on a mac?

I'm trying to use Node.js on my work computer but I don't have admin rights. I'm wondering how I can install Node.js on mac without having admin rights. I found a tutorial, which is for Windows but ...
0
votes
2answers
181 views

Who sets the BROWSER environment variable in macOS?

I noticed I have BROWSER set to open in my environment variables, but I can't figure out where it gets set by the system. When I run env I get this output: USER=xxx PATH=xxx LOGNAME=xxx ...
0
votes
1answer
457 views

environment variable not showing after set

I am trying to set permanent environmental variable in my mac machine I have tried following steps till now - vi ~/.bash_profile adding my variable export JAVA_HOME=/Library/Java/...
5
votes
1answer
67 views

Bash: Elegant ways to use multiple variables for shortening long strings?

I am aware of dockutil in homebrew but, I am trying to run a bash script that automatically adds dock icons to the dock on a fresh user account. dockutil has been uncooperative on fresh out of the box ...
2
votes
2answers
120 views

Escape space character in pathfile?

I'm trying to set an environment variable for Anki's media folder, in .bash_profile. The line is export ANKI_MEDIA='/Users/<username>/Library/Application Support/Anki2/me/collection.media'. ...
2
votes
1answer
162 views

Where can I see modifications made to the PATH environment variable by the Go installer

I've identified several changes to the PATH variable in Bash that aren't listed in e.g. /etc/profile, ~/.profile, .bash_profile, ~/.bashrc. The following snippet from the Go installation page ...
0
votes
0answers
51 views

Build without requiring users to set LD_LIBRARY_PATH?

I'm following this guide on how to build NumPy with Intel MKL on a macOS (I'm on Mojave 10.14.5), and after installing Intel's MKL library, the guide tells me to set LD_LIBRARY_PATH: export ...
1
vote
2answers
131 views

sub Applescript with Global / property

I'll like to run a second applescript with variable from the first Applescript. If I do a first script to property myName : "Kevin" And a second script with : set remoteScript to (load script "/...
0
votes
0answers
28 views

dyld monitors DYLD_ variables behind the scenes [duplicate]

If I invoke DYLD_X=foo /bin/bash -c 'echo "<$DYLD_X>"' the output is <> while MY_VAR=bar /bin/bash -c 'echo "<$MY_VAR>"' outputs <bar> Switching to Bash 5: DYLD_X=foo /...
5
votes
1answer
239 views

How do I use my GPG agent for SSH everywhere?

On my system, I'm trying to set up SSH authentication through my GPG agent (installed via brew). So far, I have this working in my terminal thanks to adding the following lines to ~/.profile: # ...
18
votes
4answers
32k views

How to add permanent environment variable in zsh

I have been scouring the internet, and cannot seem to find a solution to permanently adding an environment variable, specifically when my OS is macOS Mojave (10.14). It seems there are a lot of ...
1
vote
1answer
52 views

change default editor for command line tasks?

I want to create a cron job. Launching a terminal window, and entering crontab -e opens my current crontab, but opens it in the editor vi. I would prefer to use the nano editor. How do I configure ...
4
votes
1answer
11k views

Mojave (10.14) setting environment variables

There are other questions and topics just like this but I can not find anything that is specific to 10.14 Mojave. I have tried the ~/Library/LaunchAgents/environment.plist method and I have tried to ...
3
votes
1answer
1k views

Create and set environment variable in MacOSX

I want to set some environment variables in my Mac. I was hoping to do that by creating a small bash script file inside paths.d and then restart my machine. Is this the correct way to add ...
3
votes
1answer
458 views

Open Terminal Window with Predefined Environment Variables (Including `PATH`)

I'm trying to create a .command file which will open a terminal window with predefined Environment Variables (Including PATH). I tried this: #!/bin/bash # Adding CMake to Path export PATH=$PATH:/...
2
votes
3answers
821 views

How exactly is PATH calculated?

I've read a dozen different answers and talked to a bunch of people and am having difficulty understanding how PATH is calculated in different scenarios. Specifically I'm thinking of How exactly is ...
0
votes
1answer
260 views

Removing directories from PATH

I am trying to run rkhunter, but it is giving me this output: stack/security/rkhunter-1.4.6 ➜ sudo rkhunter --check Password: Invalid BINDIR configuration option: Invalid directory found: ~/.dotnet/...
4
votes
1answer
3k views

Add Environment Variable to PATH

I am new to the Apple "eco system" and I am trying to setup my environment variables for local development. Here is what I have in my ~/.bash_profile (simplified for brevity): export PATH="$...
3
votes
1answer
438 views

Is it possible to remove the $ from an environment variable?

I'm on Mac and have just created an environment variable inside the .bash_profile directory, it works fine when I run: $variable_name I just want the know why the dollar sign is there and if it is ...
2
votes
0answers
26 views

Launching an application via Finder and enabling env variables for logging

I want to launch an application via Finder in a current Mac OS X. I want to enable some logging modules, which can be set by export NAME=etc on the console, but I want to include them in the Finder-...
3
votes
1answer
2k views

Missing /usr/local/sbin directory in the /etc/paths file

Why doesn’t the /etc/paths file include the /usr/local/sbin directory on macOS? $ cat /etc/paths /usr/local/bin /usr/bin /bin /usr/sbin /sbin I would have expected: $ cat /etc/paths /usr/local/bin /...
1
vote
2answers
272 views

Environment variable for Apple Shake 4.1

Where is Shake's environment variable located in macOS allowing to launch Shake.app via Terminal session in High Sierra? There's no Shake's variables in ~/.bash_profile, /etc/profile and /etc/bashrc....
0
votes
1answer
336 views

/etc/profile not being sourced for login shells

The -l flag to sh is supposed to source the contents of /etc/profile and other profile scripts like ~/.profile, which generally provide the initial set of environment variables for a login session. ...
7
votes
1answer
5k views

Setting variables in environment.plist

I've been trying to come to terms with how to set environment variables needed by launched applications in Sierra, but I'm puzzled. Following various bits of advice found online, I created a file ~/...
2
votes
1answer
1k views

macOS no longer recognizes environment.plist

I need to set up environment variables for Pixar RenderMan Pro Server in macOS 10.13. Yosemite, El Capitan, Sierra and High Sierra no longer recognize environment.plist located in a hidden .MacOSX ...
1
vote
1answer
1k views

Safe to change TMPDIR?

I recently installed Open MPI, and it's complaining PMIx has detected a temporary directory name that results in a path that is too long for the Unix domain socket: Temp dir: /var/folders/**/********...
2
votes
0answers
2k views

Environment var (LD_LIBRARY_PATH) weirdly hidden under bash on Mac [duplicate]

Here is a brief, self-explanatory bash session on Linux: $ env | grep LD_LIBRARY_PATH $ export LD_LIBRARY_PATH=foo $ env | grep LD_LIBRARY_PATH LD_LIBRARY_PATH=foo $ echo $LD_LIBRARY_PATH foo Here ...
10
votes
2answers
23k views

How do I add a directory to PATH when using `zsh` in Sierra

In macOS Sierra 10.12.x, what is the modern way to add a directory to the PATH environment variable that can work across shells or specifically work with zsh shell (I switched from the default bash to ...
1
vote
1answer
795 views

Set environment variable for applications on startup

How do you set an environment variable on startup so that it can be used in applications? For example, ATOM_HOME is used by Atom.
0
votes
1answer
595 views

Command found with `which` at the new paths but still tries to run from the old path

I have installed new version of npm in the custom directory .npm-global/bin and removed it from /usr/local/bin. The new path is declared: PATH=/usr/local/bin:./node_modules/.bin:/Users/dmitrizaitsev/....
0
votes
1answer
242 views

Interaction between profiles of Terminal.app and environment variables

I wonder if and how it is possible to set shell environment variables based on the Terminal.app profile. More specifically, I would like to use a coloured prompt in Terminal.app or iTerm2.app in Mac ...
2
votes
2answers
137 views

Making ~/.bashrc function callable to set up an environment

I have an installed app lets call it my_app that I wish to be able to call from the command line. It is located in /Applications/my_app.app/Contents/Resources. So what I was hoping to do was to have ...
1
vote
0answers
75 views

Set language-related environment vars for _all_ processes (not just inside Terminal)

On my somewhat creaky MBP running Yosemite, I find that the POSIX environment variables for controlling the locale (LANG and LC_*) are properly set inside Terminal windows... $ printenv | grep -E '^(...
7
votes
2answers
3k views

Set PATH variable so that it is detected in all applications, even outside terminal. (El Captain)

My ~/etc/path looks as follows: /usr/local/bin /usr/bin /bin /usr/sbin /sbin The Problem: When I type echo $PATH into terminal, I get back: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin And this ...
3
votes
2answers
7k views

X11 applications don't open after XQuartz update (OS X 10.10.4)

I updated X11 by installing the most recent XQuartz package, 2.7.9. Now, when opening an application that is supported by X11 (e.g., emacs), my terminal throws an error (while X11 starts in the ...
1
vote
0answers
524 views

How do items in the 'Applications' folder get on the path?

How does the 'Applications' folder get on the path? For example, I installed Chrome browser into the Applications folder on my Mac and I can type chrome at a bash shell prompt to start it. Now, if I ...
0
votes
2answers
118 views

Is it possible to set the JAVA_HOME env in El Captitan?

I am unable to set the JAVA_HOME environment variable osx. I added the following line to my .bash_profile export JAVA_HOME=`/usr/libexec/java_home` and sourced it afterwards; yet when I printenv or ...