Garethmoffatt
Posts: 44
Joined: Sat Feb 25, 2017 10:11 pm

Terminal doesn't open properly first time

Mon Mar 12, 2018 1:13 am

When I click on the terminal icon in Pixel, the first time since boot, sometimes the terminal window doesn't open properly.
I get the standard license and no warranty message and the last login time message, but it doesn't give the path prompt and typing commands has no effect.
The second terminal window always opens properly.
This happens over SSH as well as at the "real" screen.
I think it started happening after I upgraded to Stretch. (R Pi 3)
It is possibe .bashrc is not being run because the last line of that is "fortune" and I never get a fortune when this fails.
Any suggestions on how to start debugging this?

Thanks in anticipation

Gareth

User avatar
jostle
Posts: 16
Joined: Tue Mar 06, 2018 6:26 am

Re: Terminal doesn't open properly first time

Wed Mar 14, 2018 6:11 am

This sounds a bit strange, especially if it only happens sometimes.

It seems as if, when you run the first terminal, it is invoking bash in non-interactive mode. That would explain the lack of a command prompt. The fact that you get the 'license and no warranty message and the last login time message' also suggests that it is being run as a login shell which is not what I would expect when running from the desktop.
Do you get the license message on the second terminal?

You could insert 'echo' commands in the startup scripts to provide some debugging info.

The scripts that are executed by bash at startup for a login shell are
  • /etc/profile
  • /etc/profile.d/*.sh
  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile
though on my system ~/.bash_profile and ~/.bash_login do not exist.

For normal interactive shells the startup scripts are
  • /etc/bash.bashrc
  • ~/.bashrc
You could start by adding an 'echo' command to the start and end of each of these files to identify which ones are being executed. Something like

Code: Select all

echo "Start /etc/profile"
.
.
.
echo "End /etc/profile"
at the top and bottom of '/etc/profile' and similarly for the other startup scripts.
Note that you will need to edit the files in '/etc/' as root by using 'sudo nano <filename>'.

For more details about bash startup have a look at the 'man' page

Code: Select all

man bash
especially the INVOCATION section.
Have Fun ...

Garethmoffatt
Posts: 44
Joined: Sat Feb 25, 2017 10:11 pm

Re: Terminal doesn't open properly first time

Fri Mar 30, 2018 11:15 pm

Would you believe it has only done it twice since your post?

At least I have pinned it down to .bashrc. I’ve added 10 way points in that and now just need it to fail again!

Thanks for the pointer, I was going nowhere!

Best regards

Gareth

Return to “Troubleshooting”