": command not found" when launching bash

Hi, everyone
Every launching of bash begin with the error messages as below:

: command not found
: command not found
: command not found
XXX@localhost:~>

The .bashrc is as follows:

Sample .bashrc for SUSE Linux

Copyright (c) SUSE Software Solutions Germany GmbH

There are 3 different types of shells in bash: the login shell, normal shell

and interactive shell. Login shells read ~/.profile and interactive shells

read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all

settings made here will also take effect in a login shell.

NOTE: It is recommended to make language settings in ~/.profile rather than

here, since multilingual X sessions would not work properly if LANG is over-

ridden in every subshell.

test -s ~/.alias && . ~/.alias || true

If anyone has encountered the same phenomenon and knows of a solution, I would appreciate it if you could share it with me.

Hello and welcome to the openSUSE forums.

How!

That is in short. You fail to explain how you “launch” bash (and we are no mind-readers :wink: ).

Also, please only copy/paste complete actions. That is starting with the prompt/command line as first, then all output and then the new prompt line.

And please use the Preformatted text feature (the button </> from the tool bar of the post editor) around such copied/pasted computer text. then maybe the silly bold text will also revert to normal.

Dear hcvv
Thank you for your instruction.

When I launch bash via Konsole from Application launcher:

: command not found
: command not found
: command not found
soedih@localhost:~>

That is, before the command prompt appears, I get “: command not found” three times.

When I launch bash via xterm, I get the same result.
When I launch fish via Konsole, the problem does not occur.

I would be happy to get advice from the community.

Thanks for the clarifications.

I read from the error messages that the sole : means that the command name is “empty” (which is then of course not found).

In fact the only line apart from comment lines and empty lines in ~/.bashrc is

test -s ~/.alias && . ~/.alias || true

which is normal.

Did you alter something in ~/.profile ?

In ~/.profile I only changed the EDITOR setting:

# Sample .profile for SUSE Linux
# rewritten by Christian Steinruecken <cstein@suse.de>
#
# This file is read each time a login shell is started.
# All other interactive shells will only read .bashrc; this is particularly
# important for language settings, see below.

test -z "$PROFILEREAD" && . /etc/profile || true

# Some applications read the EDITOR variable to determine your favourite text
# editor. So uncomment the line below and enter the editor of your choice :-)
export EDITOR=/usr/bin/nvim
#export EDITOR=/usr/bin/mcedit

# For some news readers it makes sense to specify the NEWSSERVER variable here
#export NEWSSERVER=your.news.server

# Some people don't like fortune. If you uncomment the following lines,
# you will have a fortune each time you log in ;-)

#if [ -x /usr/bin/fortune ] ; then
#    echo
#    /usr/bin/fortune
#    echo
#fi
#

I can see no strange things here either.

Maybe you could try first to start in e.g. konsole (where you get those three errors) and then at the prompt

bash -v

that will start bash again and print all lines it gets. The problem is that it will make a long list of profile’s and bashrc’s.
I was not able to catch this in a file. So you have to scroll back up in konsole and check if you can find the error and what is above it.

The three “command not found” were concentrated at the end of the bash -v output result. The last 21 lines of the output result are shown below.

# End of /etc/bash.bashrc
#
# Sample .bashrc for SUSE Linux
# Copyright (c) SUSE Software Solutions Germany GmbH

echo $"$1: command not found" >&2
: command not found
# There are 3 different types of shells in bash: the login shell, normal shell
# and interactive shell. Login shells read ~/.profile and interactive shells
# read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
# settings made here will also take effect in a login shell.
#
# NOTE: It is recommended to make language settings in ~/.profile rather than
# here, since multilingual X sessions would not work properly if LANG is over-
# ridden in every subshell.

echo $"$1: command not found" >&2
: command not found
test -s ~/.alias && . ~/.alias || true
echo $"$1: command not found" >&2
: command not found

Strange, very strange.

It happens after the blank lines in .bashrc .

Can you test this by adding temporary a blank line, e.g. between the two lines

# Sample .bashrc for SUSE Linux
# Copyright (c) SUSE Software Solutions Germany GmbH

Then there should be four error messages.

=====

Maybe I must add that I am not using Tumbleweed, but Leap. So comparing is difficult. But the two are not very different in this area I assume. I doubt that other Tumbleweed users have the same. No reports, nor people posting here that have seen the phenomenon at their own system.

Nevertheless could you explain if you had this before, or is this a new installation, or is it after an update?


I’ll bet this is closely related or the same problem. This image is from TDE 14.1.1 Konsole freshly opened and untouched in TW20240426. The user login account is old, but it was never previous to today used to open a TDE session or TDE’s Konsole. When I resize the window, the prompt count increases until it fills the entire cmdline. An updir/downdir key sequence reduces the prompt count to one. On many instances of these anomalous MCs, attempts to run commands from the prompt fail in various ways that I have not made any attempts to keep track of.

I have many installations and users where these multiple prompts appear when Konsole is opened or reopened in TDE, KDE3 and Plasma5. It started too long ago to remember with any specificity, but I believe it’s conjoined with this bug’s timing.  

.bashrc for this image’s user contains a single non-blank line that is not a comment, and 5 blank lines. The non-comment, non-blank is the last:

test -s ~/.alias && . ~/.alias || true

As you predicted, I have four error messages now.

: command not found
: command not found
: command not found
: command not found
soedih@localhost:~> 

I don’t remember after which update this message started appearing, but I don’t think the error message appeared immediately after installation.

Can you post the output from:

echo "$IFS" | od -x

Thank you for your suggestion.
I also observed the behavior of midnight commander and confirmed that it exhibits exactly the same phenomenon, including during resizing.

When I move to another directory, there is one prompt.

OK!

soedih@localhost:~> echo "$IFS" | od -x
0000000 0920 0a0a
0000004

That’s what it should be.

When you edited “.bashrc” to add a blank line, what editor did you use?

1 Like

Yep.

bor@bor-Latitude-E5450:~$ LANG=C . /tmp/foo.sh
: command not found
: command not found
bor@bor-Latitude-E5450:~$ LANG=C file /tmp/foo.sh
/tmp/foo.sh: Bourne-Again shell script, ASCII text executable, with CRLF line terminators
bor@bor-Latitude-E5450:~$ 

I think I used Neovim because I mostly use it.

Show output of

file ~/.bashrc
soedih@localhost:~> file ~/.bashrc
/home/soedih/.bashrc: ASCII text, with CRLF line terminators

which explains your “empty” command. Convert it to from DOS to Unix text file.

1 Like

Here:

henk@boven:~> file ~/.bashrc
/home/henk/.bashrc: ASCII text
henk@boven:~> 

I think @arvidjaar is up to something. Some editor you use makes wrong line endings.