Error exclusive to Mint (Mate) when starting my program

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
MikeFinch
Level 1
Level 1
Posts: 13
Joined: Mon May 17, 2021 7:29 pm

Error exclusive to Mint (Mate) when starting my program

Post by MikeFinch »

I have upgraded to version 20.1 Mate. I have a problem that Manjaro, Mageia and Windows don't have : when I click on the Desktop icon for a program I have written in Lazarus Pascal, a dialog comes up saying that a file is not present when it is in fact in the same folder!
The relevant code in my starting procedure is as follows ->

if not FileExists('clubnames.txt') then begin
showmessage('clubnames.txt missing!');
halt;
end;

If I removed 'halt' and clicked on 'OK' instead I suppose the program would continue (mainly) as expected. But why do I get this happening at all in Mint, and not in the three OSs mentioned above?
It's not a great worry because I use Mageia as my chosen OS; I am just curious, and it would be an irritation if the user was using Mint!
Is it some sort of bug in Mint (Mate)?

MikeFinch
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.
User avatar
SMG
Level 25
Level 25
Posts: 31988
Joined: Sun Jul 26, 2020 6:15 pm
Location: USA

Re: Error exclusive to Mint (Mate) when starting my program

Post by SMG »

Welcome to the forum, Mike Finch.
MikeFinch wrote: Mon May 17, 2021 7:55 pmI have upgraded to version 20.1 Mate.
Was this a clean install of LM20.1 with a new install of Lazarus or did you upgrade from LM19?
MikeFinch wrote: Mon May 17, 2021 7:55 pm But why do I get this happening at all in Mint, and not in the three OSs mentioned above?
I'm not sure I understand what error you are getting, but this thread seems to indicate there may be some issues and using specific deb files may work while other files do not.

I may not be completely understanding the issue, but it seems you are asking why third party software is not working on Mint while it is on other operating systems.
Image
A woman typing on a laptop with LM20.3 Cinnamon.
MikeFinch
Level 1
Level 1
Posts: 13
Joined: Mon May 17, 2021 7:29 pm

Re: Error exclusive to Mint (Mate) when starting my program

Post by MikeFinch »

Thankyou SMG.

I upgraded from 19 via the menu option. I was first prompted to install a file to (presumably) fix my desktop (it was unresponsive without any icons). Somehow the system seemed to know I needed the fix. Then I upgraded to 20.1 via the menu. The first 20.1 boot displayed icons - yippee!

Please note that I am talking about an executable program produced by Lazarus Pascal IDE - I haven't installed LP in Mint. I think I tried but gave up because .deb files were involved, I didn't need to use the IDE anyway. (The executable is supposed to work identically on linux OSs - the Windows .exe file version was used for Windows 10).

What is happening in Mint is that when my program's main screen fires up (after an initial starting dialog to choose one of 3 options - different forms of play in croquet), a dialog appears intimating that 'clubnames.txt' is not found - this is nonsense since the clubnames.txt is in the same folder!

As I have said, the 3 other OSs behave as intended (no error message dialogbox appears).

I just cannot understand what is going on in Mint (Mate). Does anyone have an answer?

Just had a look at your thread suggestion - it seems to be related to Lazarus Pascal's use in Mint; so seems not to be relevant to my case[?].

MikeFinch
cfb
Level 3
Level 3
Posts: 154
Joined: Sun Nov 08, 2015 3:36 am

Re: Error exclusive to Mint (Mate) when starting my program

Post by cfb »

Since you are not specifying the full path to the file, the program is most likely looking for it in the current directory, which may not be where the file is located.
To test this, you could try printing current directory in the program right before it tries to find the file.
Alternatively, you could specify the full path to the file.
User avatar
SMG
Level 25
Level 25
Posts: 31988
Joined: Sun Jul 26, 2020 6:15 pm
Location: USA

Re: Error exclusive to Mint (Mate) when starting my program

Post by SMG »

