Skip to main content

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
2 votes
1 answer
249 views

MACHTYPE environment variable on ARM

I am on an M3 Pro, MacOS 14.2. When I try echo $MACHTYPE (in a default -zsh shell) the output is x86_64, whereas uname -mp returns arm64 arm. Zsh docs say that MACHTYPE should be "the machine ...
shea's user avatar
  • 177
0 votes
0 answers
44 views

Intel Conda installation on macbook pro : changing the name of environment from "root" to "base"

I have recently installed Intel conda on my macbook pro Sonoma and I have an issue when I list the different available environments of conda : $ conda env list # conda environments: # 2022.2.0 ...
guizmo133's user avatar
0 votes
0 answers
33 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 /...
slhck's user avatar
  • 2,274
4 votes
0 answers
2k views

How to set PATH for all applications on a per-user basis?

I'm looking for a way to set the PATH environment variable for all applications that I (and only I) run under macOS (version 14 / Sonoma at the time of writing.) That sounds like it ought to be ...
Eric Anderson's user avatar
0 votes
1 answer
337 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 ...
dnes's user avatar
  • 99
2 votes
0 answers
86 views

Set Environment Variable for specific application that starts at login

I need to set an env var for an app on MacOs. This is an app that I want to run on startup (currently via Login Items). I can set the env var as a LaunchAgent plist file with the RunAtLoad key set ...
Ramias's user avatar
  • 83
3 votes
2 answers
219 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 ...
VMX's user avatar
  • 41
0 votes
1 answer
2k views

How to unset a variable which is previously set somewhere in Mac OS I don't know?

I have a variable set exactly like this: export VARIABLE_NAME=VARIABLE_VALUE I thought it would be in ~/.zshrc or bash_profile but it is seen in none of those. I am now struggling to understand where ...
Shivam Sahil's user avatar
2 votes
3 answers
999 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) ...
Ma Joad's user avatar
  • 411
1 vote
2 answers
2k views

Set environment variable for the whole GUI session (Aka without using `~/.zshenv`)

(EDIT OF 06/02/2023 : Previous title was Variables set using launchctl setenv aren't part of environment in Mac OS 12 ) I'm a daily Linux user and decided to try Mac recently. I have a Macbook pro 13&...
binarym's user avatar
  • 111
1 vote
0 answers
38 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 ...
Damien L's user avatar
  • 247
0 votes
0 answers
425 views

X11/XQuartz 'Couldn't find per display information' on Mac Book Pro 2019, OS Monterey

I am trying to run mbsystem (a command-line tool for geodata processing) that for some commands uses a GUI based interface (e.g. if i type 'mbedit' in the command line, a window should open where i ...
Mia Mia's user avatar
1 vote
0 answers
170 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....
thoni56's user avatar
  • 151
10 votes
2 answers
8k views

What's the correct file to store environmental variables for zsh?

I'm a bit confused as to how all of this works. Seemingly every tutorial tells me something different. So far there's about 4 different files I can add environmental variables to: .zshrc .profile ....
user avatar
1 vote
2 answers
834 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 ...
WGroleau's user avatar
  • 5,055
1 vote
1 answer
4k views

Setting permanent environment variable [duplicate]

I want to set a permanent environment variable, I have used the .profile, .zshrc, .bash_profile, however, none have worked, after doing the command source .profile it works while I have the terminal ...
EDWARD FABIAN TAPIERO GOMEZ's user avatar
4 votes
1 answer
237 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 ...
Carl Walsh's user avatar
1 vote
1 answer
1k views

Is it possible to set an environment variable for a user, not just a shell?

I'm looking for a way to have some environment variables set for every application. From what I read there are multiple possible files such as ~/.profile, ~/bash_profile, ~/.zshenv etc. But ...
Philip Couling's user avatar
5 votes
4 answers
1k 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 ...
StuartStaniford's user avatar
1 vote
0 answers
89 views

Where application bundles get their environment variables from?

A user of my (Python based) app reports that they can't open it in regular way (via double clicking the icon in Finder) -- nothing just happens. When they run it from Terminal, they get an error (from ...
Aivar's user avatar
  • 203
2 votes
1 answer
273 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 ...
Mat Gessel's user avatar
12 votes
1 answer
5k views

macOS Big Sur - set env vars for GUI apps?

I followed many methods on Ask Different as to how to change the $PATH environmental variable for GUI apps. Some of the methods may work for pre-Catalina macOS, some may work for Catalina, but none of ...
Teddy C's user avatar
  • 1,792
2 votes
4 answers
461 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 ...
Carlo Moretti's user avatar
1 vote
0 answers
387 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?
Damien L's user avatar
  • 247
0 votes
0 answers
790 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 ...
Damien L's user avatar
  • 247
0 votes
1 answer
333 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 ...
Dmitry's user avatar
  • 67
4 votes
2 answers
814 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 ...
flynnstone9's user avatar
2 votes
1 answer
4k 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 ...
janedoe's user avatar
  • 123
2 votes
0 answers
256 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 ...
Adrian Maire's user avatar
4 votes
2 answers
7k 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 ...
mark's user avatar
  • 369
179 votes
1 answer
216k 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 ~/....
Allan's user avatar
  • 103k
1 vote
2 answers
724 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 ...
Luís Muniz's user avatar
1 vote
1 answer
128 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 ...
Akash's user avatar
  • 11
1 vote
1 answer
6k 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 ...
taylor018's user avatar
  • 117
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 ...
taylor018's user avatar
  • 117
1 vote
2 answers
2k 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 ...
Fez Vrasta's user avatar
0 votes
1 answer
6k 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/...
Dilip's user avatar
  • 103
5 votes
1 answer
147 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 ...
input_error's user avatar
2 votes
2 answers
906 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'. ...
WobblyWindows's user avatar
2 votes
1 answer
681 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 ...
Shuzheng's user avatar
  • 1,521
0 votes
0 answers
175 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 ...
Markus Meskanen's user avatar
1 vote
2 answers
567 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 "/...
Kevin's user avatar
  • 2,378
0 votes
0 answers
45 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 /...
Dennis Williamson's user avatar
7 votes
1 answer
914 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: # ...
Kaz Wolfe's user avatar
  • 460
97 votes
7 answers
269k 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 ...
Intrastellar Explorer's user avatar
1 vote
1 answer
114 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 ...
Seamus's user avatar
  • 4,732
4 votes
1 answer
12k 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 ...
pedz's user avatar
  • 463
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 ...
ha9u63a7's user avatar
  • 201
3 votes
1 answer
1k 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:/...
Royi's user avatar
  • 217
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 ...
George Mauer's user avatar