Recent

Author Topic: Build failure  (Read 2917 times)

user5

  • Sr. Member
  • ****
  • Posts: 414
Build failure
« on: June 14, 2025, 01:31:05 am »
    I have a Lazarus 1.0.10 program running on a 32-bit computer that I would like to work on in Lazarus 2.2.6 (32/64) on
a 64-bit computer and it loads okay but when I try to compile or build it then I always get the error message shown below
from winlazfileutils.inc.
    Does Create refer to a build in progress or to the creation of a folder? I have tried to research Utf8 and it seems to me
that it refers to text or strings. It also appears that the error occurred because the compiler was unable to create a folder
called Directory5.
    I also noticed that the Online Package Manager includes a checkbox for UTFTools. Is this something I need to check out?
    Am I on the right track here?

Code: Pascal  [Select][+][-]
  1. if Create and not ForceDirectoriesUtf8(Result) then
  2.   raise EInOutError.Create(Format(lrsUnableToCreateConfigDirectoryS,[Result]));
  3.  


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11454
  • Debugger - SynEdit - and more
    • wiki
Re: Build failure
« Reply #1 on: June 14, 2025, 01:41:28 am »
"Create" is a flag, and if true the code will (at runtime) create the folder, if the folder does not exist.


"utf8" is a way to encode text. "Unicode transfer encoding".

Remember the old days? ANSI? If you wanted to process French text you needed a different codepage.

Now we have Unicode. All the chars of all the language in one collection.
Unicode can be stored in "chars" (codepoints) of 32 bits (well most Unicode chars can, some are longer).
But you can also store them on 16 or 8 bit base (and then combine multiple words or bytes to represent a char).

In utf8 the letter "A" is stored as #$41
And the letter "Ä" is stored as 2 bytes #$C3 #$A4

That the code handles Unicode (as utf8) means you do not need to switch codepages if your user uses a different language, and his folder contains special chars.

wp

  • Hero Member
  • *****
  • Posts: 12909
Re: Build failure
« Reply #2 on: June 14, 2025, 01:46:28 am »
The full procedure from which you took this snippet is
Code: Pascal  [Select][+][-]
  1. function GetAppConfigDirUtf8(Global: Boolean; Create: boolean = false): string;
  2. const
  3.   CSIDL_GLOBAL = {$IFDEF WINCE}CSIDL_WINDOWS{$ELSE}CSIDL_COMMON_APPDATA{$ENDIF WINCE};
  4.   CSIDL_LOCAL = {$IFDEF WINCE}CSIDL_APPDATA{$ELSE}CSIDL_LOCAL_APPDATA{$ENDIF};
  5. begin
  6.   If Global then
  7.     Result := SHGetFolderPathUTF8(CSIDL_GLOBAL)
  8.   else
  9.     Result := SHGetFolderPathUTF8(CSIDL_LOCAL);
  10.   If (Result <> '') then
  11.     begin
  12.       if VendorName <> '' then
  13.         Result := AppendPathDelim(Result + VendorName);
  14.       Result := AppendPathDelim(Result + ApplicationName);
  15.     end
  16.   else
  17.     Result := AppendPathDelim(DGetAppConfigDir(Global));
  18.   if Result = '' then exit;
  19.   if Create and not ForceDirectoriesUtf8(Result) then
  20.     raise EInOutError.Create(Format(lrsUnableToCreateConfigDirectoryS,[Result]));
  21. end;
As you can see, "Create" is an argument given to this function. It means: When "Create" is false the function returns the name of the directory in which usually configuration parameters can be stored. When "Create" is true, it also tries to create the directory. If this is not possible (ForceDirectories = false) the EInOutError exception is raised.

Set a breakpoint on the line "if Create and ...", run the program, and when it stops at the breakpoint, move the mouse over the word "Result" - a popup window will tell you the value of the function result. This maybe gives you an idea why this particular directory cannot be created.

user5

  • Sr. Member
  • ****
  • Posts: 414
Re: Build failure
« Reply #3 on: June 14, 2025, 06:20:00 pm »
    I did as you suggested and a popup appeared when the cursor was held over Result but the popup did not
display the value of Result.
    I also selected "Project Options\Additions and Overrides". I tried to compile with and without -dDisableUTF8RTL
but no luck. I also installed UTF8 Tools but I had no luck there either.

user5

  • Sr. Member
  • ****
  • Posts: 414
