Contenido principal

mpminstall

R2026b

Install package

Since R2024b

    Description

    pkg = mpminstall(packageFolder) installs the specified package folder and its dependencies, adds them to the path, and returns a matlab.mpm.Package object.

    example

    pkg = mpminstall(packageSpecifier) installs the specified package and its dependencies and adds them to the path. By default, the function searches all known repositories and installs the latest version.

    example

    pkg = mpminstall(pkgArray) installs the specified packages and their dependencies. The function copies packages and their dependencies to the default installation area. All packages specified in the argument list are added to the MATLAB® path.

    pkg = mpminstall(___,Name=Value) specifies options using one or more name-value arguments. For example, you can specify whether to install package dependencies and whether to add the package member folders to the beginning or end of the MATLAB path.

    example

    Examples

    collapse all

    Install the package MyPackage. When prompted, confirm the installation.

    pkg = mpminstall("MyPackage")
    The following packages will be installed:
        MyPackage@1.0.0
    
    Do you want to continue? [YES/no]:
    
    
    Copying MyPackage@1.0.0 package...Done.
    
    Successfully added the following packages to the path:
        MyPackage  (help)
    
    Installation complete.
    
    
    pkg = 
    
      Package with properties:
    
       Package Definition
                         Name: "MyPackage"
                  DisplayName: "MyPackage"
                      Version: 1.0.0 (1×1 Version)
                      Summary: ""
                         Tags: [1×0 string]
                       Readme: ""
                     Provider: <missing>
                      Folders: [1×0 PackageFolder] (1×0 PackageFolder)
                 Dependencies: ""
         ReleaseCompatibility: "*"
           SupportedPlatforms: [1×1 matlab.mpm.PlatformConfiguration]
                  FormerNames: ""
                           ID: "bb9abc84-5324-42fd-851c-b65e2887f3b5"
    
       Package Installation
                    Installed: 1
                     Editable: 0
            DirectlyInstalled: 1
                  PackageRoot: "C:\Users\MyProfile\AppData\Roaming\MathWorks\MATLAB Add-Ons\MyPackage@1.0.0"
        InstalledDependencies: ""
          MissingDependencies: ""
    
       Repository
                   Repository: [0×0 Repository]
    
      help MyPackage

    Install the package MyPackage by specifying the root folder. When prompted, confirm the installation.

    pkg = mpminstall("C:\MyCode\PackageRootDir")
    The following packages will be installed:
        MyPackage@1.0.0
    
    Do you want to continue? [YES/no]:
    
    
    Copying MyPackage@1.0.0 package...Done.
    
    Successfully added the following packages to the path:
        MyPackage  (help)
    
    Installation complete.
    
    
    pkg = 
    
      Package with properties:
    
       Package Definition
                         Name: "MyPackage"
                  DisplayName: "MyPackage"
                      Version: 1.0.0 (1×1 Version)
                      Summary: ""
                         Tags: [1×0 string]
                       Readme: ""
                     Provider: <missing>
                      Folders: [1×0 PackageFolder] (1×0 PackageFolder)
                 Dependencies: ""
         ReleaseCompatibility: "*"
           SupportedPlatforms: [1×1 matlab.mpm.PlatformConfiguration]
                  FormerNames: ""
                           ID: "bb9abc84-5324-42fd-851c-b65e2887f3b5"
    
       Package Installation
                    Installed: 1
                     Editable: 0
            DirectlyInstalled: 1
                  PackageRoot: "C:\Users\MyProfile\AppData\Roaming\MathWorks\MATLAB Add-Ons\MyPackage@1.0.0"
        InstalledDependencies: ""
          MissingDependencies: ""
    
       Repository
                   Repository: [0×0 Repository]
    
      help MyPackage

    Install the package MyPackage in authoring mode by specifying the root folder and the Authoring name-value argument. In authoring mode, the mpminstall function installs the package in its current location rather than in the default installation area and makes the package editable. When prompted, confirm the installation.

    pkg = mpminstall("C:\MyCode\PackageRootDir",Authoring=true)
    The following packages will be installed:
        MyPackage@1.0.0
    
    Do you want to continue? [YES/no]:
    
    
    Copying MyPackage@1.0.0 package...Done.
    
    Successfully added the following packages to the path:
        MyPackage  (help)
    
    Installation complete.
    
    
    pkg = 
    
      Package with properties:
    
       Package Definition
                         Name: "MyPackage"
                  DisplayName: "MyPackage"
                      Version: 1.0.0 (1×1 Version)
                      Summary: ""
                         Tags: [1×0 string]
                       Readme: ""
                     Provider: <missing>
                      Folders: [1×0 PackageFolder] (1×0 PackageFolder)
                 Dependencies: ""
         ReleaseCompatibility: "*"
           SupportedPlatforms: [1×1 matlab.mpm.PlatformConfiguration]
                  FormerNames: ""
                           ID: "bb9abc84-5324-42fd-851c-b65e2887f3b5"
    
       Package Installation
                    Installed: 1
                     Editable: 1
            DirectlyInstalled: 1
                  PackageRoot: "C:\MyCode\PackageRootDir"
        InstalledDependencies: ""
          MissingDependencies: ""
    
       Repository
                   Repository: [0×0 Repository]
    
      help MyPackage

    Input Arguments

    collapse all

    MATLAB package folder, specified as a string array where each element contains a package root folder.

    Example: “MyFolder\packageSource”

    Package specifier, specified as a string scalar, character vector, a matlab.mpm.PackageSpecifier object array, or a matlab.mpm.PackageIdentifier object array. If packageSpecifier is a string scalar or character vector, then it must contain a package specifier in the format "Name", "Name@VersionRange", or "Name@VersionRange@ID". This option limits the output to only packages whose package specifier fits the specified value.

    For additional information on package specifiers and their syntax, see What Is a Package Specifier?.

    Example: "MyPackage"

    Example: "MyPackage@1.0.1"

    Example: "MyPackage@1.0.1@9ecfea6b-1710-4fb9-aa66-e4750f0e8251"

    MATLAB package, specified as a matlab.mpm.Package object array.

    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: pkg = mpminstall(pkgArray,Prompt=true)

    Display installation prompts, specified as a numeric or logical 1 (true) or 0 (false). If you specify Prompt as false, then installation prompts are not displayed and the function automatically confirms that packages should be installed when prompted.

    Example: Prompt=false

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

    • "normal" (default) — Display informational messages during installation.

    • "quiet" — Do not display informational messages.

    • "detailed" — Display additional informational messages.

    Example: Verbosity="quiet"

    Install dependencies, specified as a numeric or logical 1 (true) or 0 (false). If you specify InstallDependencies as false, then the function does not install package dependencies.

    Example: InstallDependencies=false

    Force installation, specified as a numeric or logical 1 (true) or 0 (false). If you specify Force as true, then the function installs 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 installed 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. (since R2026b)

    Before R2026b: mpminstall does not overwrite installed packages or dependencies if it would break an installed package.

    Example: Force=true

    Allow replacement of installed version, specified as a numeric or logical 1 (true) or 0 (false). If you specify AllowVersionReplacement as true, then the function can replace any previously installed version of a package with the specified version so that only one version of the package is installed. If false, then an error is thrown when the package to be installed matches an already installed package.

    Example: AllowVersionReplacement=true

    Install in place, specified as a numeric or logical 1 (true) or 0 (false). If you specify InPlace as true, then the function installs the package in its current location rather than copying it to the default installation area.

    Inputs must be root folders when InPlace is true.

    Example: InPlace=true

    Enable editable mode, specified as a numeric or logical 1 (true) or 0 (false). If you specify Editable as true, then the function installs the package in editable mode and MATLAB will recognize changes to the package definition file and member folders. InPlace must also be true.

    The package to be installed must be specified as a package root folder or as a matlab.mpm.Package object created from a package root folder when Editable is true.

    Example: Editable=true

    Temporary install, specified as a numeric or logical 1 (true) or 0 (false). If you specify Temporary as true, then the function installs the package only for the current MATLAB session.

    Example: Temporary=true

    Position on the MATLAB path, specified as "end" or "beginning". This value determines if package member folders are added to the end or beginning of the MATLAB path, respectively.

    Example: PathPosition="beginning"

    Enable authoring mode, specified as a numeric or logical 1 (true) or 0 (false). If you specify Authoring as true, then Editable and InPlace are automatically set to true and PathPosition is automatically set to "beginning".

    pkgArray must be a root folder when Authoring is true.

    Example: Authoring=true

    Since R2026b

    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

    Installed packages, specified as a matlab.mpm.PackageSpecifier object array.

    Tips

    • Packages installed from MATLAB launched in -batch mode do not persist across sessions.

    • 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

    Algorithms

    collapse all

    Version History

    Introduced in R2024b

    expand all