Skip to content

bug: install_r_packages calls utils.install_packages with empty vector when only CircE is missing #128

@MitchellAcoustics

Description

@MitchellAcoustics

Description

In install_r_packages() (src/soundscapy/r_wrapper/_r_wrapper.py), the guard if len(packnames_to_install) > 0 runs before CircE is removed from the list. In the common case where only CircE is missing (sn already installed), after the GitHub install the list becomes [] and utils.install_packages(StrVector([])) is called unnecessarily with an empty vector, which may cause R to emit a warning or error depending on version.

Reproduction

Trigger auto-install when only CircE is missing (sn already present):

# packnames_to_install = ["CircE"]
if len(packnames_to_install) > 0:           # True — passes
    if "CircE" in packnames_to_install:
        remotes.install_github(...)
        packnames_to_install.remove("CircE")  # now []
    utils.install_packages(StrVector([]))     # called with empty vector

Fix

Add a second guard after the CircE removal:

if packnames_to_install:  # only call CRAN install if anything remains
    utils.install_packages(StrVector(packnames_to_install))
    logger.info("Installed missing R packages: %s", packnames_to_install)

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions