Error with /etc/profile after login

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
maximumwarp

Error with /etc/profile after login

Post by maximumwarp »

Hello,
since about two or three days, when I boot up my Mint 19 box just after login I get this error message:

Code: Select all

Error found when loading /etc/profile:

/etc/profile: line 22: [: /etc/profile.d/GitHub: binary operator expected

As a result the session will not be configured correctly.
You should fix the problem as soon as feasible.
What's wrong? How can I fix? :( :shock:
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
WharfRat

Re: Error with /etc/profile after login

Post by WharfRat »

Did you make any changes ti it :?:

Paste back the results of diff /usr/share/base-files/profile /etc/profile
maximumwarp

Re: Error with /etc/profile after login

Post by maximumwarp »

WharfRat wrote: Sun Nov 18, 2018 1:59 pm Did you make any changes ti it :?:

Paste back the results of diff /usr/share/base-files/profile /etc/profile
If I do diff /usr/share/base-files/profile /etc/profile in terminal I have no output...
WharfRat

Re: Error with /etc/profile after login

Post by WharfRat »

maximumwarp wrote: Tue Nov 20, 2018 9:40 am
WharfRat wrote: Sun Nov 18, 2018 1:59 pm Did you make any changes ti it :?:

Paste back the results of diff /usr/share/base-files/profile /etc/profile
If I do diff /usr/share/base-files/profile /etc/profile in terminal I have no output...
Neither do I so that means it's OK.

On further scrutiny of your error message, what is sitting in ls -lh /etc/profile.d/
maximumwarp

Re: Error with /etc/profile after login

Post by maximumwarp »

WharfRat wrote: Tue Nov 20, 2018 9:47 am
On further scrutiny of your error message, what is sitting in ls -lh /etc/profile.d/

Code: Select all

xxxxxxxx@xxxxxx:~$ ls -lh /etc/profile.d/
total 32K
-rw-r--r-- 1 root root  825 Jul 19 12:05  apps-bin-path.sh
-rw-r--r-- 1 root root  664 Apr  2  2018  bash_completion.sh
-rw-r--r-- 1 root root  294 Mar 11  2018  flatpak.sh
-rw-r--r-- 1 root root   50 Nov 15 19:39 'GitHub Desktop.sh'
-rw-r--r-- 1 root root  652 Feb 13  2018  input-method-config.sh
-rwxr-xr-x 1 root root  301 Feb 20  2013  jdk.csh
-rwxr-xr-x 1 root root  299 Feb 20  2013  jdk.sh
-rw-r--r-- 1 root root 1,9K Apr 10  2018  vte-2.91.sh
WharfRat

Re: Error with /etc/profile after login

Post by WharfRat »

It's complaining about the 'GitHub Desktop.sh' file so move it out of there to your home and see what happens

sudo mv /etc/profile.d/'GitHub Desktop.sh' ~
maximumwarp

Re: Error with /etc/profile after login

Post by maximumwarp »

WharfRat wrote: Wed Nov 21, 2018 11:32 am It's complaining about the 'GitHub Desktop.sh' file so move it out of there to your home and see what happens

sudo mv /etc/profile.d/'GitHub Desktop.sh' ~
I actually suspected it... I try to uninstall the GitHub Desktop application, I prefer to use git from command line.
Thank you! :wink:
gm10

Re: Error with /etc/profile after login

Post by gm10 »

That's not the problem though. The error is a syntactical error in the /etc/profile script exactly where it says it is, by the looks of it they forgot to quote the filename:
maximumwarp wrote: Sun Nov 18, 2018 1:52 pm

Code: Select all

Error found when loading /etc/profile:

/etc/profile: line 22: [: /etc/profile.d/GitHub: binary operator expected
What's wrong? How can I fix? :( :shock:
If uninstalling that application doesn't properly restore the script you'll have to edit that manually.
WharfRat

Re: Error with /etc/profile after login

Post by WharfRat »

gm10 wrote: Thu Nov 22, 2018 5:55 am That's not the problem though. The error is a syntactical error in the /etc/profile script exactly where it says it is, by the looks of it they forgot to quote the filename:
If uninstalling that application doesn't properly restore the script you'll have to edit that manually.
It can't be /etc/profile because a diff /usr/share/base-files/profile /etc/profile had no results viewtopic.php?p=1555519#p1554862
gm10

Re: Error with /etc/profile after login

Post by gm10 »

WharfRat wrote: Thu Nov 22, 2018 9:28 am It can't be /etc/profile
It's a philosophical question I guess. Is the error caused by /etc/profile not quoting the filename in line 22 or by the GitHub script's filename containing a space? Blame on both sides, no doubt.
WharfRat

Re: Error with /etc/profile after login

Post by WharfRat »

It has something to do with that GitHub file as line 22 is checking if it's readable

Code: Select all

    20	if [ -d /etc/profile.d ]; then
    21	  for i in /etc/profile.d/*.sh; do
    22	    if [ -r $i ]; then
    23	      . $i
    24	    fi
gm10

Re: Error with /etc/profile after login

Post by gm10 »

WharfRat wrote: Thu Nov 22, 2018 9:57 am It has something to do with that GitHub file as line 22 is checking if it's readable
As I said:
The problem with the GitHub file is that it contains a space in the filename.
The problem with /etc/profile is that it does not quote the filename and thus cannot handle a space.

I don't care where you ultimately place the blame. You can fix it either by renaming the file or by fixing /etc/profile:

Code: Select all

sudo sed -i 's/$i/"$i"/' /etc/profile
source /etc/profile
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Error with /etc/profile after login

Post by Flemur »

gm10 wrote: Thu Nov 22, 2018 10:07 amThe problem with the GitHub file is that it contains a space in the filename.
Eeeevilll! It's evil, I tells ya!
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
WharfRat

Re: Error with /etc/profile after login

Post by WharfRat »

I'm surprised $i wasn't quoted in the first place :?
maximumwarp

Re: Error with /etc/profile after login

Post by maximumwarp »

gm10 wrote: Thu Nov 22, 2018 10:07 am
WharfRat wrote: Thu Nov 22, 2018 9:57 am It has something to do with that GitHub file as line 22 is checking if it's readable
As I said:
The problem with the GitHub file is that it contains a space in the filename.
The problem with /etc/profile is that it does not quote the filename and thus cannot handle a space.

I don't care where you ultimately place the blame. You can fix it either by renaming the file or by fixing /etc/profile:

Code: Select all

sudo sed -i 's/$i/"$i"/' /etc/profile
source /etc/profile
I tried doing:

Code: Select all

sudo sed -i 's/$i/"$i"/' /etc/profile
source /etc/profile
after the sed command I verified and the $i in /etc/profile are quoted.
I logout and then I can't login in my account so I reverted back to no-quoted $i. Now I can login again but the error message is still there. I'll try to rename 'Github Desktop.sh' to 'GithubDesktop.sh'.
maximumwarp

Re: Error with /etc/profile after login

Post by maximumwarp »

Guys, please now I really need HELP because I'm really in trouble!

I tried to rename /etc/profile.d/GitHub Desktop.sh to /etc/profile.d/GitHubDesktop.sh (so same name but without space) and now I can't log in, when I enter my password I'm always shown the login screen again.
If I access a text console with CTRL + ALT + Fx and go to /etc/profile.d the GitHubDesktop.sh file seems to have disappeared...


HEEEEEEEEEEEEEEEEEEELP!!!!!!!!!!! :(
gm10

Re: Error with /etc/profile after login

Post by gm10 »

maximumwarp wrote: Fri Nov 23, 2018 12:27 pm after the sed command I verified and the $i in /etc/profile are quoted.
I logout and then I can't login in my account so I reverted back to no-quoted $i.
As you realized, the problem wasn't with the command I gave but with the GitHub script itself. As to finding that script, did you check if you renamed it to something else?:

Code: Select all

ll /etc/profile.d
You've got the listing of what else should be in there in your previous post: viewtopic.php?p=1555231#p1555231
Whichever file doesn't match is the GitHub one you have to remove. ;)
WharfRat

Re: Error with /etc/profile after login

Post by WharfRat »

Do you know how to mount your Linux partition to /mnt from the live media :?:

If so, do so and paste back ls -lh /mnt/etc/profile.d
maximumwarp

Re: Error with /etc/profile after login

Post by maximumwarp »

Thank you to all, I solved uninstalling GitHub Desktop...
Locked

Return to “Beginner Questions”