Re: Build failure
« Reply #4 on: June 14, 2025, 06:34:43 pm »
    I did some research and came across the information below. Do any of them ring a bell? Would supplying a
specific path in Program Options\Paths help at all?
   
    The "Unable to create config directory" error typically arises when an application or program lacks the necessary
permissions to create or write to a configuration directory. This can be due to user account permissions, security
software interference, or incorrect file paths.

    If the application is installed in a restricted location like "Program Files" (Windows) or a similar directory on other
systems, it might lack write access. The program which will not compile with the newest Lazarus version WAS stored
in Program Files on the old computer but this is not the case on the 64-bit computer.

    Double-check the application's configuration settings to confirm the correct path for the configuration directory is specified.

    Check if your antivirus or firewall is blocking the application from creating or accessing the directory.

jamie

  • Hero Member
  • *****
  • Posts: 6991
Re: Build failure
« Reply #5 on: June 14, 2025, 06:43:58 pm »
Place a break point on that give line in the source code that comes up, then run the app
app again and when it breaks there, over the mouse over to the RESULT variable to see what the actual content of it is?

 Maybe it's an in valid directory combination of naming.

Jamie
The only true wisdom is knowing you know nothing

user5

  • Sr. Member
  • ****
  • Posts: 414
Re: Build failure
« Reply #6 on: June 14, 2025, 06:57:16 pm »
    Based on the suggested path options below, can anyone tell me what the path might be for the Utf2 config
DirectoryS and in which path box it should go?
    It seems clear to me that the compiler cannot create the config directory and that is why the error happens.
    I feel like I am close.

    /etc/default/locale: This file often stores system-wide default locale settings, including the UTF-8 configuration.
    /etc/locale.conf: Another common location for locale configuration, particularly on CentOS machines.
    /etc/sysconfig/i18n: For CentOS systems, you can find the i18n file here, where you can configure the default locale to UTF-8.
    ~/.bashrc or ~/.zshrc: These files are used for user-specific locale configurations, especially in setting shell environment
variables like LANG and LC_ALL to en_US.UTF-8.

user5

  • Sr. Member
  • ****
  • Posts: 414
Re: Build failure
« Reply #7 on: June 15, 2025, 03:28:46 am »
    This may be my last post on this thread and subject unless I can get some more guidance.
    The bottom line of this problem is that the program I mentioned compiles fine on an early version of Lazarus
on a Windows XP machine but not a later version on a Windows 10 machine.
    That should be a strong hint of some kind, that a difference between Lazarus versions initiates the problem.
    I plan to eventually donate my work to Lazarus (if they/you want it) so it would be nice to not donate damaged goods.
    I may buy an old Windows XP computer from Walmart to do some experimentation with different Lazarus versions.
    Would it be possible to hire someone to help me on this, perhaps someone extremely familiar with UTF8?
    In any case thank you so much.

n7800

  • Sr. Member
  • ****
  • Posts: 399
Re: Build failure
« Reply #8 on: June 15, 2025, 04:42:07 am »
@wp, @jamie, the author's problem is not with the exception during execution. He gets an error when compiling the program. This is clearly visible in the screenshot in the "original" topic. Apparently, the line with "raise" confused everyone, and all gave advice on the wrong problem...

@user5, this really looks like a problem with your installation, not your program. How exactly did you install it? Did you use the installer from the sourceforge.net? By the way, you do not have to uninstall the previous version, if you set checkbox "Secondary installation".

To confirm that you have problems with the IDE, try to run a test project from the attachment. It simply contains a function call from this unit, with which you have a problem. Tell, does this project run?

dbannon

  • Hero Member
  • *****
  • Posts: 3410
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Build failure
« Reply #9 on: June 15, 2025, 09:49:30 am »
user5, I think you should take a deep breath and start again. Right back to your first post -

    I have a Lazarus 1.0.10 program running on a 32-bit computer that I would like to work on in Lazarus 2.2.6 (32/64) on
a 64-bit computer and it loads okay but when I try to compile or build it then I always get the error message shown below
from winlazfileutils.inc.
Firstly, what operating system are you using, you seem to be quoting both Windows and Linux conventions further down ?

Secondly, no error message is shown, you have pasted what looks like a two line bit of code that might generate an error but no sign of the error message it self. Important aspect, is this error generated when you compile or when you run the app ?

