Skip to content

Conversation

@aduh95
Copy link
Contributor

@aduh95 aduh95 commented Aug 31, 2025

In the case where softwareupdate --history does not list any CLT update, the program crashes with an unhelpful error instead of trying the next fallback.

Stacktrace
Traceback (most recent call last):
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/tools/gyp/pylib/gyp/xcode_emulation.py", line 1501, in XcodeVersion
    version_list = GetStdoutQuiet(["xcodebuild", "-version"]).splitlines()
                   ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/tools/gyp/pylib/gyp/xcode_emulation.py", line 1560, in GetStdoutQuiet
    job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "/nix/store/i8r431v9g2hwh9g0kkp2lrgd426szgnq-python3-3.13.7/lib/python3.13/subprocess.py", line 1039, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                        pass_fds, cwd, env,
                        ^^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
                        gid, gids, uid, umask,
                        ^^^^^^^^^^^^^^^^^^^^^^
                        start_new_session, process_group)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/i8r431v9g2hwh9g0kkp2lrgd426szgnq-python3-3.13.7/lib/python3.13/subprocess.py", line 1972, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'xcodebuild'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/configure.py", line 2428, in <module>
    run_gyp(gyp_args)
    ~~~~~~~^^^^^^^^^^
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/tools/gyp_node.py", line 52, in run_gyp
    rc = gyp.main(args)
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/tools/gyp/pylib/gyp/__init__.py", line 692, in main
    return gyp_main(args)
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/tools/gyp/pylib/gyp/__init__.py", line 677, in gyp_main
    generator.GenerateOutput(flat_list, targets, data, params)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/tools/gyp/pylib/gyp/generator/ninja.py", line 2957, in GenerateOutput
    GenerateOutputForConfig(
    ~~~~~~~~~~~~~~~~~~~~~~~^
        target_list, target_dicts, data, params, config_name
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/tools/gyp/pylib/gyp/generator/ninja.py", line 2829, in GenerateOutputForConfig
    target = writer.WriteSpec(spec, config_name, generator_flags)
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/tools/gyp/pylib/gyp/generator/ninja.py", line 413, in WriteSpec
    self.archs = self.xcode_settings.GetActiveArchs(config_name)
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/tools/gyp/pylib/gyp/xcode_emulation.py", line 510, in GetActiveArchs
    xcode_archs_default = GetXcodeArchsDefault()
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/tools/gyp/pylib/gyp/xcode_emulation.py", line 120, in GetXcodeArchsDefault
    xcode_version, _ = XcodeVersion()
                       ~~~~~~~~~~~~^^
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/tools/gyp/pylib/gyp/xcode_emulation.py", line 1513, in XcodeVersion
    version = CLTVersion()  # macOS Catalina returns 11.0.0.0.1.1567737322
  File "/private/tmp/nix-build-nodejs-22.19.0.drv-0/node-v22.19.0/tools/gyp/pylib/gyp/xcode_emulation.py", line 1551, in CLTVersion
    return re.search(regex, output).groupdict()["version"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'groupdict'

Copy link
Contributor

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Can you please add a sample of the current error stack trace?

Would it be possible to add a pytest so we avoid regressions?

Co-authored-by: Christian Clauss <[email protected]>
@aduh95
Copy link
Contributor Author

aduh95 commented Sep 1, 2025

I've updated the OP with a stacktrace. I don't know about pytest, we would need to mock GetStdout or re.search to return an empty result as I don't think we can tamper with /usr/sbin/softwareupdate output

Copy link
Contributor

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Let's move forward with these changes.

@aduh95 aduh95 merged commit b21ee31 into main Sep 1, 2025
84 checks passed
@aduh95 aduh95 deleted the regex-no-match branch September 1, 2025 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants