[SU2 beta] Finding InstalledPackagesPath is broken

Hi @EPellissier,

We do not use the SDK installer. We use a custom LUA language installer. And there is no info on InstalledPackagesPathNextBoot in the SDK. So I have no clue when this shows and what it’s for and how it’s causing an issue for our installer. Can you please share exact info about this new line of code?

What do you mean poorly written installers when they simply locate the path from the word “InstalledPackagesPath”. Seems to me you added the same word again that confuses our installers. So, yes there may be a work around if we can specify exact word. And if this is the case we will just update on our end if we can do that.

Our code is, LUA language. Here is the string we used.

local sFound = string.match(sOpt, “.InstalledPackagesPath[ "]([^"%c]).”);

Yes, when dealing with key/value type files such as these it is never safe to assume part or some of a string won’t appear in a different key. You must always search for the whole exact key only. This is not anything specific to this file, this applies to any file format with key/values (INI, JSON, YAML, etc).

In Lua, to match just the line with the exact key only I would do something like this (keep in mind you should test this for yourself and make sure!):

--[[
Just an example here, I'm assuming sOpt is the result of reading
the file itself in the real installer code, but this demonstrates
the idea
]]
local sOpt = "NotInstalledPackagesPathValue 7.5\r\nInstalledPackagesPath \"Some Path\"\r\nInstalledPackagesPathNextBoot \"Some Path\""

--Split the file on newline characters into a table with individual lines
lines = {}
for s in sOpt:gmatch("[^\r\n]+") do
    table.insert(lines, s)
end

--Iterate over the lines to find an exact key match
local sFound;
for i, line in ipairs(lines) do
  -- Matches a line starting with "InstalledPackagesPath", followed by
  -- a space, then any other characters until the end of the line
  sFound = string.match(line, "^InstalledPackagesPath .+");
  if(sFound ~= nil)
  then
    -- Break once we find a match
    break;
  end
end

print(sFound);

Somebody more well versed in Lua might have a more succinct way, but something like this is how I would try and do it safely and avoid matching partial keys.

-Matt

1 Like