Skip to content

Unable to install module on nanoserver #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rfrerebe opened this issue Apr 30, 2020 · 11 comments
Closed

Unable to install module on nanoserver #417

rfrerebe opened this issue Apr 30, 2020 · 11 comments

Comments

@rfrerebe
Copy link

rfrerebe commented Apr 30, 2020

Steps to reproduce

Using windows container

docker run -it --rm mcr.microsoft.com/powershell:lts-nanoserver-1809
or
docker run -it --rm mcr.microsoft.com/powershell:lts-nanoserver-1903
Install-Module -Name Pester -Force
or any module
Install-Module -Name NetworkingDsc -Force

Expected behavior

I expect this command to work (it works on ubuntu, alpine, windowsservercore).
I expect modules to be loaded.

Actual behavior

With Pester

PS C:\> Install-Module -Name Pester -Force
WARNING: Win32Helpers: Cannot add type. Compilation errors occurred.
WARNING: Could not find a part of the path 'C:\Users\ContainerAdministrator\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet\PSRepositories.xml'
.
Install-Package: C:\program files\powershell\Modules\PowerShellGet\PSModule.psm1:9685
Line |
9685 |  … talledPackages = PackageManagement\Install-Package @PSBoundParameters
     |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The module 'Pester' cannot be installed or updated because the authenticode signature of the file 'Pester.psd1' is not valid.

With NetworkingDsc

PS C:\> Install-Module -Name NetworkingDsc -Force
WARNING: Win32Helpers: Cannot add type. Compilation errors occurred.
WARNING: Could not find a part of the path 'C:\Users\ContainerAdministrator\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet\PSRepositories.xml'
.
Install-Package: C:\program files\powershell\Modules\PowerShellGet\PSModule.psm1:9685
Line |
9685 |  … talledPackages = PackageManagement\Install-Package @PSBoundParameters
     |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The module 'NetworkingDsc' cannot be installed or updated because the authenticode signature of the file 'NetworkingDsc.psd1' is not
     | valid.

Environment data

docker info

Client:
 Debug Mode: false
 Plugins:
  buildx: Build with BuildKit (Docker Inc., v0.3.1-tp-docker)
  mutagen: Synchronize files with Docker Desktop (Docker Inc., testing)
  app: Docker Application (Docker Inc., v0.8.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 55
 Server Version: 19.03.8
 Storage Driver: lcow (linux) windowsfilter (windows)
  LCOW:
  Windows:
 Logging Driver: json-file
 Plugins:
  Volume: local
  Network: ics internal l2bridge l2tunnel nat null overlay private transparent
  Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
 Swarm: inactive
 Default Isolation: hyperv
 Kernel Version: 10.0 19041 (19041.1.amd64fre.vb_release.191206-1406)
 Operating System: Windows 10 Pro Version 2004 (OS Build 19041.208)
 OSType: windows
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.63GiB
 Name: Desktop
 ID: 
 Docker Root Dir: C:\ProgramData\Docker
 Debug Mode: true
  File Descriptors: -1
  Goroutines: 62
  System Time: 2020-04-30T15:36:52.0489507+02:00
  EventsListeners: 1
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine
PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

##Workaround

I can get the module installed with additionnal command

Install-Module -Name Pester -Force -SkipPublisherCheck
 Import-Module ("C:\" + (Get-ChildItem -Name Pester.psm1 -Recurse -Path "C:\"))
@ghost ghost added the Needs: Triage 🔍 label Apr 30, 2020
@ghost ghost assigned TravisEz13 Apr 30, 2020
@RDIL
Copy link
Collaborator

RDIL commented Apr 30, 2020

Hey! I believe you need to pass the -Scope CurrentUser parameter aswell. Can you please try that out? Thanks 😃

@rfrerebe
Copy link
Author

Hello,

Thanks for your quick response 😄

It tried, but I did not saw any change.

PS C:\> Install-Module -Name Pester -Force -Scope CurrentUser
WARNING: Win32Helpers: Cannot add type. Compilation errors occurred.
WARNING: Could not find a part of the path 'C:\Users\ContainerAdministrator\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet\PSRepositories.xml'
.
Install-Package: C:\program files\powershell\Modules\PowerShellGet\PSModule.psm1:9685
Line |
9685 |  … talledPackages = PackageManagement\Install-Package @PSBoundParameters
     |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The module 'Pester' cannot be installed or updated because the authenticode signature of the file 'Pester.psd1' is not valid.

@RDIL
Copy link
Collaborator

RDIL commented Apr 30, 2020

Hmm. Not sure what is going on here.

@TravisEz13
Copy link
Member

for pester, or any signed package, you must specify, -skippublishercheck the signing verification code in PowerShellGet uses an API that is not available on nanoserver.

@rfrerebe
Copy link
Author

Thanks

@TravisEz13
Copy link
Member

TravisEz13 commented May 17, 2020

I added a known issues wiki and i'll update the readme to link to this soon:
https://github.com/PowerShell/PowerShell-Docker/wiki/Known-Issues

GitHub
Repository for building PowerShell Docker images. Contribute to PowerShell/PowerShell-Docker development by creating an account on GitHub.

@identifi-awilliamson
Copy link

identifi-awilliamson commented Sep 10, 2020

This gets the module installed - but the current nanoserver image does not have the ContainerUser module path as part of the PSModulePath ENV variable. So you end up not being able to use the module unless you also alter the PSModulePath. This is further complicated by not being able to edit the registry of the base image to create a new image with the C:\Users\ContainerUser\Documents\Powershell\Modules path added to the PSModulePath environment variable, so you have to do it yourself (via some kind of entrypoint script).

@TravisEz13
Copy link
Member

TravisEz13 commented Sep 11, 2020

@identifi-awilliamson, please file an issue for this, so we can put this on our backlog.

This is probably a PowerShell/.NET bug but we can fix it here.

@identifi-awilliamson
Copy link

Done! - #492
Thanks!

@TravisEz13
Copy link
Member

Thanks for filing an issue. I can't make promises on when it will be done but I put in on the list for the MSFT team to do, but anyone is free to submit a PR in the meantime.

Although, some refactoring of the Windows images is in progress.

@TravisEz13
Copy link
Member

Thanks for filing an issue. I can't make promises on when it will be done but I put in on the list for the MSFT team to do, but anyone is free to submit a PR in the meantime.

Although some refactoring of the Windows images is in progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants