mpminstall AllowVersionReplacement doesn't seem to work

조회 수: 3 (최근 30일)
Alan
Alan 2025년 4월 9일
댓글: Vidhi Agarwal 2025년 7월 10일
I have a package repository set up as a folder, with a few packages inside created by running mpmcreate(Install=false), and manually setting their version numbers. When I install a package, then advance the version number in remote_repository/TestLibrary/resources/mpackage.json to 1.0.2, and attempt to install by running either of the following commands:
mpminstall("TestLibrary", AllowVersionReplacement=false)
mpminstall("TestLibrary", AllowVersionReplacement=true)
I just get grey text saying "The following packages are already installed: TestLibrary@1.0.1 No additional packages were installed."
When passing false, I do not get an error, as the documentation says I should. When passing true, I do not get a new version of the package installed. Based on the documentation, I expected passing true would reinstall the package, essentially updating it. Is this not the intended behavior? Or have I setup my repository wrong?
For context, if I run:
mpmsearch("TestLibrary")
I get:
Name Version Summary
"TestLibrary" "1.0.2" ""
And if I run:
mpmlist("TestLibrary")
I get:
Name Version Editable InstalledAsDependency
"TestLibrary" "1.0.1" false false
  댓글 수: 3
Alan
Alan 2025년 4월 15일
Here is a script that reproduces the issue central to my confusion. Perhaps it will demonstrate where I've gone wrong.
I am confused as to why a manually edited version in the json file should error-out. Are there other things behind the scenes that get changed when you change a package version?
I had to retype everything here, so I apologize if there's any typos.
%% Clear/CLC && filepaths
clear;clc;
localDir = "..\ReproducablePackage"; % "..\" to ensure the local folder is not on the path
remoteRepository = "Z:\Some\Repository\ReproducablePackage"; % Assuming the parent folder has already been mpmAddRepository()'d
%% Not needed, but helps re-run the script
% If re-running, remember to mpmuninstall("ReproducablePackage")
if isfolder(localDir)
rmdir(localDir, "s");
end
if isfolder(remoteRepository)
rmdir(remoteRepository, "s");
end
%% Setup package
mkdir(localDir);
packing = mpmcreate("ReproducablePackage", localDir, Install=false);
packing.Version = "1.0.1";
copyfile(localDir, remoteRepository);
mpmsearch("ReproducablePackage")
%% Update package
mpminstall("ReproducablePackage") % type "YES"
packing.Version = "1.0.2";
rmdir(remoteRepository, "s");
copyfile(localDir, remoteRepository)
mpmsearch("ReproducablePackage")
%% These return the exact same result: "The following padckages are already installed"
mpminstall("ReproducablePackage", AllowVersionReplacement=true)
mpminstall("ReproducablePackage", AllowVersionReplacement=false)
Vidhi Agarwal
Vidhi Agarwal 2025년 7월 10일
Hi @Alan,
  • Manual Version Edits Are Not Enough: Simply changing the version in `mpackage.json` or the package object does **not** update the package archive used by MPM for installs.
  • MPM Relies on Package Archives: MPM checks for new or updated `.mlpkginstall` package archives when installing or updating packages—not just the JSON file.
  • Why No Error or Update Occurs: If only the JSON is changed, but the archive isn’t rebuilt, MPM sees no new version available and neither errors nor updates.
  • Proper Update Workflow: To release a new version, "change the version" in your package and then "rebuild the archive" using
mpmcreate("ReproducablePackage", localDir, Install=false);
  • .Copy the Updated Archive: After rebuilding, copy the new package files (including the updated archive) to your repository folder.
  • Now Install Works as Expected: Running below line will now detect and install the new version.
mpminstall("ReproducablePackage", AllowVersionReplacement=true)
Always rebuild the package archive with `mpmcreate` after changing the version, then update your repository. This ensures MPM recognizes and installs the new version.
Hope this helps!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

제품


릴리스

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by