Recent

Author Topic: Lazarus and MacOS  (Read 4733 times)

Seenkao

  • Hero Member
  • *****
  • Posts: 546
    • New ZenGL.
Lazarus and MacOS
« on: September 15, 2020, 03:16:54 pm »
Hello!
Честно говоря, мне уже надоело решать проблемы с Lazarus.

Установил Lazarus на MacOS. Мне нужна работа с OpenGL. Устанавливаю пакет LazOpenGLContext.
Результат = Lazarus отображается как "папка" (для MacOS). Закрываю Lazarus, открываю снова. LazOpenGLContext не установлен.
Получается я не могу ни каких пакетов установить в Lazarus. Как эта проблема решается?

Google translate: To be honest, I'm already tired of solving problems with Lazarus.

Installed Lazarus on MacOS. I need to work with OpenGL. Installing the LazOpenGLContext package.
Result = Lazarus appears as a "folder" (for macOS). I close Lazarus, open it again. LazOpenGLContext is not installed.
It turns out that I cannot install any packages in Lazarus. How is this problem solved?

Update:
Сами пакеты уже прописаны по путям, Lazarus их не видит. Подойдёт способ прописать вручную для определения пакета. (где можно посмотреть?)

google translate:
The packages themselves are already registered in the paths, Lazarus does not see them. A manual way to define the package is fine. (where can you see?)
« Last Edit: September 15, 2020, 03:31:08 pm by Seenkao »
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Lazarus and MacOS
« Reply #1 on: September 15, 2020, 03:51:57 pm »
перенёс в русский раздел, чтобы можно было спокойно материться, без привлечения переводчика xD

вопрос про "Lazarus отображается как "папка"" - отображается в Приложениях?

Основная проблема Лазаруса, что в отличии от других приложений, для установки новых компонентов ему нужно себя перекомпилировать.
Всё бы ничего, в Маке приложения организованы как бандлы - особого вида папка.
После перекомпиляции Лазарус должен скопировать в себя в бандл, в котором он был "установлен".

Если я правильно помню, то установка НЕ использует символьные ссылки (которые помогают избежать явного копирования), а значит свежеиспечённый исполняемый файл нужно скопировать вручную.

Seenkao

  • Hero Member
  • *****
  • Posts: 546
    • New ZenGL.
Re: Lazarus and MacOS
« Reply #2 on: September 15, 2020, 04:00:51 pm »
skalogryz, да решение уже есть, только искать его оказалось очень долго.

https://forum.lazarus.freepascal.org/index.php/topic,47711.0.html

терминал -> open ~/.lazarus/bin/lazarus.app

твою дивизию!!!!! У меня уже матов нет!!!! Я столько времени потерял!!!!

