needbighelp
Posts: 4
Joined: Tue Mar 31, 2020 10:48 am

Exported the wrong path in Pi renders all commands useless

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 :(

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

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

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... )

needbighelp
Posts: 4
Joined: Tue Mar 31, 2020 10:48 am

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

Tue Mar 31, 2020 11:09 am

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!

User avatar
thagrol
Posts: 3178
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

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

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.
Arguing with strangers on the internet since 1993.

jahboater
Posts: 5825
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

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

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.
Pi4 8GB running PIOS64

needbighelp
Posts: 4
Joined: Tue Mar 31, 2020 10:48 am

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

Tue Mar 31, 2020 11:27 am

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.

needbighelp
Posts: 4
Joined: Tue Mar 31, 2020 10:48 am

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

Tue Mar 31, 2020 11:28 am

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.

jbudd
Posts: 1446
Joined: Mon Dec 16, 2013 10:23 am

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

Tue Mar 31, 2020 11:48 am

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 :)

Return to “Troubleshooting”