Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- #961: Adding creation of a lock file for a module by using the `-create-lockfile` flag on install.
- #959: In ORAS repos, external name can now be used interchangeably with (default) name for `install` and `update`, i.e. a module published with its (default) name can be installed using its external name.
- #951: The `unpublish` command will skip user confirmation prompt if the `-force` flag is provided.
- #994: prevent crash when target namespace lacks IPM mappings

### Changed
- #316: All parameters, except developer mode, included with a `load`, `install` or `update` command will be propagated to dependencies
Expand Down
28 changes: 24 additions & 4 deletions src/cls/IPM/Main.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,11 @@ ClassMethod Namespace(ByRef pCommandInfo) [ Internal ]
set name = $translate($get(pCommandInfo("parameters","name"),"*"),$char(34))
if (name'["*") {
try {
set $namespace = name
if '..IsIPMEnabled(name) {
write $$$FormattedLine($$$Red,"IPM is not enabled in the "_name_" namespace.")
} else {
set $namespace = name
}
} catch ex {
$$$ThrowStatus($$$ERROR($$$GeneralError,"Failed to switch to namespace: " _ name))
}
Expand All @@ -1102,9 +1106,17 @@ ClassMethod Namespace(ByRef pCommandInfo) [ Internal ]
do ##class(%Library.Prompt).GetString(prompt, .value)
quit:value=""
try {
set $namespace = $select($data(list(value), ns): $listget(ns), 1: value)
set selectedNamespace = $select($data(list(value), ns): $listget(ns), 1: value)
if '..IsIPMEnabled(selectedNamespace) {
write $$$FormattedLine($$$Red," IPM is not enabled for the selected "_selectedNamespace_" namespace.")
hang 0.5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of the hang? Its generally not great practice to have hangs (exceptions are for polling purposes)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @isc-kiyer
The purpose of the hang is to ensure the error message is visible to the user. Without the hang, the message IPM is not enabled in this namespace disappears immediately. Adding a 0.5-second hang allows the message to be displayed long enough for the user to notice and read it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AshokThangavel Ah right. I think it may be a better user experience to accumulate all namespaces where IPM is not enabled and print it at the end instead of them needing to hunt for lines in between possibly long output.

Copy link
Contributor Author

@AshokThangavel AshokThangavel Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback. However, the namespace, zn command already displays the ZPM-enabled details. The crash occurs only when we attempt to select a namespace where IPM is not enabled.

zpm:USER>zn

 1. %SYS>                
 2. USER>                zpm               0.10.5-SNAPSHOT
                         testify           1.0.2
                         web-fslog         1.0.2
                         objectscript-math 0.0.5
 3. USER-VERIFY>         zpm               0.10.5-SNAPSHOT
 4. USER-VERIFY-HISTORY> simplest-module   1.0.0
 5. USER-VERIFY-VERIFY>  testmodule        1.0.0

As you suggested, Can we display this existing message at the end by default

%SYS>zpm

IPM is not enabled in this namespace.
Change namespace to one of the following to run the "zpm" command
USER>                zpm 0.10.5-SNAPSHOT
USER-VERIFY>         zpm 0.10.5-SNAPSHOT
USER-VERIFY-HISTORY> zpm 0.10.5-SNAPSHOT
                     Installed In: USER-VERIFY 
USER-VERIFY-VERIFY>  zpm 0.10.5-SNAPSHOT
                     Installed In: USER-VERIFY 
https://pm.community.intersystems.com/ - 1.0.6
If you want to map IPM globally, switch to one of the namespaces above and run: zpm "enable -map -globally".
If you want to reset repository and map IPM globally along with repository settings, switch to one of the namespaces above and run: zpm "enable -community".

or simple summary of namespace and whether IPM enabled or not

1. %SYS>                       IPM not enabled
2. USER>                       IPM enabled
....

// Clear the current line and move the cursor up to remove the error message
write $$$ClearLineAndMoveUp
continue
}
set $namespace = selectedNamespace
} catch e {
write $char(13),*27,"[K",*27,"[A"
write $$$ClearLineAndMoveUp
continue
}
quit
Expand Down Expand Up @@ -3854,7 +3866,8 @@ ClassMethod DisplayModules(
if pNumbered {
write $justify(i, numbersWidth - 2), ". "
}
write $$$FormattedLinePadRight($$$Magenta, tNS _ "> ", nsWidth)
set ipmStatus=$select('..IsIPMEnabled(tNS):"(IPM not enabled)",1:"")
write $$$FormattedLinePadRight($$$Magenta, tNS _ "> "_ipmStatus, nsWidth)
set tPrefix = $justify("", numbersWidth) _ tNS
kill tModulesList
merge tModulesList = pList(i, "modules")
Expand Down Expand Up @@ -3933,6 +3946,13 @@ ClassMethod DisplayModules(
}
}

ClassMethod IsIPMEnabled(pNamespace As %String = {$namespace}) As %Boolean
{
new $namespace
set $namespace = pNamespace
return $system.CLS.IsMthd("%IPM.Main", "Shell")
}

ClassMethod GetUpstreamPackageVersions(Output list)
{
set query = "SELECT %DLIST(Name) AS Repos FROM %IPM_Repo.Definition"
Expand Down
1 change: 1 addition & 0 deletions src/inc/IPM/Formatting.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ROUTINE %IPM.Formatting [Type=INC]

/// Creates the control sequence for the formatting based on the code
#define ControlSequence(%code) $Char(27)_"["_%code_"m"
#define ClearLineAndMoveUp $char(13),*27,"[K",*27,"[A"

#; Codes to add to convert format types
#define Reset 20
Expand Down