Recent

Author Topic: Lazarus 2.0.12 doesn't load project passed as parameter  (Read 3933 times)

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Lazarus 2.0.12 doesn't load project passed as parameter
« on: March 10, 2021, 04:45:55 pm »
I've got a utility to start lazarus passing to it different PCPs depending on several conditions (where the project is located, its name, etc). It ends up calling startlazarus on a button click with:
Code: Pascal  [Select][+][-]
  1.  {Base version with just "normal" and "test" configs}
  2. procedure TMainForm.OKButtonClick(Sender: TObject);
  3. const
  4.   NL = LineEnding; {pure laziness: Less typing}
  5.   basecmd = '--nsc' + NL + '--skip-last-project';
  6.   stdcmd  = basecmd + NL + '%s';
  7.   pcpcmd  = basecmd + NL + '--pcp=%s' + NL + '%s';
  8.   PCP = 2;{--> Ignore these;}
  9.   PRJ = 3;{-/  they are not used here}
  10. var
  11.   cfgpath, project: String;
  12. begin
  13.   {lbProjects is a list box with absolute paths to .lpi file(s)}
  14.   project := lbProjects.Items[lbProjects.ItemIndex];
  15.   if LowerCase(project).Contains('test')
  16.   and (rgConfigPath.ItemIndex = 0) then {rgConfigPath: radiogroup to select PCP}
  17.     case MessageDlg(sTest, sUseAltConfig, mtWarning, mbYesNoCancel, 0) of
  18.     mrYes: rgConfigPath.ItemIndex := 1;
  19.     mrCancel: Exit;
  20.     end;
  21.   {const CfgPaths: array [0..1] of String = ('', '~/.lazbis/');}
  22.   cfgpath := CfgPaths[rgConfigPath.ItemIndex];
  23.   with Process do begin {TProcess}
  24.     {startlazarus is set elsewhere to:
  25.      FindDefaultExecutablePath('startlazarus');}    
  26.     Executable := startlazarus;
  27.     Options := [poNoConsole];
  28.     if cfgpath <> '' then
  29.       Parameters.Text := Format(pcpcmd, [cfgpath, project])
  30.     else
  31.       Parameters.Text := Format(stdcmd, [project]);
  32.     Execute;
  33.   end;
  34.   Close;
  35. end;

This has worked well for several versions of Lazarus until now: with Lazarus 2.0.12 all seems to go right but Lazarus starts with either an empty new project or the "no project" dialog, depending on whether it was exited with a project loaded (which is logical, given the --skip-last-project), but doesn't open the project passed as parameter.

To test what was happening I've tried launching startlazarus with hand-built command lines, e.g.:
Code: [Select]
startlazarus --nsc --skip-last-project ./sendtolaz.lpi
startlazarus ./sendtolaz.lpi
and it doesn't work as it should either; it does as my program: empty project or no-project dialog. It looks as if Lazarus were ignoring (or not receiving) the passed project to open.

So, the question(s)
Does someone knows what's happening?
Has something changed or is it a bug in the new release?
Or am I doing something wrong?
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.

ASBzone

  • Hero Member
  • *****
  • Posts: 614
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
Re: Lazarus 2.0.12 doesn't load project passed as parameter
« Reply #1 on: March 10, 2021, 06:04:39 pm »
I've never tried to start it this way before, so I have no baseline to compare it with, but I can attest that it does *not* work running Lazarus 2.0.11 r64280 on Windows 10 x64

It brings up the app I was previously working on, when using either StartLazarus.exe or Lazarus.exe from the command-line.

My build is from FPCupDeluxe (last updated in January)
-ASB: https://www.BrainWaveCC.com/

Lazarus v2.0.13 r64843 / FPC v3.2.1-r49055 (via FpcUpDeluxe) -- Windows 64-bit install w/Win32 and Linux/Arm cross-compiles
Primary System: Windows 10 Pro x64, Version 2009 (Build 19042)
Other Systems: Windows 10 Pro x64, Version 2009 (Build 19042) or greater

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Lazarus 2.0.12 doesn't load project passed as parameter
« Reply #2 on: March 10, 2021, 06:54:59 pm »
It brings up the app I was previously working on, when using either StartLazarus.exe or Lazarus.exe from the command-line.

