How to abort a macports portfile on an error condition?

Ryan Schmidt ryandesign at
Sun Oct 4 20:13:51 UTC 2020

On Oct 3, 2020, at 05:42, Nils Breunese wrote:

> There is also ‘known_fail yes’, which I see getting combined with ‘return -code error’:
> I’m not familiar with the precise differences between known_fail, ui_error and return -code error.

ui_error prints an error message. This is the primary means by which you should inform the user of the problem. Use sentences and use multiple ui_error statements if you need multiple lines.

return -code error stops doing whatever MacPorts was doing at that point. Use this if you've determined that the port installation cannot continue. Usually both of these are used together. It also prints a short message if you provide one. Usually you should summarize what the problem was in two or three words such as "incompatible macOS version",

known_fail yes currently does nothing other than add a value to that port's entry in the portindex stating that failure is expected. In the future MacPorts might use this information to, for example, skip unnecessary steps like installing a port's dependencies if the port is expected to fail. Currently, it is only used by our buildbot infrastructure to skip builds that are known to fail. You should only use known_fail yes if the criteria for the failure lines up with the criteria we use to generate different portindexes. We generate a different portindex for each os.platform/os.major/os.arch combination. So if your criteria for failure is that you cannot build on macOS 10.6 and earlier, great, use known_fail yes. If your criteria depends on the existence of particular files that may or may not be on everyone's system, or Xcode versions, or build architectures, or anything else, don't use known_fail yes.

More information about the macports-dev mailing list