MikeFinch wrote: Thu May 20, 2021 10:15 pmI upgraded from 19 via the menu option. I was first prompted to install a file to (presumably) fix my desktop (it was unresponsive without any icons). Somehow the system seemed to know I needed the fix. Then I upgraded to 20.1 via the menu. The first 20.1 boot displayed icons - yippee!
There is no menu option to upgrade LM19 to LM20. It has to be done manually.

One can update from one version of LM19 to a higher version of LM19 (and from one version of LM20 to a higher version of LM20) via the menu option, but one can not update from LM19 to LM20 through menu options. How to upgrade to Linux Mint 20 explains it is a manual process.

Quite a few people upgraded manually from LM19 to LM20 and many ended up doing clean installs of LM20 because they were unable to resolve issues which came up during the upgrade.

One way to test if the upgrade was an issue is to boot to a live session of Mint using an install usb/dvd and see if you can run the program without getting the error.
MikeFinch wrote: Thu May 20, 2021 10:15 pm (The executable is supposed to work identically on linux OSs
From where did you obtain this executable?
Image
A woman typing on a laptop with LM20.3 Cinnamon.
MikeFinch
Level 1
Level 1
Posts: 13
Joined: Mon May 17, 2021 7:29 pm

Re: Error exclusive to Mint (Mate) when starting my program

Post by MikeFinch »

Thanks SMG and cfb. Haven't tried specifying the full path (I presume you mean in the code?); surely this is counterproductive and I repeat that "no problem in the 3 OSs" I have mentioned. That is, the desktop icon specifies the location of the executable (which is the same as for 'clubnames.txt').

Oops! I meant 20.0 (not 19[.3]) to 20.1. Tried using the 20.0 DVD but don't have permission to enter /home/michael (in Mageia 8). So gave up.

The executable was developed in Mageia 8 with the code being compiled in W10 for the .exe version.

So, the problem is still there. No worries except that Mint users cannot use the program! Surely there is a solution lurking somewhere? Is it a Mint problem or are the 3 OSs themselves quirky : I think I know the answer! I'm afraid that this problem is the main reason Mint turns me off : don't others have this problem?

MikeFinch
cfb
Level 3
Level 3
Posts: 154
Joined: Sun Nov 08, 2015 3:36 am

Re: Error exclusive to Mint (Mate) when starting my program

Post by cfb »

Yes, I meant in the code, but just as a test. The same goes for the suggestion to print "current directory" from the code.
Are you sure the launcher (desktop icon) actually sets "current directory" to the right one before starting the program?
You could try starting the program from a command line, making sure that "current directory" is the one containing the executable and the file.
User avatar
SMG
Level 25
Level 25
Posts: 31988
Joined: Sun Jul 26, 2020 6:15 pm
Location: USA

Re: Error exclusive to Mint (Mate) when starting my program

Post by SMG »

MikeFinch wrote: Fri May 21, 2021 11:43 pm Tried using the 20.0 DVD but don't have permission to enter /home/michael (in Mageia 8). So gave up.
That sounds like a permissions issue with your Mageia install. Nothing in the Mint live session prevents one from accessing other drives except permission /encryption issues on other drives.
MikeFinch wrote: Fri May 21, 2021 11:43 pm The executable was developed in Mageia 8 with the code being compiled in W10 for the .exe version.

So, the problem is still there. No worries except that Mint users cannot use the program! Surely there is a solution lurking somewhere? Is it a Mint problem or are the 3 OSs themselves quirky : I think I know the answer! I'm afraid that this problem is the main reason Mint turns me off : don't others have this problem?
Are you asking us if other Mint users are having problems running your program? How many other Mint users have you given it to for them to try?

Other Mint users launch programs from desktop icons without getting errors. I do not know what might be different about your program to be able to give any more feedback.
Image
A woman typing on a laptop with LM20.3 Cinnamon.
User avatar
all41
Level 19
Level 19
Posts: 9525
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: Error exclusive to Mint (Mate) when starting my program

Post by all41 »

In Caja window toolbar Edit/Preferences/Behaviour/Executable Text Files
Make sure executable text is allowed to run.
Also right click the executable and choose Properties/Permissions
and make sure the files is marked executable
Everything in life was difficult before it became easy.
MikeFinch
Level 1
Level 1
Posts: 13
Joined: Mon May 17, 2021 7:29 pm

Re: Error exclusive to Mint (Mate) when starting my program

Post by MikeFinch »

Thakyou again for your responses. I should make things clearer (I hope) with the following.

I have just used Mint to run my program from the File Manager - it runs without that error!

But if I try to run it from a Desktop icon created from "Create launcher . . ." I get the error.

Is there something about "Create launcher" that is causing the problem? Or is it me.

Obviously using desktop icons is more convenient than using the file manager.

MikeFinch
DPM
Level 4
Level 4
Posts: 430
Joined: Thu Sep 24, 2020 9:21 am

Re: Error exclusive to Mint (Mate) when starting my program

Post by DPM »

MikeFinch wrote: Sun May 23, 2021 8:00 pmObviously using desktop icons is more convenient than using the file manager.
Looks like it is an issue with the working directory. What you could do is instead of launching your program directly, you instead launch a bash shell script in your program directory, and that shell script would first set its working directory to whereever it is located:

Code: Select all

#!/bin/bash
cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
./your-program
MikeFinch
Level 1
Level 1
Posts: 13
Joined: Mon May 17, 2021 7:29 pm

Re: Error exclusive to Mint (Mate) when starting my program

Post by MikeFinch »

Thanks DPM > I can only repeat, yet again, that I have no problem using the desktop icon(s) in other OSs!

Seems to be a quirk (bug?) in Mint, which I hope the developers can do something about. Since that topic is above my head I can't say more.

MikeFinch.
MikeFinch
Level 1
Level 1
Posts: 13
Joined: Mon May 17, 2021 7:29 pm

Re: Error exclusive to Mint (Mate) when starting my program

Post by MikeFinch »

[I can't find the draft I made before leaving (HOW DO YOU FIND IT??) - forget how I managed it once before, but it was with great difficulty.]

DPM - further : I have just tried OpenMandriva expecting it to be OK (OM is similar to Mageia).

To my great surprise the error appeared when using both the Link and Copy options for creating the desktop icon.

So it is Mint and OpenMandriva displaying the odd error message. Odd because the pascal code says to display the message when clubnnames.txt is absent but is doing it when the file is actually present in the same folder.

Why on earth do we have this problem??

Tried your script but with my-program at the end of dirname instead of being the third line; the result displayed the error. Both Mint and OpenMandriva run the program OK from the file manager.

PS - I could simply send the files to anyone who wishes to test this anomaly - you only have to ask!!

MikeFinch - more perplexed than ever . . .
DPM
Level 4
Level 4
Posts: 430
Joined: Thu Sep 24, 2020 9:21 am

Re: Error exclusive to Mint (Mate) when starting my program

Post by DPM »

MikeFinch wrote: Mon May 31, 2021 10:10 pmDPM - further : I have just tried OpenMandriva expecting it to be OK (OM is similar to Mageia).
Which desktop? Also Mate? And does that problem also occur with Mint Cinnamon?
Tried your script but with my-program at the end of dirname instead of being the third line; the result displayed the error.
Now that's surprising because it rules out the "wrong working directory" problem. Did you try the temporary test to include the absolute path name in your Pascal code just to see whether that would change anything (not meant as solution ofc)?
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Error exclusive to Mint (Mate) when starting my program

Post by AndyMH »

As a lazarus user, try specifying the full pathname in your code. Debug - modify your code to show the current working directory, see GetCurrentDir.

Code: Select all

begin
  if not FileExists('clubnames.txt') then 
     begin
       showmessage(GetCurrentDir); //or writeln(GetCurrentDir) with the debug window open
       showmessage('clubnames.txt missing!');
       halt;
     end;
end;
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
MikeFinch
Level 1
Level 1
Posts: 13
Joined: Mon May 17, 2021 7:29 pm

Re: Error exclusive to Mint (Mate) when starting my program

Post by MikeFinch »

Thanks DPM and AndyMH >

DPM > yes I still used Mate (don't have Cinnamon installed). The Mint users in my linux group dislike Mate and are always saying "use Cinnamon"!

AndyMH > a very interesting GetCurrentDir suggestion --> first of all some good news; OpenMandriva is OK afterall. I have been spoilt by the fact that in Mageia a simple drag-and-drop from Dolphin to the Desktop and choosing 'Link' works; but not apparently in OM. In the latter I chose 'Link to Application' and it was OK.

Now Mint(Mate) is interesting : using 'Create Launcher' is still creating the error. The first showmessage indicates the directory as '/home/michael' right-justified to the showmessage window edge. The next showmessage is actually wider - this seems to indicate that '/home/michael' is all that is being recognised. I looked at the icon Properties and saw that the (much longer) path is correct (/home/michael/[etc]). So it seems something is going wrong in the Launcher[?].

Can the relevant developer(s) inspect this - if you think Mint is at fault and not me!?

MikeFinch

PS. I should mention the following in case it is important. When compiling my program in the Lazarus Pascal IDE, there are 2 Warnings :

"Compile Project: default, Target: MSPairings: Success, Warnings: 2
[Shreik in Triangle] MSPairings.LPR(50,1) Warning: "crtbeginS.o" not found, this will probably cause a linking failure."
(The second is similar but with "crtendS.o" instead). Interesting, since the last line is "end." on line 38!!
DPM
Level 4
Level 4
Posts: 430
Joined: Thu Sep 24, 2020 9:21 am

Re: Error exclusive to Mint (Mate) when starting my program

Post by DPM »

So the working directory that you get isn't the location of the executable, but the user home directory. In Cinnamon, I don't even have the option of configuring the working directory, only the executable path.

After thinking it through, that behaviour makes sense. Normally, your program would be installed either under /usr/bin/ if installed via the package manager, or you'd put it under /opt/ if it's not in the package manager. In both cases, the user shouldn't even have writing permissions there. On top of that, Linux is a multi-user system so that the same executable could be used by different users.

As for actually storing configuration and data, that should be done via $XDG_DATA_HOME, $XDG_CONFIG_HOME, $XDG_STATE_HOME, or in absence of these environment variables, their default paths - see https://specifications.freedesktop.org/ ... atest.html. In any way, the executable should not just use its own path as reference.
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Error exclusive to Mint (Mate) when starting my program

Post by AndyMH »

Don't know how much lazarus-fu you have, but there is a lazarus forum, helpful, but wouldn't say it is as friendly as the LM forum. While I maybe a level 16 here, I'm very much a junior member on the lazarus forum.

ShowMessage adjusts its width to fit the length of the string it is trying to display. It is the simplest of the message dialogs.
if you think Mint is at fault and not me!?
I'm afraid the fault is yours - not allowing for all the possible conditions.
MSPairings.LPR(50,1) Warning: "crtbeginS.o" not found, this will probably cause a linking failure.
I usually get lots of errors when developing, google is your friend. Best guess - you are missing one of the standard units in your uses clause or a compiler switch.

What is your program trying to do and if not too large, post it.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
MikeFinch
Level 1
Level 1
Posts: 13
Joined: Mon May 17, 2021 7:29 pm

Re: Error exclusive to Mint (Mate) when starting my program

Post by MikeFinch »

I've just spent hours making a reply, only to discover that my post with lots of zip files attached has apparently been lost. I had been logged in and evidenly was no longer. I obviously hadn't noticed.

CAN I RETRIEVE MY POST?

MikeFinch :mrgreen:
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Error exclusive to Mint (Mate) when starting my program

Post by AndyMH »

lots of zip files
One zip file would be helpful, or better, a .tar.gz - this is linux, I'm not going to download and crawl through lots of them.
MSPairings.LPR(50,1)
Guessing - you aren't trying to port across a windows application that uses units only applicable to win?
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Locked

Return to “MATE”