You are not logged in.

#1 2016-07-20 05:39:57

nexcode
Member
Registered: 2016-07-20
Posts: 17

Gnome 3 GUI and environment variables from ~/.bashrc

I set in my .bashrc file:
export GOPATH=${HOME}/GoProjects
export PATH=${PATH}:${HOME}/GoProjects/bin

It works in my console but not working in Gnome 3 GUI app.
For example, https://aur.archlinux.org/packages/visual-studio-code/ reports that a variable GOPATH is not set.

Offline

#2 2016-07-20 06:48:43

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,738

Re: Gnome 3 GUI and environment variables from ~/.bashrc

Yeah the .bashrc is only parsed for interactive shells, you want /etc/profile(.d/*.sh) or /etc/environment or similar https://wiki.archlinux.org/index.php/En … s#Globally or .bash_profile if it is to be used only by your user

Offline

#3 2016-07-20 07:35:37

nexcode
Member
Registered: 2016-07-20
Posts: 17

Re: Gnome 3 GUI and environment variables from ~/.bashrc

V1del wrote:

Yeah the .bashrc is only parsed for interactive shells, you want /etc/profile(.d/*.sh) or /etc/environment or similar https://wiki.archlinux.org/index.php/En … s#Globally or .bash_profile if it is to be used only by your user

Thanks, I read this guide.
But, if I declare a variable in the ~/.bash_profile, it does not work in console or the GUI.
I want to set these variables only for the user.

Offline

#4 2016-07-20 07:44:51

corner578
Member
Registered: 2012-06-16
Posts: 11

Re: Gnome 3 GUI and environment variables from ~/.bashrc

You can set GOPATH in /etc/profile.
After that all works in Atom + go-plus

Offline

#5 2016-07-20 07:49:34

nexcode
Member
Registered: 2016-07-20
Posts: 17

Re: Gnome 3 GUI and environment variables from ~/.bashrc

corner578 wrote:

You can set GOPATH in /etc/profile.
After that all works in Atom + go-plus

Thanks, but, this will work for all users.
GOPATH is specific to each user variable.

Last edited by nexcode (2016-07-20 07:51:53)

Offline

#6 2016-07-20 08:45:09

corner578
Member
Registered: 2012-06-16
Posts: 11

Re: Gnome 3 GUI and environment variables from ~/.bashrc

Try create ~/.gnomerc and set GOPATH there

Last edited by corner578 (2016-07-20 08:45:25)

Offline

#7 2016-07-20 12:54:06

gnumdk
Member
Registered: 2009-10-15
Posts: 175

Re: Gnome 3 GUI and environment variables from ~/.bashrc

$ less /etc/gdm/Xsession
[...]
# First read /etc/profile and .profile
test -f /etc/profile && . /etc/profile
test -f "$HOME/.profile" && . "$HOME/.profile"
# Second read /etc/xprofile and .xprofile for X specific setup
test -f /etc/xprofile && . /etc/xprofile
test -f "$HOME/.xprofile" && . "$HOME/.xprofile"
[...]

Offline

#8 2016-07-20 19:13:32

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Gnome 3 GUI and environment variables from ~/.bashrc

Manipulating your $PATH is best done in ~/.profile (or the bash-specific alternative ~/.bash_profile) if only because it should only take effect once (not multiple times for multiple subshells).

Also, a common tactic for unifying your shell initialization is to source ~/.bashrc from ~/.bash_profile


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#9 2016-07-20 19:24:30

nexcode
Member
Registered: 2016-07-20
Posts: 17

Re: Gnome 3 GUI and environment variables from ~/.bashrc

gnumdk wrote:

$ less /etc/gdm/Xsession
[...]
# First read /etc/profile and .profile
test -f /etc/profile && . /etc/profile
test -f "$HOME/.profile" && . "$HOME/.profile"
# Second read /etc/xprofile and .xprofile for X specific setup
test -f /etc/xprofile && . /etc/xprofile
test -f "$HOME/.xprofile" && . "$HOME/.xprofile"
[...]

Thank you.
I created a ~/.profile and declare variables there. It works in console and the GUI.

Offline

Board footer

Powered by FluxBB