mpminstall AllowVersionReplacement doesn't seem to work

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 commentaires

praguna manvi
praguna manvi le 15 Avr 2025
Modifié(e) : praguna manvi le 15 Avr 2025
Hi @Alan,
Can you share the complete script for a deeper investigation. On running "mpminstall" on a manually edited version in the json file should ideally error-out.
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)
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!

Connectez-vous pour commenter.

Réponses (0)

Catégories

Produits

Version

R2024b

Tags

Question posée :

le 9 Avr 2025

Commenté :

le 10 Juil 2025

Community Treasure Hunt

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

Start Hunting!

Translated by