unit not found (StdCtrls) lazarus / 21-General ---------------------------------------------------------------------- munair · 2023-09-14 11:47 In a project with multiple forms and units, I added a new form and tried to add the event Onshow from the Events tab. An error message appeared saying "unit not found: StdCtrls". I checked the paths and other form units. StdCtrls is in the uses clause of every form and the paths are the same. I did not change any path, nor added any package, so this error was strange, especially because I was able to compile and run the project. So I figured, what would happen if I change the uses clause by moving StdCtrls from the end of the list. That did the trick and I could add the OnShow event. This looks like a bug. Error: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls; No error: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  Classes, SysUtils, StdCtrls, Forms, Controls, Graphics, Dialogs; This is the first time I run into this error. I use Lazarus 2.2.6 on Debian Linux 12. The error so far only occurred when trying to add an event. ---------------------------------------------------------------------- GAN · 2023-09-15 02:38 It is not a bug, the units are loaded (or initialized) from right to left. ---------------------------------------------------------------------- PascalDragon · 2023-09-17 16:05 Quote from: GAN on September 15, 2023, 04:38:12 amIt is not a bug, the units are loaded (or initialized) from right to left. This is about the IDE, not the compiler. And there might indeed be a bug regarding this. Quote from: munair on September 14, 2023, 01:47:53 pmIn a project with multiple forms and units, I added a new form and tried to add the event Onshow from the Events tab. An error message appeared saying "unit not found: StdCtrls". I checked the paths and other form units. StdCtrls is in the uses clause of every form and the paths are the same. I did not change any path, nor added any package, so this error was strange, especially because I was able to compile and run the project. So I figured, what would happen if I change the uses clause by moving StdCtrls from the end of the list. That did the trick and I could add the OnShow event. This looks like a bug. Can you provide a small, self contained test project that shows the issue and then create a bug report for that? ---------------------------------------------------------------------- munair · 2023-09-19 15:08 Quote from: PascalDragon on September 17, 2023, 06:05:59 pmCan you provide a small, self contained test project that shows the issue and then create a bug report for that? With small test projects I have not been able to reproduce this behaviour yet. I will do more tests and get back here when I run into this issue again. ---------------------------------------------------------------------- TRon · 2023-09-20 05:11 I just ran into a similar situation that the order of the units was messed up which resulted in the compiler throwing the error (3.0RC1). Just like munair I seem unable to reproduce but can say I was experimenting with NOGUI and console application using a datamodule (with a non visual component). It is strange because I can't remember having ran into that before. 2 cents. ---------------------------------------------------------------------- munair · 2023-10-01 08:55 This error/problem is tied into Codetools. What I have found from the IDE behavior so far is that when I start the IDE, open the project and try to find a variable definition from the context menu -> [Find Declaration of ... Alt+Up], no error pops up. Then, after I run/stop the project (debug disabled) and repeat the context menu procedure, Codetools throws an error that a unit was not found. The units "not found" so far are StdCtrls and Clipbrd, but they may be arbitrary. Same behavior is observed with adding control events, as I described earlier; after starting the IDE and opening the project, adding events (by double clicking the control on the form) works fine. After running the project, the same error is thrown. Despite the error, I can run and build the project. But Codetools makes editing the project cumbersome and adding events no longer works. ---------------------------------------------------------------------- munair · 2023-10-01 10:30 There is no difference in behavior after running or building the project. Either way path definitions seem to be messed up. ---------------------------------------------------------------------- cdbc · 2023-10-01 12:03 Hi I had that exact problem once, it was a PITFA! I even stood on my head before the laptop, ...nothing seemed to cure it. It turned out to be a deeply buried "double free" in my code(not fpc/lazarus). At the point, where I found it, my code was riddled(nothing else than) with "try-except LogLn; end" I even changed parts of the LCL, hunting it down... What I'm saying is, it can be a teensy-weensy-tiny bit, that only shows its ugly head on spurious occasions, that tips the wagon. So, it's time to go hunting and preferably show us the entire code, if possible. Regards Benny ---------------------------------------------------------------------- d7_2_laz · 2023-10-01 13:17 I'd sporadically (but not reproduceable) encountered the same (Laz. 3.0RC1 win x64), especially when i had - without having changed anything else - introduced into my form's unit something like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TEdit = class(StdCtrls.TEdit)   procedure WMEraseBkgnd(var Message: TLMEraseBkgnd); message LM_ERASEBKGND;  end;for to expose a message. Compiler complaint: unit StdCtrls not found ... Surprise ... the unit had uses: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,  ComCtrls, StdCtrls,   ... and others ....  After having changed dummy-wise the "StdCtrls.TEdit" to some other unit qualifier a couple of times and back to StdCtrls again, finally it had been accepted ... ---------------------------------------------------------------------- munair · 2023-10-01 13:32 So far, my particular case seems to be limited to Linux (Lazarus 2.2.6 on Debian 12 x64). There is no problem when I edit/run/build the same project with Lazarus 2.2.0 on Windows 7 x64. I will try Lazarus 2.2.6 on W7 as well. ---------------------------------------------------------------------- munair · 2023-10-01 14:05 It looks like - at least on Linux - the Lazarus IDE/Codetools has difficulty with the order of units in the uses clause. When I place e.g. Clipbrd between my own custom units, the error as described earlier pops up. When I place Clipbrd between the Lazarus units (and all other Lazarus units in the uses clause precede all custom units) no error occurs. I have not yet observed this behavior on Windows. ---------------------------------------------------------------------- sfeinst · 2023-10-11 23:45 I have this same issue.  Running Debian Bookworm.  Lazarus is 2.2.6+dfsg2-2.  In my case, moving items around the uses clause doesn't seem to solve the problem.  At some point (it varies when it will hit), I can't change control names or double-click an event in the object inspector to tie a procedure to the event.  My only option is to close Lazarus and start it back up.  Then I'm good to go for a while before it happens again.  I'm starting to wonder if it is Debian's build of Lazarus and I should download debs from the Lazarus download page. Haven't tried this yet since I'm in the middle of coding, didn't want to interrupt my setup.  But these constant restarts are getting old. ---------------------------------------------------------------------- arneolav · 2023-12-26 17:40 Run into this issue, Rasberry, Debian Bookworm.  Lazarus is 2.2.6+dfsg2-2. Drop a button, in events OnClick, message: unit not found (StdCtrls) On new started IDE this does work, but problem raised after some work and/or compile. To get around, tried install Lazarus 3.0. Due to an error in fpcupdeluxe this was not possible: https://forum.lazarus.freepascal.org/index.php/topic,65642.0.html ---------------------------------------------------------------------- sfeinst · 2023-12-27 13:35 I have had this issue.  I downloaded source and built lazarus, problem went away.  Could be a bug in version debian used, or maybe because source is in a writable directory now.  No idea.  But building from source helped me. ---------------------------------------------------------------------- DuVoL · 2025-01-08 19:29 Had this problem for a LONG time with Lazarus 2.... and now 3.0 on Linux Mint Cinnamon with Lazarus installed from the Linux Mint software manager. Eventually took ownership of /usr/lib/lazarus using sudo chown -R username:username /usr/lib/lazarus. The problem stopped completely. Will still play with ownership / group settings to see if there is better way to address the access rights ---------------------------------------------------------------------- VisualLab · 2025-01-08 20:42 Quote from: DuVoL on January 08, 2025, 08:29:37 pmHad this problem for a LONG time with Lazarus 2.... and now 3.0 on Linux Mint Cinnamon with Lazarus installed from the Linux Mint software manager. Eventually took ownership of /usr/lib/lazarus using sudo chown -R username:username /usr/lib/lazarus. The problem stopped completely. Will still play with ownership / group settings to see if there is better way to address the access rights There is nothing better than being a brazen "godless of the Church of Saint Penguin" And this is done by: unlocking the root account in the GUI (only once),logging into the GUI as root (all the time).It works great. No need to do any "crazy sudo-f..g on the keyboard" every 2 minutes Of course, on a computer intended for experimentation (not on a server, nor a computer at work). Lazarus served from the official Debian repositories is quite old. It's better to install DEB packages from the Lazarus creators, e.g. from Lazarus Files. I installed them 2 weeks ago in Kubuntu 24.04 (version: Lazarus 4.0 RC1 for AMD64). It works without problems. P.S. Where have the former times of freedom of action in Linux gone? Back then I was mainly using various Red Hats and derivatives. You could change everything as you wanted (yes, the system was more clumsy on a desktop back then). But no nosy gendarme, oprichnik, hunweibin or other chekist tried to block various things in the system with idiotic scripts, as it is now (especially in Deb(il)ian and derivatives). They accuse MS of imposing various artificial restrictions, and they themselves do it in Linux, hypocrites. ---------------------------------------------------------------------- munair · 2025-05-10 07:36 I have not run into this issue since I use Lazarus 3.2 on Debian 12. ---------------------------------------------------------------------- JD · 2025-05-10 15:46 Quote from: VisualLab on January 08, 2025, 09:42:40 pmP.S. Where have the former times of freedom of action in Linux gone? Back then I was mainly using various Red Hats and derivatives. You could change everything as you wanted (yes, the system was more clumsy on a desktop back then). But no nosy gendarme, oprichnik, hunweibin or other chekist tried to block various things in the system with idiotic scripts, as it is now (especially in Deb(il)ian and derivatives). They accuse MS of imposing various artificial restrictions, and they themselves do it in Linux, hypocrites.   I'm curious to know what you think of immutable distros like VanillaOS and others like it. https://www.ubuntupit.com/immutable-linux-distributions/ ---------------------------------------------------------------------- TRon · 2025-05-10 15:58 Quote from: VisualLab on January 08, 2025, 09:42:40 pmQuote from: DuVoL on January 08, 2025, 08:29:37 pmHad this problem for a LONG time with Lazarus 2.... and now 3.0 on Linux Mint Cinnamon with Lazarus installed from the Linux Mint software manager. Eventually took ownership of /usr/lib/lazarus using sudo chown -R username:username /usr/lib/lazarus. The problem stopped completely. Will still play with ownership / group settings to see if there is better way to address the access rights There is nothing better than being a brazen "godless of the Church of Saint Penguin" And this is done by: unlocking the root account in the GUI (only once),logging into the GUI as root (all the time).It works great. No need to do any "crazy sudo-f..g on the keyboard" every 2 minutes Of course, on a computer intended for experimentation (not on a server, nor a computer at work). also not on any machine for experiments. Even stronger, especially not on a machine for experiments exactly because ... experimental (meaning more chance to mess up)  One of the more correct ways of doing it is creating a separate group that allow r/w access to lazarus folder (and yes, taking ownership does the same thing but does not so for all users) and making "developers that are allowed to use lazarus" a member of that group. Running as root is a no-go, not on any platform that supports using different access rights. QuoteP.S. Where have the former times of freedom of action in Linux gone? It always was this way if you setup Linux as intended. As comparison the days that you can run windows with admin account in order to circumvent all issues is also long gone (and for the ones that believe it works perfect, please keep on doing so as you are not the target of this remark so, please keep sharing). There is no good reason whatsoever to advertise the "take all access rights behaviour" because it makes life easier. That is how the world of (not) computing got into all this mess in the first place. On the other hand people don't seem to care at all any more these days, so why bother with linux at all: just install chromeOS and/or android and be gone with any privacy at all (hello and goodbye m$) But I understand that access rights and how to deal with them properly is not a happy place topic so the other workaround is to install in user-space and not bother at all with any ownership/access rights whatsoever. 2 cents, PS: the correct solution would ofc be for this issue to be fixed but it seem to be a difficult one to reproduce with a simple and consistent example. ---------------------------------------------------------------------- Thaddy · 2025-05-10 20:15 Quote from: TRon on May 10, 2025, 05:58:30 pmPS: the correct solution would ofc be for this issue to be fixed but it seem to be a difficult one to reproduce with a simple and consistent example. Which in 99% of the cases means the questioner screwed up and possibly in 1% of the cases it is a real issue. You have to be firm with children. You think the same. Be blunt. A bodged install caused by a bodged uninstall from a previous version.