7

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.

  • 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
  • thank you @SergiyKolodyazhnyy Will give it a try. – Amirtha Wiiliam Mar 23 '19 at 07:05

2 Answers2

4

Try adding

. /etc/profile
. ~/.profile

to ~/.xsessionrc.

Solomon Ucko
  • 157
  • 1
  • 7
  • 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
1

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.

Sergiy Kolodyazhnyy
  • 103,293
  • 19
  • 273
  • 492
  • 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