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.
106 questions
0
votes
0
answers
38
views
What is the location of system PATH and other environment variables in macOS 26?
There seems to be a consensus that the PATH for macOS (any version) is some value set (exclusively) in /etc/paths and user-maintained shell scripts (notably /etc/profile and ~/.profile as well as ...
0
votes
0
answers
112
views
TMPDIR is not set in a new shell when using su
On a Mac running macOS 13.5, $TMPDIR is not set in a new shell. This is a multi-user machine, and it is unset for all users that are sued to, causing multiple issues since libraries may default to /...
0
votes
1
answer
397
views
No $PATH file in my home folder on my Ventura 13.5.2? [duplicate]
I am using zsh and I wanted to modify the $PATH variable permanently. I can't seem to find either .zshrc or .zsh_profile on my computer -- I tried searching in Finder with enabled hidden files.
I ...
3
votes
2
answers
304
views
Can I use the output of a shell script to set env vars from launchd?
I'm using launchd to set an env var at startup using launchctl setenv.
The script works fine when the variable is hardcoded in it, but unfortunately I need to get this variable dynamically at startup ...
3
votes
3
answers
2k
views
Automator run shell script does not know my PATH?
When I use the "run shell script" in automator, and do, for example
say $PATH
it then tells me the PATH. But the path is incomplete. Some items I have in $PATH when using the terminal (zsh) ...
2
votes
1
answer
82
views
sudo -E -s does not preserve ZDOTDIR
Running zsh on macOS Ventura
→ With
sudo --preserve-env -s the environment variable ZDOTDIR is not preserved but all the others are.
→ With sudo --preserve-env=ZDOTDIR -s the variable ZDOTDIR is ...
1
vote
0
answers
217
views
Why is LANG environment variable wrong in shell?
When I start a Terminal (in Monterey 12.2.1) my LANG is sv_SE.UTF-8, which is fine.
When I start a shell, or any other sub-process that reads environment, from GUI Emacs it is set to LANG="en_SE....
1
vote
2
answers
2k
views
How to tell what shell is running from command line?
If I do sudo zsh, I can tell I am in zsh by examining ps -ef
Is there an easier way? echo $SHELL says it's /bin/sh, because $SHELL is always the default shell, not necessarily the shell that's ...
4
votes
1
answer
296
views
How to set PATH and other env vars for apps with "Reopen windows when logging back in"?
EDIT in 2023: I have macOS 13.2 Ventura and vscode 1.74.3 installed now, and this problem isn't reproducing the same way anymore. It looks like this is due to a relatively new vscode feature, Terminal ...
5
votes
4
answers
2k
views
Exporting DYLD_INSERT_LIBRARIES for libgmalloc not working on Big Sur?
I've been struggling with a very weird issue. I'm trying to use libgmalloc (eg per man 3 libgmalloc) on Big Sur (I'm on 11.3.1) to trouble shoot a memory issue in my code. However, I can't set the ...
2
votes
1
answer
325
views
Script menu: how to reference user-path utilities (PATH / environment is missing)
Summary
How can I execute scripts from the system-wide Script menu with a normal environment? It seems the environment is not being setup at all.
Scripts that are run from the script menu can find and ...
2
votes
4
answers
521
views
Automate workspace setup
I'm a software developer and I often have to switch between different projects, each with its own environment setup. Some actions I have to do each time include:
creating ssh tunnels
connecting ...
0
votes
0
answers
826
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 ...
4
votes
2
answers
971
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 ...
2
votes
0
answers
262
views
How to set an environment variable working on both bash and GUI? [duplicate]
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 ...
205
votes
1
answer
267k
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 ~/....
1
vote
1
answer
155
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 ...
0
votes
2
answers
2k
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
1
answer
7k
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/...
2
votes
2
answers
984
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'.
...
0
votes
0
answers
215
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 ...
7
votes
1
answer
1k
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:
# ...
1
vote
1
answer
137
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 ...
5
votes
1
answer
2k
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
3
answers
1k
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 ...