10

I just installed Rust by curl https://sh.rustup.rs -sSf | sh and rebooted my system. But I cannot access cargo, rustc.. on my terminal.

My .profile file contains the following line

export PATH="$HOME/.cargo/bin:$PATH" I'm using Xfce 4.12 as my desktop env.

I can guess this happens because, my PATH variable is not working .. ?

So, my question is, .profile not work in Xfce(I'm very much new to Xfce) as with Gnome? and how should I resolve this.

Thank you in advance.

Amirtha Wiiliam
  • 103
  • 1
  • 5
  • 1
    ~/.profile is not read if ~/.bashr_profile or ~/.bash_login exists so check those two files - if you have them, they're probably the reason why the file is not read and doesn't set PATH env variable. Otherwise, it might be due to how your shell is invoked. Try starting bash with bash --login command. It reads ~/.profile then so you should have PATH variable modified. If you haven't closed the terminal since you installed cargo (immediately trying to call cargo after install ) , then try to logout and log back in – Sergiy Kolodyazhnyy Mar 23 '19 at 05:59
  • Thank you @SergiyKolodyazhnyy for the reply :) Yes! works with bash --login. and only with bash --login As soon as exited and reopened the terminal they were gone. I'm not sure why this happens. – Amirtha Wiiliam Mar 23 '19 at 06:56
  • Has logging out/in helped ? – Sergiy Kolodyazhnyy Mar 23 '19 at 06:58
  • no :) @SergiyKolodyazhnyy – Amirtha Wiiliam Mar 23 '19 at 06:59
  • In that case, take out that line out of ~/.profile file and place it into ~/.bashrc at the very end of the file. After that whenever you open new terminal tab or window, you will have the proper PATH value available. – Sergiy Kolodyazhnyy Mar 23 '19 at 07:03
  • For some reason this only happens to me when I connect using remote VNC connection, but not when I'm on the physical machine opening a terminal from a seemingly similar xfce desktop. Why do I only have problem in remote session? – Moberg Mar 14 '25 at 09:26

2 Answers2

5

Try adding

. /etc/profile
. ~/.profile

to ~/.xsessionrc.

  • 2
    Yes, this is much better. ~/.xsessionrc might not be created by default so ~/.profile is not loaded. More info here: https://wiki.debian.org/Xsession – nyg Mar 19 '21 at 13:07
  • What is the difference between ~/.xsession and ~/.xsessionrc and what do I need to do to reload it? – Moberg Mar 14 '25 at 09:28
0

As has been determined in the comments, the ~/.profile not being loaded is the root cause of the issue. The solution is to either start the shell with --login option or relocate the variable declaration and export into ~/.bashrc file so that it is available in every interactive shell.

  • It works! .bashrc is for non-login shells right. I'm curious, does editing this file and amending lines to it effect the security ? – Amirtha Wiiliam Mar 23 '19 at 07:37
  • @AmirthaWiiliam ~/.bashrc is for interactive shells in general, and regardless if that interactive shell is login or non-login shell. The ~/.bashrc file is read if you log into TTY1 or via ssh (those two start a login shell) or open a GUI terminal, but not when you run a script ( because a script is non-interactive shell ). As for security, generally you should put there only commands you understand, and keep it from being edited by other username (so set permissions to either 644 or 600). – Sergiy Kolodyazhnyy Mar 23 '19 at 07:41
  • If you start another shell by calling bash from inside another shell, you will be calling bashrc multiple times and append multiple times on your PATH. – Moberg Mar 14 '25 at 09:08