Skip to content

Fix module reload failure when calling update from within module#72

Merged
visschersm merged 2 commits into
mainfrom
copilot/fix-update-functionality-issue
Oct 30, 2025
Merged

Fix module reload failure when calling update from within module#72
visschersm merged 2 commits into
mainfrom
copilot/fix-update-functionality-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 30, 2025

After qp update, the module fails to reload, causing "Get-Script-Path is not recognized" errors. The update functions were calling Remove-Module on themselves mid-execution, leaving the session in an inconsistent state.

Changes

  • Removed Remove-Module calls from Update-QuickPathFromGallery and Update-QuickPathFromBuild
  • Updated tests to verify reload behavior instead of removal

Import-Module -Force already handles reloading loaded modules without explicit removal.

Before

function Update-QuickPathFromGallery {
    try {
        $moduleName = "quickpath"
        if (Get-Module $moduleName) {
            Remove-Module $moduleName -Force -ErrorAction SilentlyContinue
        }
        Update-Module -Name $moduleName -Force -ErrorAction Stop
        Import-Module $moduleName -Force -ErrorAction Stop
        # ...
    }
}

After

function Update-QuickPathFromGallery {
    try {
        $moduleName = "quickpath"
        Update-Module -Name $moduleName -Force -ErrorAction Stop
        Import-Module $moduleName -Force -ErrorAction Stop
        # ...
    }
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.powershellgallery.com
    • Triggering command: pwsh ./install.ps1 (dns block)
    • Triggering command: pwsh -Command Install-Module -Name InvokeBuild -Scope CurrentUser -Force -AllowClobber (dns block)
    • Triggering command: pwsh -Command Get-PSRepository (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Update issues were not resolved</issue_title>
<issue_description>```pwsh
...\quickpath [65-update-module ≡]> qp update
Updating quickpath...
WARNING: Built quickpath module not found at ...\quickpath\0.16.3\private..\output\quickpath\quickpath.psd1'. Please run 'Invoke-Build Build' first.


<agent_instructions>After the last PR the update functionality does not work completly as expected.
Can you make a suggestion on how to resolve this?</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@visschersm</author><body>
Solved in MatrTech/quickpath#71 but now the refresh after update does not work.

Steps to reproduce:
- `qp update`
- `qp version`
- error: 

qp: Error: The term 'Get-Script-Path' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

- `Remove-Module quickpath`
- error:

Remove-Module: No modules were removed. Verify that the specification of modules to remove is correct and those modules exist in the runspace.

- `import-Module quickpath`
- `qp version` no returns correct version.

This suggests that the module is not correctly re-imported after updating:
```pwsh
function Update-QuickPathFromGallery {
    try {
        $moduleName = "quickpath"
        if (Get-Module $moduleName) {
            Remove-Module $moduleName -Force -ErrorAction SilentlyContinue
        }
        Update-Module -Name $moduleName -Force -ErrorAction Stop
        Import-Module $moduleName -Force -ErrorAction Stop
        Write-Host "$moduleName updated from gallery and reloaded." -ForegroundColor Green
    }
    catch {
        Write-Error "Failed to update '$moduleName' from gallery: $($_.Exception.Message)"
        throw
    }
}
```</body></comment_new>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: visschersm <11668365+visschersm@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix update functionality for quickpath module Fix module reload failure when calling update from within module Oct 30, 2025
Copilot AI requested a review from visschersm October 30, 2025 08:26
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
private/Update-QuickPath.ps1 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@visschersm visschersm marked this pull request as ready for review October 30, 2025 08:57
@visschersm visschersm merged commit c56631d into main Oct 30, 2025
3 checks passed
@visschersm visschersm deleted the copilot/fix-update-functionality-issue branch October 31, 2025 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update issues were not resolved

2 participants