Recent

Author Topic: ERROR (Access Denied) with file handling on Mac OS Catalina  (Read 8219 times)

ENRICO

  • New Member
  • *
  • Posts: 17
ERROR (Access Denied) with file handling on Mac OS Catalina
« on: January 03, 2020, 09:37:08 pm »
Hello, I'm having a problem with saving a file and in general file handling with lazarus on Mac OS Catalina .
The procedure I'm showing works perfectly on Windows, it is from a learning course and it's supposed to work with Mac OS X as well:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.SaveBtnClick(Sender: TObject);
  2. var
  3.    recFile : file of CDRec;
  4.    i       : integer;
  5.    aRec    : CDRec;
  6. begin
  7.    AssignFile(recFile, FILENAME);
  8.    Rewrite(recFile);
  9.    for i := 1 to ARRAYSIZE do
  10.    begin
  11.       { if object variable is nil then save a record with '' or 0 value fields }
  12.       if ObArray[i] = nil then
  13.       begin
  14.         aRec.name := '';
  15.         aRec.artist := '';
  16.         aRec.price := 0.0;
  17.         aRec.cdlabel := '';
  18.       end
  19.       { else map object's fields onto a record and save the record             }
  20.       else
  21.       begin
  22.         aRec.name := ObArray[i].name;
  23.         aRec.artist := ObArray[i].artist;
  24.         aRec.price := ObArray[i].price;
  25.         aRec.cdlabel := ObArray[i].cdlabel;
  26.       end;
  27.         Write(recFile,aRec);
  28.    end;
  29.    CloseFile(recFile);
  30. end;                  

The program saves some record fields to a file, then it loads them with another button.
The code compiles perfectly on mac, but when the program is running and i press the save button, the program crashes and a window appears with this message:
Quote
"Debugger exception Notification:

Project objects2 raised exception class 'EInOutError' with message:
Access denied

At address 1000138A0
(please check the screen attached below).

followed by another window that says access denied. (check screen attached below).
   

                         *** extra information that might help: ***

I think that it's important to mention that every time I make a new application and compile it for the first time, this window appears:
Quote
enable dwarf 2 (-gw)?
the project does not write debug info in dwarf format. The "LLDB debugger (with fpdebug) (Beta)' supports only dwarf

when this window appears, I press Enable Dwarf 3(-gw3) , as recommended by other users in this forum (check screen attached below).

Finally, I checked in the security system/privacy/full disk access and files and folders and I enabled everything related to Lazarus, but it appears to do nothing (check screen attached).


I successfully installed Lazarus on mac OS Catalina following this thread here
https://forum.lazarus.freepascal.org/index.php/topic,47011.0.html
so I don't understand what's wrong.

Please be patient as I'm still learning but I really need to make it work on Mac OS.

Thank you


trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #1 on: January 04, 2020, 08:43:27 am »
Are you sure you're writing the file to the desktop directory?

I tried the following command line application on Catalina and had no issues writing to my desktop:

Code: Pascal  [Select][+][-]
  1. {$mode objfpc}{$H+}
  2.  
  3. Program filewrite;
  4.  
  5. Const Path = 'Hello.txt';
  6.    
  7. Var
  8.   HelloFile:TextFile;
  9.      
  10. begin
  11.   AssignFile(HelloFile,Path);
  12.  
  13.   Try
  14.       Rewrite(HelloFile);
  15.       Writeln(HelloFile,'Hello World!');
  16.   Finally
  17.       CloseFile(HelloFile);
  18.   End;
  19.        
  20. end.
  21.  

Create the filewrite.pas file on the Desktop with the above code, then open a Terminal and:

Code: [Select]
$ cd ~/Desktop
$ fpc filewrite.pas
$ ./filewrite

wittbo

  • Full Member
  • ***
  • Posts: 150
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #2 on: January 06, 2020, 11:07:46 am »
Access denied occurs typically, if your programm does not have write access to the Directory.
You should check:
-  the complete filename including path; does your macOS have write access to this path?
-  is the pathname correct (remember the different pathdelimiters between macos and Windows)?
-  does the specified directory exist?
-wittbo-
MBAir with MacOS 10.14.6 / Lazarus 2.2.4
MacStudio with MacOS 13.0.1 / Lazarus 2.2.4

ENRICO

  • New Member
  • *
  • Posts: 17
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #3 on: February 02, 2020, 10:26:51 pm »
Are you sure you're writing the file to the desktop directory?

I tried the following command line application on Catalina and had no issues writing to my desktop:

Code: Pascal  [Select][+][-]
  1. {$mode objfpc}{$H+}
  2.  
  3. Program filewrite;
  4.  
  5. Const Path = 'Hello.txt';
  6.    
  7. Var
  8.   HelloFile:TextFile;
  9.      
  10. begin
  11.   AssignFile(HelloFile,Path);
  12.  
  13.   Try
  14.       Rewrite(HelloFile);
  15.       Writeln(HelloFile,'Hello World!');
  16.   Finally
  17.       CloseFile(HelloFile);
  18.   End;
  19.  
  20. end.
  21.  

Create the filewrite.pas file on the Desktop with the above code, then open a Terminal and:

Code: [Select]
$ cd ~/Desktop
$ fpc filewrite.pas
$ ./filewrite

Hi, sorry for answering so late...thank you for helping me out!
I tried to follow your advice step by step but the terminal is giving me these messages
Code: [Select]
enricobonetti@Enricos-MacBook-Air ~ % cd ~/Desktop
enricobonetti@Enricos-MacBook-Air Desktop % fpc filewrite.pas
Free Pascal Compiler version 3.0.4 [2019/11/01] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Darwin for x86_64
Compiling filewrite.pas
Fatal: Cannot open file "filewrite.pas"
Fatal: Compilation aborted
Error: /usr/local/bin/ppcx64 returned an error exitcode
enricobonetti@Enricos-MacBook-Air Desktop % ./filewrite
zsh: no such file or directory: ./filewrite
enricobonetti@Enricos-MacBook-Air Desktop %

I don't understand how why it is giving me these fatal errors ...
any suggestion??
thank you

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #4 on: February 04, 2020, 01:07:41 am »
Hi, sorry for answering so late...thank you for helping me out!
I tried to follow your advice step by step but the terminal is giving me these messages
Code: [Select]
enricobonetti@Enricos-MacBook-Air ~ % cd ~/Desktop
enricobonetti@Enricos-MacBook-Air Desktop % fpc filewrite.pas
Free Pascal Compiler version 3.0.4 [2019/11/01] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Darwin for x86_64
Compiling filewrite.pas
Fatal: Cannot open file "filewrite.pas"
Fatal: Compilation aborted
Error: /usr/local/bin/ppcx64 returned an error exitcode
enricobonetti@Enricos-MacBook-Air Desktop % ./filewrite
zsh: no such file or directory: ./filewrite
enricobonetti@Enricos-MacBook-Air Desktop %

I don't understand how why it is giving me these fatal errors ...
any suggestion??
thank you

You did create the filewrite.pas file in your desktop folder, yes? If not, please do so.

ENRICO

  • New Member
  • *
  • Posts: 17
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #5 on: February 04, 2020, 10:14:24 pm »
Hi, sorry for answering so late...thank you for helping me out!
I tried to follow your advice step by step but the terminal is giving me these messages
Code: [Select]
enricobonetti@Enricos-MacBook-Air ~ % cd ~/Desktop
enricobonetti@Enricos-MacBook-Air Desktop % fpc filewrite.pas
Free Pascal Compiler version 3.0.4 [2019/11/01] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Darwin for x86_64
Compiling filewrite.pas
Fatal: Cannot open file "filewrite.pas"
Fatal: Compilation aborted
Error: /usr/local/bin/ppcx64 returned an error exitcode
enricobonetti@Enricos-MacBook-Air Desktop % ./filewrite
zsh: no such file or directory: ./filewrite
enricobonetti@Enricos-MacBook-Air Desktop %

I don't understand how why it is giving me these fatal errors ...
any suggestion??
thank you

You did create the filewrite.pas file in your desktop folder, yes? If not, please do so.

yes I did! see pic attached

dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #6 on: February 04, 2020, 11:14:08 pm »
Enrico, while still cd'ed in the Desktop in that terminal, please type -

pwd [enter]
ls -la filewrite.pas [enter]

and post an image of what you get.

Davo
« Last Edit: February 04, 2020, 11:38:39 pm by dbannon »
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

ENRICO

  • New Member
  • *
  • Posts: 17
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #7 on: February 05, 2020, 01:37:57 pm »
I noticed I did something wrong, sorry I'm a newbie!
when I created the program filewrite, I saved it as Project1.pas... that's why the terminal couldn't find the filewrite.pas.


I deleted everything and remade the (simple program) filewrite program, saved on the desktop this time with filewrite.pas

I inserted in the terminal the following lines suggested by Trev
Code: [Select]
$ cd ~/Desktop
$ fpc filewrite.pas
$ ./filewrite

this gave a different result: (see pic attached)
Code: [Select]
enricobonetti@Enricos-MacBook-Air ~ % cd ~/Desktop
enricobonetti@Enricos-MacBook-Air Desktop % fpc filewrite.pas
Free Pascal Compiler version 3.0.4 [2019/11/01] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Darwin for x86_64
Compiling filewrite.pas
Assembling (pipe) filewrite.s
Linking filewrite
21 lines compiled, 0.2 sec
enricobonetti@Enricos-MacBook-Air Desktop % ./filewrite

yet, when I click run and build the program, I still receive this bug message (check pic attached)

the program I created is a "simple program".

Then, I typed in the terminal commands line given by Davo:
pwd [enter]
ls -la filewrite.pas [enter]

this is what the terminal shows:
Code: [Select]
enricobonetti@Enricos-MacBook-Air Desktop % pwd
/Users/enricobonetti/Desktop
enricobonetti@Enricos-MacBook-Air Desktop % ls -la filewrite.pas
-rw-r--r--@ 1 enricobonetti  staff  257  5 Feb 13:14 filewrite.pas
enricobonetti@Enricos-MacBook-Air Desktop %

Enrico



dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #8 on: February 06, 2020, 12:31:00 am »
Hmm, a bit of confusion here Enrico.

First, lets concentrate on building and running Trev's little test program.

You got that compile (after changing its name to filewrite.pas.   You then ran the a program with the command -

Code: Pascal  [Select][+][-]
  1. ./filewrite [enter]

If that worked as it should, it would have created a file, on your desktop, called Hello.txt.

Now, you used the command I suggested, ie "ls -la filewrite.pas" but that was for when we were looking for the missing source file, filewrite.pas.   Now you are looking for Hello.txt.   So, lets be really general, now type -

Code: Pascal  [Select][+][-]
  1. ls -l [enter]

That will list all the files in that directory, you should see writefile.pas (the source code), writefile (the executable binary) and hopefully Hello.txt, and others I'd expect.  If Hello.txt is there, you could 'cat' it out to see contents -

Code: Pascal  [Select][+][-]
  1. cat Hello.txt [enter]

and you should see a cheery 'hellow world'.

That would prove that fpc programmes have no problems writing to your desktop directory.

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

ENRICO

  • New Member
  • *
  • Posts: 17
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #9 on: February 06, 2020, 01:01:52 am »
Hmm, a bit of confusion here Enrico.
I'd say a lot!! but now everything is clear.. thank you Davo for your patience.

The text file is on my desktop and I successfully created the directory.. which is great!

Now I'm trying to create the directory for the CD program that is on another folder.
I typed the complete address of the folder on the terminal
Code: [Select]
cd ~/Desktop/program/COOLPROGRAMS/CDPLAYER
and I got at the right location, this is what the terminal showed me:
Code: [Select]
enricobonetti@Enricos-MacBook-Air CDPLAYER %
then I added
Code: [Select]
fpc unit1.paswhich is the name of the unit of the program. Here I encountered this error:
Code: [Select]
Free Pascal Compiler version 3.0.4 [2019/11/01] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Darwin for x86_64
Compiling unit1.pas
unit1.pas(8,22) Fatal: Can't find unit FileUtil used by Unit1
Fatal: Compilation aborted
Error: /usr/local/bin/ppcx64 returned an error exitcode

I don't understand why it "Can't find unit FileUtil used by Unit1" ?

Enrico

dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #10 on: February 06, 2020, 06:58:08 am »
Quote
I don't understand why it "Can't find unit FileUtil used by Unit1" ?

FileUtil is a Lazarus unit and if you build using the fpc command, you will need to tell fpc where to find your Lazarus units. 

Not hard but I suggest you will find it easier to build from within Lazarus and let Lazarus look after all that for you. But there is an alternative, the lazbuild command might just help you here, not sure.

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

ENRICO

  • New Member
  • *
  • Posts: 17
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #11 on: February 07, 2020, 03:56:21 pm »
FileUtil is a Lazarus unit and if you build using the fpc command, you will need to tell fpc where to find your Lazarus units.

I'm trying to access to the folder containing the fileutils unit, to tell fpc where to find the lazarus unit but i can't even access that, this message appears

Code: [Select]
Last login: Thu Feb  6 01:03:08 on ttys000
enricobonetti@Enricos-Air ~ % cd ~/Library
enricobonetti@Enricos-Air Library % cd ~/Library/Lazarus/components/lazutils
cd: no such file or directory: /Users/enricobonetti/Library/Lazarus/components/lazutils
enricobonetti@Enricos-Air Library %


Quote
Not hard but I suggest you will find it easier to build from within Lazarus and let Lazarus look after all that for you.
I'm not sure what you mean by build from within lazarus, i've opened the program with lazarus and press build, but nothing really changed.I've also tried "clean up and build project' but an error message appear saying it's not able to delete the file lazutils

Quote
But there is an alternative, the lazbuild command might just help you here, not sure.

i tried this but it don't see anything that could help me, or at least i think :/
Code: Pascal  [Select][+][-]
  1. lazbuild [options] <project/package filename or package name>
  2.  
  3. Parameters:
  4.  
  5. --help or -?
  6.                       this help message
  7. -B or --build-all
  8.                       build all files of project/package/IDE
  9. -r or --recursive
  10.                       apply build flags (-B) to dependencies too
  11. -d or --skip-dependencies
  12.                       do not compile dependencies
  13. --build-ide=<options>
  14.                       build IDE with packages
  15. -v or --version
  16.                       show version and exit
  17. -q or --quiet
  18.                       be less verbose, can be given multiple times
  19.                       Passing quiet two times, will pass
  20.                       -vw-n-h-i-l-d-u-t-p-c-x- to the compiler
  21. --verbose
  22.                       be more verbose, can be given multiple times
  23. --verbose-pkgsearch
  24.                       Write what package files are searched and found
  25.  
  26. --add-package
  27.                       add package(s) to list of installed packages
  28.                       (combine with --build-ide to rebuild IDE).
  29. --add-package-link=<.lpk file>
  30.                       Only register the Lazarus package files (.lpk). Do
  31.                       not build.
  32. --create-makefile
  33.                       Instead of compile package create a simple Makefile.
  34.  
  35. --primary-config-path=<path>
  36. or --pcp=<path>
  37.                       primary config directory where Lazarus stores its
  38.                       config files. Default is
  39.                       /Users/enricobonetti/.lazarus
  40.  
  41. --secondary-config-path=<path>
  42. or --scp=<path>
  43.                       secondary config directory where Lazarus searches
  44.                       for config template files. Default is /etc/lazarus
  45.  
  46. --operating-system=<operating-system>
  47. or --os=<operating-system>
  48.                       override the project operating system. e.g. win32
  49.                       linux. default: darwin
  50.  
  51. --widgetset=<widgetset>
  52. or --ws=<widgetset>
  53.                       override the project widgetset. e.g. gtk gtk2 qt
  54.                       win32 carbon. default: carbon
  55.  
  56. --cpu=<cpu>
  57.                       override the project cpu. e.g. i386 x86_64 powerpc
  58.                       powerpc_64 etc. default: x86_64
  59.  
  60. --build-mode=<project/ide build mode>
  61. or --bm=<project/ide build mode>
  62.                       override the project or IDE build mode.
  63.  
  64. --compiler=<ppcXXX>
  65.                       override the default compiler. e.g. ppc386 ppcx64
  66.                       ppcppc etc. default is stored in
  67.                       environmentoptions.xml
  68.  
  69. --language=
  70.                       Override language. For example --language=de. For
  71.                       possible values see files in the languages directory.
  72.  
  73. --lazarusdir=<Lazarus directory>
  74.                       directory to be used as a basedirectory
  75.  
  76. --max-process-count=<count>
  77.                       Maximum number of threads for compiling in
  78.                       parallel. Default is 0 which guesses the number of
  79.                       cores in the system.
  80.  
  81. --no-write-project
  82.                       Do not write updated project info file after build.
  83.                       If not specified, build number will be incremented
  84.                       if configured.
  85.  
  86. enricobonetti@Enricos-Air Library %
  87.  

I really don't know what to do, I've googled how to do the things you told me but I can't actually find/implement them... I'm such a beginner in this field.  :(

Enrico

dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #12 on: February 08, 2020, 11:26:26 am »
OK, Enrico, lets get this clear.  Earlier Trev showed you some code that you built with fpc, it was to test that there was no problem with you writing to your Desktop. 

I got the impression that you are building another bit of source, something that uses FileUtils the same way. You said -
Quote
then I added

fpc unit1.pas

which is the name of the unit of the program. Here I encountered this error:

Free Pascal Compiler version 3.0.4 [2019/11/01] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Darwin for x86_64
Compiling unit1.pas
unit1.pas(8,22) Fatal: Can't find unit FileUtil used by Unit1
Fatal: Compilation aborted
Error: /usr/local/bin/ppcx64 returned an error exitcode


I don't understand why it "Can't find unit FileUtil used by Unit1" ?

That sounds, to me that you are building that source with fpc on the command line, not Lazarus within the IDE.

Lazarus provides the IDE (Integrated Development Env) and, importantly a whole lot of (mostly) GUI libraries or units in pascal speak.  When you use Lazarus, it adds the paths to all those extra units and when you build, the pretty complicated command line to fpc is all organised for you.

If you are using the Lazarus IDE, you might be building a GUI app and you will be telling the Lazarus IDE where all the thing you need are and, when you press the green triangle, Lazarus will put all that info together to do the building.

Sorry that was so long winded but it sounds to me that there is some confusion about what we are talking about !  If I still have it wrong, please say so, I'll be no use to you unless I understand what you are doing.

Code: [Select]
enricobonetti@Enricos-Air Library % cd ~/Library/Lazarus/components/lazutils
cd: no such file or directory: /Users/enricobonetti/Library/Lazarus/components/lazutils

Hmm, are you sure that is where the units should be ?   I am sorry, currently travelling and don't have my mac with me so cannot see where mine are.  But if you think that where you expect them, try moving up the line a bit and see, for example if ~/Library is there, next, see if ~/Library/Lazarus and so on, will expose a typo.

From within Lazarus, you can go to Tools->Options and the field labeled "Lazarus Directory (default for all projects)" is the one that should point to the directory that has the "components/lazutils/" directory, the one you are looking for.

If Lazarus has an entry for that field, "Lazarus Directory (default for all projects)" that is not really there, it sure won't work. It could be that you have accidentally changed that field or maybe installed Lazarus somewhere else.  In either case, that setting must point to where the content really is.

Davo

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

ENRICO

  • New Member
  • *
  • Posts: 17
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #13 on: February 09, 2020, 03:52:19 pm »

That sounds, to me that you are building that source with fpc on the command line, not Lazarus within the IDE.

Lazarus provides the IDE (Integrated Development Env) and, importantly a whole lot of (mostly) GUI libraries or units in pascal speak.  When you use Lazarus, it adds the paths to all those extra units and when you build, the pretty complicated command line to fpc is all organised for you.

If you are using the Lazarus IDE, you might be building a GUI app and you will be telling the Lazarus IDE where all the thing you need are and, when you press the green triangle, Lazarus will put all that info together to do the building.

Sorry that was so long winded but it sounds to me that there is some confusion about what we are talking about !  If I still have it wrong, please say so, I'll be no use to you unless I understand what you are doing.
thank you very much for this explanation, i really appreciate you taking the time for writing me all of this!

Quote
When you use Lazarus, it adds the paths to all those extra units and when you build, the pretty complicated command line to fpc is all organised for you.
that's why I'm so confused... if I run the program and lazarus takes care of grouping all the info for me, then why am I having these problems with writing/reading files?


Quote
Code: [Select]
enricobonetti@Enricos-Air Library % cd ~/Library/Lazarus/components/lazutils
cd: no such file or directory: /Users/enricobonetti/Library/Lazarus/components/lazutils

Hmm, are you sure that is where the units should be ?   I am sorry, currently travelling and don't have my mac with me so cannot see where mine are.  But if you think that where you expect them, try moving up the line a bit and see, for example if ~/Library is there, next, see if ~/Library/Lazarus and so on, will expose a typo.

From within Lazarus, you can go to Tools->Options and the field labeled "Lazarus Directory (default for all projects)" is the one that should point to the directory that has the "components/lazutils/" directory, the one you are looking for.

i tried to search  ~/Library and i found it, then i tried with ~/Library/Lazarus but i can't find it. I opened lazarus and went to Tools->Options and the field labeled "Lazarus Directory (default for all projects)" and the entry field is /Library/Lazarus/ (i attached a screen of it).

I'm thinking that maybe i did something wrong when I installed lazarus, since in macOS catalina is not easy to do it properly.









dbannon

  • Hero Member
  • *****
  • Posts: 2778
    • tomboy-ng, a rewrite of the classic Tomboy
Re: ERROR (Access Denied) with file handling on Mac OS Catalina
« Reply #14 on: February 10, 2020, 01:25:26 am »
thank you very much for this explanation, i really appreciate you taking the time for writing me all of this!
I had a heap of help when I first started here and i still get a lot help, thats how it works here !

Quote
.. if I run the program and lazarus takes care of grouping all the info for me, then why am I having these problems with writing/reading files?

Easy to confuse two different issues. Firstly, failure to compile and secondly, failure at run time.    The compiler options, all those settings that Lazarus should be doing for you are mainly about the first. If the compiler can find all the things you need and make sense of your code, it will compile.  But that does not necessarily mean your code will do what you want, thats where run time errors come in to play.

Going back to your original problem, top of this thread, I understand you had a program that built (or compiled) OK but failed (to write a file on the desktop) at run time ?


Quote
i tried to search  ~/Library and i found it, then i tried with ~/Library/Lazarus but i can't find it. I opened lazarus and went to Tools->Options and the field labeled "Lazarus Directory (default for all projects)" and the entry field is /Library/Lazarus/ (i attached a screen of it). I'm thinking that maybe i did something wrong when I installed lazarus, since in macOS catalina is not easy to do it properly.

I think its OK for Lazarus to be in either location although its definitely not something I am sure of because I download source and build my own Lazarus so, even on the Mac I can put it where I like.   But what is important is that the Lazarus setting "Lazarus Directory (default for all projects)" must point to where it is really is installed !  So, I don't think you have done it wrong, just maybe different. And, as you say, Catalina is getting a reputation for being quite fussy !

So, use the Finder or a command line of "ls -la /Library/Lazarus" to make sure its there, if it is, then that all you need do. If that setting is right, Lazarus will fill in the compiler options and if you add "uses FileUtil" to your code, will let you browse to that unit from within Lazarus.  Now, your code should compile.  If not, we need to look at the compile error messages.

Hmm, a distraction that might do more harm than good but I will mention it anyway. LazFileUtils may be preferable to using FileUtil, it is better at UTF8. Its generally a drop in replacement. Note that LazFileUtils has an 's' at the end, FileUtil does not.

 We are pretty sure there is no OS linked issue writing a file to your desktop.

Davo


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

 

TinyPortal © 2005-2018