Pode.Web icon indicating copy to clipboard operation
Pode.Web copied to clipboard

InvalidOperation: /usr/local/share/powershell/Modules/Pode/Private/Helpers.ps1:933

Open solipsist01 opened this issue 2 years ago • 2 comments

I've created a docker image:

FROM badgerati/pode.web:latest
COPY . /usr/src/app/
EXPOSE 9999
CMD [ "pwsh", "-c", "cd /usr/src/app; ./blahblahs.ps1" ]

When the docker image starts, the script crashes a few times before loading the webserver.

InvalidOperation: /usr/local/share/powershell/Modules/Pode/Private/Helpers.ps1:933
Line |
 933 |          $null = Import-Module $path -DisableNameChecking -Scope Globa …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The running command stopped because the preference variable
     | "ErrorActionPreference" or common parameter is set to Stop: An item with
     | the same key has already been added. Key: 595860939

at Import-PodeModules, /usr/local/share/powershell/Modules/Pode/Private/Helpers.ps1: line 933
at Open-PodeRunspace, /usr/local/share/powershell/Modules/Pode/Private/Helpers.ps1: line 603
at <ScriptBlock>, <No file>: line 1


After a few restarts, it works fine.

I tried combatting this by putthing this in the top of blahblah.ps1 (before importing pode.web) with:


$global:ProgressPreference = 'SilentlyContinue'
$global:ErrorActionPreference = 'SilentlyContinue'

Is there something obvious i'm doing wrong ? :)

solipsist01 avatar Nov 20 '23 07:11 solipsist01

Interesting 🤔

I've seen this error over in Pode, and it was fixed in the latest version - just need to update Pode.Web accordingly.

The error was thrown when other modules were available for being automatically imported. Is there any other modules you're using? Are you using a server.psd1 file at all?

Badgerati avatar Nov 23 '23 22:11 Badgerati

i'm not using a server.psd1 file :) i just import with Import-Module Pode.Web

i'll wait until a new build. No rush. it's just a minor inconvenience ;)

solipsist01 avatar Nov 28 '23 06:11 solipsist01