Quote
I have tried to research Utf8 and it seems to me
that it refers to text or strings. It also appears that the error occurred because the compiler was unable to create a folder
called Directory5.

I am pretty sure the compiler was not trying to create a folder ("folder" ? Hmm, Windows ?).  If there is a create folder problem it will happen at run time IMHO.

Depends on whether its a compile time or run time problem. If it generates an error at run time, it will almost certainly be because you are running the app from a place (on your file system) where an app, running with your permissions, cannot write. Perhaps a read only area or an existing directory ?

Alternatively, if its a compile time error, the compiler should give you a meaningful reason for the error. ForceDirectoriesUtf8() is a normal function from the LazFileUtils unit, nothing special about it.  All UTF8 means in this context is to use the version of FoceDirectories() that is capable of writing a dir name containing UTF8 characters.

Please review what you have told us.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

user5

  • Sr. Member
  • ****
  • Posts: 414
Re: Build failure
« Reply #10 on: June 16, 2025, 12:28:18 am »
    I think that my recent downloads have been from the Lazarus site. On the old machine I installed the old Lazarus version
in the Program Files section, which I now know is slightly a no no because I've read that it can cause conflict with Utf8 but
my newest Lazarus compiler is not in the Program section.
    Thanks for stating the fact that I can do a secondary install. I will try it. There is no way on earth that I will uninstall either
of my Lazarus versions unless I have to.
    dbannon, glad to see you again. The program won't run or compile on my Windows 10 machine. From my research I agree
with you that Utf8 is probably not going to create a physical folder as I previously thought.
    I will try to do some things including new installations and we'll see.
    Thanks again. U R an encouragement.

dbannon

  • Hero Member
  • *****
  • Posts: 3410
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Build failure
« Reply #11 on: June 16, 2025, 01:22:20 am »
...The program won't run or compile on my Windows 10 machine. From my research I agree
with you that Utf8 is probably not going to create a physical folder as I previously thought.
Ahh, thats progress.

Just to be really clear, if it does not compile, it cannot possibly run.  So, the problem is a compile problem.

That means the compile process will stop somewhere (on that line of code you quoted ?) and will, in the Messages Window, show a usually meaningful error message. A right click will allow you to copy that (or those) messages, please copy and paste here.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

user5

  • Sr. Member
  • ****
  • Posts: 414
Re: Build failure
« Reply #12 on: June 16, 2025, 01:49:43 am »
    I installed Lazarus 2.0.0RC2 and the necessary components but it didn't work when I tried to compile the program written
on Lazarus 1.0.1.0 though at least the error messages were different: Cannot find Interfaces + other stuff.
    I then tried to install Lazarus 1.0.1.0 on the Windows 10 machine the installer wanted to downgrade my Lazarus 2.2.6.0
installation so I cancelled the installation. I guess that the 1.0.1.0 installed did not have the secondary installation option.
    I'm going to try and find the earliest Lazarus version which includes the secondary installation option and then install it.

    I couldn't copy and paste the compiler messages but I attached a screenshot of them. Thanks again.

user5

  • Sr. Member
  • ****
  • Posts: 414
Re: Build failure
« Reply #13 on: June 16, 2025, 01:59:54 am »
    I forgot to add the contents of the Source Editor which contained a different result that the screenshot shown at the start of this
thread. This message, shown on the Laz .inc page, is shown below.

Code: Pascal  [Select][+][-]
  1. procedure CheckIfFileIsExecutable(const AFilename: string);
  2. begin
  3.   // TProcess does not report, if a program can not be executed
  4.   // to get good error messages consider the OS
  5.   if not FileExistsUTF8(AFilename) then begin
  6.     raise Exception.Create(Format(lrsFileDoesNotExist, [AFilename]));
  7.   end;
  8.   if DirPathExists(AFilename) then begin
  9.     raise Exception.Create(Format(lrsFileIsADirectoryAndNotAnExecutable, [
  10.       AFilename]));
  11.   end;
  12. end;


dseligo

  • Hero Member
  • *****
  • Posts: 1532
Re: Build failure
« Reply #14 on: June 16, 2025, 02:18:35 am »
Can you try to compile attached project (extract it in some new directory)?

Did you try to comment calls to functions in LazFileUtils in your project (such as GetAppConfigDirUtf8) and see if otherwise you can compile project?

 

TinyPortal © 2005-2018