"Failed to open portfile from registry" while reinstalling because of configure.optflags

René J.V. Bertin rjvbertin at gmail.com
Wed Oct 26 10:11:20 PDT 2016


On Wednesday October 26 2016 18:50:33 Clemens Lang wrote:

> On Wed, Oct 26, 2016 at 02:17:53AM +0200, René J.V. Bertin wrote:
> > Yeah. There could be a check if the Portfile exists to catch the 1st
> > possibility
> 
> That would introduce a race condition, wouldn't it? Checking whether a
> file exists before doing something with it is a classic mistake.

That depends. I don't see how it would if you check before executing code that assumes the file exist:

if {![file exists [$port portfile]/Portfile]} {
    ui_warn "[$port portfile]/Portfile] doesn't exist"
} else {
    if {![catch {set mport [mportopen_installed ...] etc.} err]} {
    } else {
        ui_warn "Failed to run/parse Portfile from registry for $portspec ($err)"
    }
}

I'm more used to the effects of the classic mistake where you assume a bit too easily that a file always exists ;)

> That information already exists, and you'll see it in debug mode.

Yes, I know $errorInfo is output, but to be honest it's not always easy to find, for instance because the logfile is rewritten at least once during a `upgrade --force`. I find it more useful to obtain the succinct error message from catch and print that in the ui_warn call.

R


More information about the macports-dev mailing list