Page 1 of 1

Exported the wrong path in Pi renders all commands useless

Posted: Tue Mar 31, 2020 10:53 am
by needbighelp
Hi everyone,
I was tinkering around with the command line of my Pi and found out the hard way that exporting to a wrong path makes all of my commands unusable. I was installing a package using pip and it advise me to export my PATH like this:

Code: Select all

  The script pycodestyle is installed in '/home/pi/.local/bin' which is not on PATH.
I follow the instruction and execute export PATH=/home/pi/.local/bin. The installed package works but other commands like "ls, nano, cat.." all is not working, I tried exporting back to /usr/local/bin and /usr/bin like this
export PATH=/usr/local/bin but see no results.
I have lots of important data on there and in need of help right now. Any helping hands would definitely be appreciated :(

Re: Exported the wrong path in Pi renders all commands useless

Posted: Tue Mar 31, 2020 11:02 am
by B.Goode
Welcome to the Raspberry Pi forums.

needbighelp wrote:
Tue Mar 31, 2020 10:53 am
Hi everyone,
I was tinkering around with the command line of my Pi and found out the hard way that exporting to a wrong path makes all of my commands unusable. I was installing a package using pip and it advise me to export my PATH like this:

Code: Select all

  The script pycodestyle is installed in '/home/pi/.local/bin' which is not on PATH.
I follow the instruction and execute export PATH=/home/pi/.local/bin. The installed package works but other commands like "ls, nano, cat.." all is not working, I tried exporting back to /usr/local/bin and /usr/bin like this
export PATH=/usr/local/bin but see no results.
I have lots of important data on there and in need of help right now. Any helping hands would definitely be appreciated :(


Wouldn't simply rebooting the Operating System return your system to normal? That export should only be transient within your current session, it hasn't made any persistent change to your installation. (Assuming we have the whole story... )

Re: Exported the wrong path in Pi renders all commands useless

Posted: Tue Mar 31, 2020 11:09 am
by needbighelp
B.Goode wrote:
Tue Mar 31, 2020 11:02 am
Welcome to the Raspberry Pi forums.

needbighelp wrote:
Tue Mar 31, 2020 10:53 am
Hi everyone,
I was tinkering around with the command line of my Pi and found out the hard way that exporting to a wrong path makes all of my commands unusable. I was installing a package using pip and it advise me to export my PATH like this:

Code: Select all

  The script pycodestyle is installed in '/home/pi/.local/bin' which is not on PATH.
I follow the instruction and execute export PATH=/home/pi/.local/bin. The installed package works but other commands like "ls, nano, cat.." all is not working, I tried exporting back to /usr/local/bin and /usr/bin like this
export PATH=/usr/local/bin but see no results.
I have lots of important data on there and in need of help right now. Any helping hands would definitely be appreciated :(


Wouldn't simply rebooting the Operating System return your system to normal? That export should only be transient within your current session, it hasn't made any persistent change to your installation. (Assuming we have the whole story... )
So I rebooted as you say and now it works again. I thought export is permanent and you need to find the correct path to fix it. Thanks a bunch!

Re: Exported the wrong path in Pi renders all commands useless

Posted: Tue Mar 31, 2020 11:14 am
by thagrol
Setting PATH via an export command in the shell has no effect on disc contents or on the PATH in other shells/terminals/logins.

Just logout then log back in again.

To add something to your PATH you do it like this:

Code: Select all

export PATH=$PATH:/home/pi/.local/bin
That preserves the existing PATH and adds the new directory to the end of it. If you want it to be set after at the next boot or in the next terminal you open, add that line to the end of your .bashrc

Edit:
Seems you got there while I was writing this post. Gonna leave it up here anyway.

Re: Exported the wrong path in Pi renders all commands useless

Posted: Tue Mar 31, 2020 11:18 am
by jahboater
needbighelp wrote:
Tue Mar 31, 2020 11:09 am
So I rebooted as you say and now it works again. I thought export is permanent and you need to find the correct path to fix it. Thanks a bunch!
You should add the extra directory to $PATH
For example:

export PATH=$PATH:/home/pi/.local/bin

would leave your existing PATH unchanged.
These things become semi-permanent if you add the export to your bash profile so the export command is executed every time you start a new shell, or login.

Re: Exported the wrong path in Pi renders all commands useless

Posted: Tue Mar 31, 2020 11:27 am
by needbighelp
thagrol wrote:
Tue Mar 31, 2020 11:14 am
Setting PATH via an export command in the shell has no effect on disc contents or on the PATH in other shells/terminals/logins.

Just logout then log back in again.

To add something to your PATH you do it like this:

Code: Select all

export PATH=$PATH:/home/pi/.local/bin
That preserves the existing PATH and adds the new directory to the end of it. If you want it to be set after at the next boot or in the next terminal you open, add that line to the end of your .bashrc

Edit:
Seems you got there while I was writing this post. Gonna leave it up here anyway.
Thanks for your solution :), I did managed to make it back to default but still can't find a way to append /home/pi/.local/bin to my current path and this definitely works.

Re: Exported the wrong path in Pi renders all commands useless

Posted: Tue Mar 31, 2020 11:28 am
by needbighelp
jahboater wrote:
Tue Mar 31, 2020 11:18 am
needbighelp wrote:
Tue Mar 31, 2020 11:09 am
So I rebooted as you say and now it works again. I thought export is permanent and you need to find the correct path to fix it. Thanks a bunch!
You should add the extra directory to $PATH
For example:

export PATH=$PATH:/home/pi/.local/bin

would leave your existing PATH unchanged.
These things become semi-permanent if you add the export to your bash profile so the export command is executed every time you start a new shell, or login.
Thanks for the extra info. I will be extra cautious when doing something related to bash_profile and PATH.

Re: Exported the wrong path in Pi renders all commands useless

Posted: Tue Mar 31, 2020 11:48 am
by jbudd
Incidentally, if you have a directory /home/pi/bin, that is automatically added to your $PATH when you log in.

I know it wasn't your choice to put the script in .local/bin :)