主要内容

mpmupdate

R2026b

Update installed package to newer version

Since R2026b

    Description

    newpkg = mpmupdate(pkg) updates the specified packages to the newest versions available. By default, dependencies are not updated unless a newer version of a dependency is required by the new version of pkg.

    If the Editable property of the specified package is true then MATLAB® throws an error.

    example

    newpkg = mpmupdate(pkg,verRange) updates the specified packages to the latest versions available in the specified version range where each element of verRange corresponds to the same element of pkg.

    example

    newpkg = mpmupdate(__,Name=Value) specifies options using one or more name-value arguments in addition to any of the input argument combinations in previous syntaxes. For example, you can specify the dependencies to update and whether to display update prompts.

    Examples

    collapse all

    Display a list of all installed packages.

    mpmlist
             Name         Version    Editable    InstalledAsDependency
        ______________    _______    ________    _____________________
    
        "Astronomy"       "1.3.1"     false              false        
        "RandomNumGen"    "2.0.0"     false              false        
        "Physics"         "1.0.1"     false              false        
    

    Update the Astronomy package to the latest version.

    newpkg = mpmupdate("Astronomy")
    newpkg = 
    
      PackageSpecifier with properties:
    
                Name: "Astronomy"
        VersionRange: "4.5.0"
                  ID: "31e6c531-b484-4878-90e4-a61e8e973eb3"

    Display a list of all installed packages.

    mpmlist
             Name         Version    Editable    InstalledAsDependency
        ______________    _______    ________    _____________________
    
        "Astronomy"       "1.3.1"     false              false        
        "RandomNumGen"    "2.0.0"     false              false        
        "Physics"         "1.0.1"     false              false        
    

    Update the Astronomy package to a version between 2.0.0 and 3.0.0.

    newpkg = mpmupdate("Astronomy",">=2.0.0 <=3.0.0")
    newpkg = 
    
      PackageSpecifier with properties:
    
                Name: "Astronomy"
        VersionRange: "3.0.0"
                  ID: "31e6c531-b484-4878-90e4-a61e8e973eb3"

    Input Arguments

    collapse all

    MATLAB package specifiers, specified as a string array or cell array of character vectors where each element contains a package specifier, a character vector containing a package specifier, or a matlab.mpm.PackageSpecifier array.

    Example: "mypackage"

    Example: "mypackage@1.0.0"

    Example: "mypackage@1.0.1@17487be8-15e8-447b-9319-83516fc31f08"

    Version range, specified as a string array, character vector, or cell array of character vectors. The input package is updated to the latest available version within the specified version range.

    Version syntax follows the Semantic Versioning 2.0.0 format: <major>.<minor>.<patch>, where each version number must be a nonnegative integer, for example 1.2.3. You can optionally specify a pre-release version by adding -<prerelease> to the end of the version, for example 1.2.3-alpha. Optionally specify a build version by adding +<build>.

    Specify a range of versions by including the <, <=, >, or >= operators in front of a version number. For example, >2.1.13 specifies all versions greater than 2.1.13. Specify more than one range separated by white space to further limit matches. For example, >2.1.13 <=2.1.15 includes versions 2.1.14 and 2.1.15, but not 2.1.13 or 2.1.16. Use the || operator to designate multiple acceptable version ranges. For example, <2.1.13 || >2.1.15 includes versions less than 2.1.13 and greater than 2.1.15, but not 2.1.14.

    Example: "1.2.3"

    Example: "1.2.3-alpha"

    Example: "1.2.3-alpha+exp"

    Example: ">2.1.13"

    Example: ">2.1.13 <=2.1.15"

    Example: "<2.1.13 || >2.1.15"

    Example: ["1.2.3" "2.0.0"]

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: newpkg = mpmupdate(pkg,Prompt=true)

    Display update prompts, specified as a numeric or logical 1 (true) or 0 (false). If you specify Prompt as false, then update prompts are not displayed and the function automatically confirms package updates.

    Example: Prompt=false

    Verbosity level for displayed information, specified as one of these values:

    • "normal" — Display informational messages during update.

    • "quiet" — Do not display informational messages.

    • "detailed" — Display additional informational messages.

    Example: Verbosity="quiet"

    Dependencies to update, specified as one of these values:

    • "all" — Update dependencies to the latest version even if the installed version is compatible with the new package.

    • "necessary" — Update dependencies only if necessary to satisfy dependency constraints.

    • "none" — Do not update any dependencies.

    Example: UpdateDependencies="necessary"

    Force update, specified as a numeric or logical 1 (true) or 0 (false). If you specify Force as true, then the function updates packages even if a dependency is not found or if the MATLAB version or platform is not compatible with the ReleaseCompatibility or SupportedPlatforms properties of the updated package.

    When a dependency of the updated package conflicts with an already installed package or dependency and you specify Force as true, then the updated dependency overwrites the installed package or dependency even if it breaks an installed package. For example, if the installed packageA depends on version 1.0.0 of packageB and you call mpmupdate with Force as true on packageC, which depends on version 2.0.0 of packageB, then mpmupdate overwrites version 1.0.0 of packageB with version 2.0.0 and breaks the dependency of packageA.

    Example: Force=true

    View installation changes without installation, specified as a numeric or logical 1 (true) or 0 (false). If you specify DryRun as True, then the names and versions of all packages and their dependencies that would be installed are displayed without installation. If AllowVersionReplacement is true, then the names and versions of packages and dependencies that would be removed are displayed as well. Use this information to verify the packages you are installing are the correct packages.

    Output Arguments

    collapse all

    Updated packages, returned as a matlab.mpm.PackageSpecifier array.

    Tips

    • During package installation the event is logged by the system audit logger. MATLAB records the following information for each installed package and dependency:

      • Package ID

      • Originating repository

      • Download URL

      • Download destination

      • Package digest, as returned by digest

    Version History

    Introduced in R2026b