0

I'm trying to set global environment variables in my mac so that they can be seen from anywhere. I've tried setting them in both /profile and /.bash_profile but still when I run my script from blender then call echo $MY_LIB_PATH and echo $MY_PRO_PATH only one of them $My_PRO_PATH exists, I'm not sure why, looks like there is another location where $My_PRO_PATH is set where I need to set $My_LIB_PATH as well. Any advice please?

this is my /etc/profile:

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc
fi

export MY_LIB_PATH=/usr/local/mypro/mylib/
export MY_PRO_PATH=/usr/local/mypro/

this is my bash_profile:

export MY_LIB_PATH=/usr/local/mypro/mylib/
export MY_PRO_PATH=/usr/local/mypro/
Tak
  • 3,536
  • 11
  • 51
  • 93
  • Where/how did you run your script? From within the macOS's *Terminal* App? – pynexj Mar 29 '17 at 05:02
  • `/profile` is not a location. If you look at the `path_helper` man page, it actually tells you where you can customize these settings. – tripleee Mar 29 '17 at 05:46
  • You should not use the Bash-only `export VAR=value` syntax in a script which is also executed by `sh`. The portable syntax is `VAR=value; export VAR`. – tripleee Mar 29 '17 at 05:47
  • Uppercase variable names are reserved for system use. You should use lowercase variables if you are in control over this. – tripleee Mar 29 '17 at 05:47
  • @tripleee thanks for your comments. When I run my script in terminal using `~/Desktop/./run-test.sh` which has two lines ` echo $MY_LIB_PATH` and `echo $MY_PRO_PATH ` they are both printed. For some reason when I run my shell script from blender using `os.system('~/Desktop/./run-test.sh')` which has two lines ` echo $MY_LIB_PATH` and `echo $MY_PRO_PATH ` only `My_PRO_PATH ` is printed. Any thoughts please? – Tak Mar 29 '17 at 06:14
  • Did you reboot your system after changing `/etc/profile` if indeed you did change that? – tripleee Mar 29 '17 at 06:21
  • @tripleee which system? you mean reboot my mac? I didn't reboot my mac, I closed/terminated terminal and reopened it and when I type `echo $MY_LIB_PATH` and `echo $MY_PRO_PATH` they are both printed in the terminal. But for some reason calling the script from blender only print one of them which makes me think that possible I need to add the `MY_LIB_PATH ` somewhere else. Now they are both in etc/profile and bash_profile as shown in the question like that: `export MY_LIB_PATH=/usr/local/mypro/mylib/` `export MY_PRO_PATH=/usr/local/mypro/` – Tak Mar 29 '17 at 06:25
  • `/etc/profile` only gets evaluated system-wide at system startup. – tripleee Mar 29 '17 at 06:26
  • @tripleee okay, I'll try. Although I didn't do a restart before and one of them is already printed when calling echo :/ – Tak Mar 29 '17 at 06:28
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/139326/discussion-between-tak-and-tripleee). – Tak Mar 29 '17 at 07:17
  • @tripleee I tried making a .command file called mytest.command which has 2 echos for the two variables but when I run it only one of them is printed although if I terminated all terminal sessions and opened new one then typed echo for both in it they are both displayed? – Tak Mar 29 '17 at 07:18

0 Answers0