Я ЗАПУСТИЛ ТЕСТОВЫЕ ВЕРСИИ LAZARUS!!! >:D >:( :P

OpenGL работает на Маке, теперь надо всунуть и оставить хотя бы чтоб в LCL-версиях всё работало. На остальное я просто нас..л в пень этот Мак, сможете запустить LCL-приложения и с вас хватит. И так уже матов не хватает на это всё. (хотя думаю ещё не одна проблема выползет при работе с Маком)
« Last Edit: September 15, 2020, 04:05:35 pm by Seenkao »
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Lazarus and MacOS
« Reply #3 on: September 16, 2020, 01:30:39 am »
Простите, что помешал.

Я думаю, проблема в том, что Lazarus не установлен в доступном для записи месте. Когда Lazarus компилируется, он создает новый исполняемый файл в подкаталоге .lazarus вашего домашнего каталога, но когда вы перезапускаете Lazarus в следующий раз, он запускает исходный исполняемый файл.

===

Excuse my interruption.

I think the issue is that Lazarus is not installed in a user writable location. When Lazarus compiles itself it creates a new executable in your home directory .lazarus subdirectory, but when you restart Lazarus the next time it starts the original executable.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Lazarus and MacOS
« Reply #4 on: September 16, 2020, 07:17:27 am »
Excuse my interruption.

I think the issue is that Lazarus is not installed in a user writable location. When Lazarus compiles itself it creates a new executable in your home directory .lazarus subdirectory, but when you restart Lazarus the next time it starts the original executable.
This is exactly what's going on. Seenkao did find his answer.

However, that brings up a bigger issue of the use of Lazarus on macOS.
Technically it's more or less usable if being built from sources.

Installing an application that needs to rebuild/rewrite itself to an unwritable path is an odd approach.
But I must add that Lazarus is quite unique in this sense, as no other application actually tries to modify itself.
In the modern world with the Code Signing, self rewriting applications is something that should be overall avoided.  (And cannot be avoided for Lazarus :( )

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Lazarus and MacOS
« Reply #5 on: September 16, 2020, 08:16:16 am »
I lodged Bug 37753 with a suggestion that Lazarus be installed in /Users/[name]/Applications instead.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Lazarus and MacOS
« Reply #6 on: September 16, 2020, 04:22:58 pm »
I think the issue is that Lazarus is not installed in a user writable location. When Lazarus compiles itself it creates a new executable in your home directory .lazarus subdirectory, but when you restart Lazarus the next time it starts the original executable.

The former is the case on all *nixes (Linux, BSD, etc.) and startlazarus is clever enough to look for a custom Lazarus under ~/.lazarus first, so the problem seems to be: what is different in MacOS that it doesn't do so?


Первый характерен для всех * nix (Linux, BSD и т. Д.), И startlazarus достаточно умен, чтобы сначала искать пользовательский Lazarus в ~/.lazarus, поэтому проблема, похоже, в следующем: чем отличается MacOS от того, чего она не делает?
« Last Edit: September 16, 2020, 04:24:59 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Lazarus and MacOS
« Reply #7 on: September 16, 2020, 08:45:00 pm »
The former is the case on all *nixes (Linux, BSD, etc.) and startlazarus is clever enough to look for a custom Lazarus under ~/.lazarus first, so the problem seems to be: what is different in MacOS that it doesn't do so?
I really don't know about that!
FPC 3.2.0 change the behavior of FileExists() function for Nixes. Prior to Fpc 3.2 it would return TRUE for directories, on FPC 3.2 it returns FALSE. (this has been done for Windows compatibility)

However FileExists() has been used through out the code in Lazarus itself to figure out if bundle directory exists.
Turning all clever code into a pretty dumb and buggy lines... Lazarus IDE was fixed.
And I'm not sure similar fixes are needed for startLazarus. Maybe it does!

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: Lazarus and MacOS
« Reply #8 on: September 16, 2020, 10:01:54 pm »
Startlazarus uses Lazarusmanager unit. It has this code with lot of FileExists-
Code: Pascal  [Select][+][-]
  1. function TLazarusManager.RenameLazarusExecutable(const Directory: string
  2.   ): TModalResult;
  3. var
  4.   NewFilename: String;
  5.   BackupFilename: String;
  6.   CurFilename: String;
  7. begin
  8.   NewFilename:=AppendPathDelim(Directory)+'lazarus.new'+GetExeExt;
  9.   BackupFilename:=AppendPathDelim(Directory)+'lazarus.old'+GetExeExt;
  10.   CurFilename:=AppendPathDelim(Directory)+'lazarus'+GetExeExt;
  11.   if FileExistsUTF8(NewFileName) then
  12.   begin
  13.     if FileExistsUTF8(CurFilename) then
  14.     begin
  15.       if FileExistsUTF8(BackupFileName) then
  16.         if not DeleteFileUTF8(BackupFileName) then begin
  17.           MessageDlg (format('Can''t delete "%s"'+LineEnding+'%s',
  18.             [BackupFileName, SysErrorMessageUTF8(GetLastOSError)]),
  19.             mtError, [mbOK], 0);
  20.           Result := mrAbort;
  21.           exit;
  22.         end;
  23.       if not RenameFileUTF8(CurFilename, BackupFileName) then begin
  24.         MessageDlg (format('Can''t rename "%s" to "%s"'+LineEnding+'%s',
  25.           [CurFilename, BackupFileName, SysErrorMessageUTF8(GetLastOSError)]),
  26.           mtError, [mbOK], 0);
  27.         Result := mrAbort;
  28.         exit;
  29.       end;
  30.       InvalidateFileStateCache;
  31.     end;
  32.     if not RenameFileUTF8(NewFileName, CurFilename) then begin
  33.       MessageDlg (format('Can''t rename "%s" to "%s"'+LineEnding+'%s',
  34.         [NewFileName, CurFilename, SysErrorMessageUTF8(GetLastOSError)]),
  35.         mtError, [mbOK], 0);
  36.       Result := mrAbort;
  37.       exit;
  38.     end;
  39.     InvalidateFileStateCache;
  40.   end;
  41.   Result:=mrOk;
  42. end;
  43.  
  44.  

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Lazarus and MacOS
« Reply #9 on: September 16, 2020, 10:51:39 pm »
in this particular case use of FileExist is appropriate

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: Lazarus and MacOS
« Reply #10 on: September 16, 2020, 11:52:25 pm »
Looked at unix permissions inside lazarus.app.
It has Contents/MacOS/lazarus which is SYMLINK to ../../../lazarus.
My guess: startlazarus rewrites that "lazarus" bad.
Also I am lazy to check how Laz is originally installed- is there the symlink too? what unix permissions?

 

TinyPortal © 2005-2018