Lazarus 2.0.12 doesn't load project passed as parameter lazarus / 13-General ---------------------------------------------------------------------- lucamar · 2021-03-10 15:45 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  {Base version with just "normal" and "test" configs}procedure TMainForm.OKButtonClick(Sender: TObject);const  NL = LineEnding; {pure laziness: Less typing}  basecmd = '--nsc' + NL + '--skip-last- project';  stdcmd  = basecmd + NL + '%s';  pcpcmd  = basecmd + NL + ' --pcp=%s' + NL + '%s';  PCP = 2;{--> Ignore these;}  PRJ = 3;{-/  they are not used here}var  cfgpath, project: String;begin  {lbProjects is a list box with absolute paths to .lpi file(s)}  project := lbProjects.Items[lbProjects.ItemIndex];  if LowerCase(project).Contains('test')  and (rgConfigPath.ItemIndex = 0) then {rgConfigPath: radiogroup to select PCP}    case MessageDlg(sTest, sUseAltConfig, mtWarning, mbYesNoCancel, 0) of    mrYes: rgConfigPath.ItemIndex := 1;    mrCancel: Exit;    end;  {const CfgPaths: array [0..1] of String = ('', '~/.lazbis/');}  cfgpath := CfgPaths[rgConfigPath.ItemIndex];  with Process do begin {TProcess}  {startlazarus is set elsewhere to:     FindDefaultExecutablePath('startlazarus');}        Executable := startlazarus;    Options := [poNoConsole];    if cfgpath <> '' then    Parameters.Text := Format(pcpcmd, [cfgpath, project])    else      Parameters.Text := Format(stdcmd, [project]);    Execute;  end;  Close;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.lpiand 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? ---------------------------------------------------------------------- ASBzone · 2021-03-10 17:04 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) ---------------------------------------------------------------------- lucamar · 2021-03-10 17:54 Quote from: ASBzone on March 10, 2021, 06:04:39 pmIt 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 ... ---------------------------------------------------------------------- JuhaManninen · 2021-03-10 19:12 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. ---------------------------------------------------------------------- lucamar · 2021-03-10 22:48 Quote from: JuhaManninen on March 10, 2021, 08:12:18 pmHow 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. QuoteIncidentally 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][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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 :-( ---------------------------------------------------------------------- dbannon · 2021-03-11 03:05 On original topic .... Quote from: JuhaManninen on March 10, 2021, 08:12:18 pmHow 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 ---------------------------------------------------------------------- lucamar · 2021-03-12 15:02 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. ---------------------------------------------------------------------- Francois_C · 2021-06-25 18:47 Quote from: lucamar on March 10, 2021, 06:54:59 pmYes, 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...