1

I upgraded my system from 14.04 to 16.04 a while ago, but this problem has been really bothering me since, and I still don't have a solution.

When I start an application from a launcher (like MATLAB), I found that the LD_LIBRARY_PATH variable is not defined as in my .bashrc file, which causes that some of my codes stop working.

Similarly, when I double-clicking a binary and start those from Thunar, the application is also not aware of the environment var settings in .bashrc.

can anyone know to fix this problem? it worked perfectly fine in xubuntu 14.04 and older versions.

FangQ
  • 367
  • .bashrc is only sourced by bash, and only under certain circumstances (see "Invocation" in man bash). Check the launcher file, my guess is that bash is not even involved when starting the application from the launcher or executing a binary from thunar. So you'll probably want to define the environment variables in a file that also affects thunar's environment. I'm sure there are Q&As available on AskUbuntu that already explain how to do that. – danzel Mar 20 '19 at 11:36
  • thanks @danzel. When I click on the "launcher", or double-clicking an executable in the file browser (in my case, Thunar), what kind of shell does it start? an interactive one or non-iterative one? or no shell at all? is there a way to find out? – FangQ May 03 '19 at 02:58
  • To find out if it is started in a shell, you can use pstree or ksysguard to view the process tree. For setting environment variables, see this answer for a quick reference or the Ubuntu help page for more detailed information. The easiest approach is probably adding the variable to /etc/environment, but since the variable you are setting is very generic, you'll probably want a solution more specific to the application like using env in the launcher's exec line or using a wrapper script. – danzel May 03 '19 at 07:49
  • Is there no way to add variables to all app started from the launcher? – Lou Garczynski Feb 19 '21 at 15:57

1 Answers1

1

If the problem you are describing is that it is failing to source your bashrc file, try the following: Check your ~/.profile file and add something like this:

if [ -n "$BASH_VERSION" ]; then
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

Then, try opening a terminal again and see if it sources it.

Mike D
  • 168
  • 2
    thanks for the reply. However, upon checking my ~/.profile file, it already contains the code you shared. Are there other places that I need to check?

    Also, when double-clicking in a file browser to start an application, does that start an "interactive" or "non-interactive" shell? I am still a bit confused. thanks

    – FangQ May 03 '19 at 02:53