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
0 votes
0 answers
48 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 ...
user avatar
1 vote
0 answers
24 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....
user avatar
  • 141
1 vote
2 answers
194 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
80 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 ...
user avatar
  • 3,355
0 votes
1 answer
92 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 ...
user avatar
1 vote
1 answer
46 views

How to set PATH and other env vars for apps with "Reopen windows when logging back in"?

I have the option "Reopen windows when logging back in" set, which on my 11.6 macbook will reopen apps like vscode and iTerm2 after I restart. I want the reopened windows to have the ...
user avatar
1 vote
1 answer
122 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 ...
user avatar
4 votes
2 answers
339 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 ...
user avatar
1 vote
0 answers
28 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 ...
user avatar
  • 193
2 votes
1 answer
146 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 ...
user avatar
10 votes
1 answer
3k 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 ...
user avatar
  • 1,076
1 vote
4 answers
329 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 ...
user avatar
1 vote
0 answers
206 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?
user avatar
  • 227
0 votes
0 answers
701 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 ...
user avatar
  • 227
0 votes
1 answer
179 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 ...
user avatar
  • 31
4 votes
2 answers
422 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 ...
user avatar
1 vote
1 answer
356 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 ...
user avatar
  • 113
2 votes
0 answers
240 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 ...
user avatar
0 votes
2 answers
5k 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 ...
user avatar
  • 329
90 votes
1 answer
76k 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 ~/....
user avatar
  • 81k
0 votes
2 answers
258 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 ...
user avatar
1 vote
1 answer
57 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 ...
user avatar
  • 11
1 vote
1 answer
2k 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 ...
user avatar
  • 117
0 votes
2 answers
1k 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 ...
user avatar
  • 117
1 vote
2 answers
795 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 ...
user avatar
0 votes
1 answer
4k 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/...
user avatar
  • 103
5 votes
1 answer
94 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 ...
user avatar
2 votes
2 answers
422 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'. ...
user avatar
2 votes
1 answer
230 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 ...
user avatar
  • 991
0 votes
0 answers
142 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 ...
user avatar
1 vote
2 answers
326 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 "/...
user avatar
  • 2,016
0 votes
0 answers
38 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 /...
user avatar
7 votes
1 answer
691 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: # ...
user avatar
  • 450
65 votes
7 answers
138k 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 ...
user avatar
1 vote
1 answer
83 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 ...
user avatar
  • 3,220
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 ...
user avatar
  • 409
3 votes
1 answer
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 ...
user avatar
  • 151
3 votes
1 answer
752 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:/...
user avatar
  • 217
3 votes
3 answers
953 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 ...
user avatar
0 votes
1 answer
414 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/...
user avatar
4 votes
1 answer
4k 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="$...
user avatar
3 votes
1 answer
596 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 ...
user avatar
2 votes
0 answers
46 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-...
user avatar
  • 31
3 votes
1 answer
3k 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 /...
user avatar
  • 135
1 vote
2 answers
282 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....
user avatar
0 votes
1 answer
423 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. ...
user avatar
9 votes
1 answer
7k 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 ~/...
user avatar
  • 193
2 votes
1 answer
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 ...
user avatar
2 votes
1 answer
2k 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/**/********...
user avatar
1 vote
0 answers
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 ...
user avatar