Yes, that's the behaviour I see but, curiously enough, I just tested launching:
Code: [Select]
lazarus-ide sendtolaz.lpiand it worked as it should (regardlless of what was or wasn't open before), so it seems it's something related to startlazarus after 2.0.10.

BTW, in case it's not clear, this is a Linux install; forgot to mention it before :-[
Though it should also happen in any other system ...
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.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3959
  • I like bugs.
Re: Lazarus 2.0.12 doesn't load project passed as parameter
« Reply #3 on: March 10, 2021, 08:12:18 pm »
How does it work in Lazarus trunk?
There are not awfully many revisions between 2.0.10 and 2.0.12. You could bisect to find the guilty revision.

Incidentally I am now implementing a configurable project template selection for Lazarus startup. See :
 https://bugs.freepascal.org/view.php?id=38105
I have not tested any command line parameter stuff. I don't really use them myself.
Soon I will ask volunteers to test it.

[Edit] Committed in r64781. Please test. It should not change any cmd line parameter behavior.
See my comment there. The GUI may need improvements later.
« Last Edit: March 10, 2021, 08:59:42 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Lazarus 2.0.12 doesn't load project passed as parameter
« Reply #4 on: March 10, 2021, 11:48:53 pm »
How does it work in Lazarus trunk?
There are not awfully many revisions between 2.0.10 and 2.0.12. You could bisect to find the guilty revision.

Yeah, I thought about checking that but I don't have much time (neither a trunk install, TBH :-[), which is why I thought about asking here first, in case someone had seen something similar and had some clue why before resorting to that.

Quote
Incidentally I am now implementing a configurable project template selection for Lazarus startup. See :
 https://bugs.freepascal.org/view.php?id=38105
I have not tested any command line parameter stuff. I don't really use them myself.
Soon I will ask volunteers to test it.

[Edit] Committed in r64781. Please test. It should not change any cmd line parameter behavior.
See my comment there. The GUI may need improvements later.

Fun fact, that's the other part of our pre-Lazarus launch tool-chain: we have yet another tool to do that, kind of like the actual "New project ..." dialog but on steroids allowing us to select from tens of templates (i.e "type of application") and applying to it specific info, like who's the initial creator, which license should apply, etc.

And then I have a personal app (gentest) that creates a "test" application for either internal testing of something (say, "let's see how a TNotebook works for X") or for example programs for this forum. The problem about which this thread is meant is that until now creating a new program could be as easy as launching (e.g. for a test):
Code: Bash  [Select][+][-]
  1. gentest --forum --gui /some/path/ && sendtolaz /some/path/
where gentest creates the project from (kind of) a template and sendtolaz launchs Lazarus with(/out) several options, most important of which is the primary config. path; but now this last (using a method like the one in the OP) doesn't work :-(
« Last Edit: March 10, 2021, 11:57:19 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.

dbannon

  • Hero Member
  • *****
  • Posts: 1532
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Lazarus 2.0.12 doesn't load project passed as parameter
« Reply #5 on: March 11, 2021, 04:05:26 am »
On original topic ....

How does it work in Lazarus trunk?

The issue here may be that if you are using Laz trunk, you build from source, build in user space and don't have a path set to any particular Lazarus. So, unlikely to use or need startlazarus.  So, noting lucamar observation that calling lazarus directly works OK, trunk users are unlikely to notice. Or even be able to confirm the problem.  :(

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

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Lazarus 2.0.12 doesn't load project passed as parameter
« Reply #6 on: March 12, 2021, 04:02:44 pm »
OK, I've modified the tool to both: add an option to launch lazarus-ide instead of startlazarus, and a check for versions higher than 2.0.10 to do so automatically (with the prescriptive "ignore" switch to disable it).

It works now but it isn't optimal so when I've a little free time I'll try to see what changed in startlazarus and write a bug report.

Thanks to all for your attention and advice.
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.

Francois_C

  • New member
  • *
  • Posts: 9
Re: Lazarus 2.0.12 doesn't load project passed as parameter
« Reply #7 on: June 25, 2021, 08:47:46 pm »
Yes, that's the behaviour I see but, curiously enough, I just tested launching:
Code: [Select]
lazarus-ide sendtolaz.lpiand it worked as it should (regardlless of what was or wasn't open before), so it seems it's something related to startlazarus after 2.0.10.
I noticed the same with this 2.0.12 version on a fresh install of Linux Mint a few weeks ago. I'm used to set Lazarus as the default app for .lpi, I understood it didn't work because the Lazarus executable no longer accepted parameters.
I browsed the forums and fortunately I found rather easily that I could set lazarus-ide as default app for .lpi...

 

TinyPortal © 2005-2018