install-module ImportExcel -verbose -Scope CurrentUser
Import-Module -Name ImportExcel
no error
```error:
Import-Module : The specified module 'ImportExcel' was not loaded because no valid module file was found in any module directory.
At line:1 char:1
Environment data
----------------
<!-- provide the output of $PSVersionTable -->
```powershell
> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0-preview.4
PSEdition Core
GitCommitId 6.1.0-preview.4
OS Linux 4.4.0-17134-Microsoft #112-Microsoft Thu Jun 07 22:57:00 PST 2018
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
using verbose mode it shows:
InstallPackageLocal' - name='ImportExcel', version='5.1.1',destination='/tmp/147239779'
````
PS /home/mihol/.local/share/powershell/Modules> install-module ImportExcel -verbose -Scope CurrentUser
VERBOSE: Acquiring providers for assembly: /opt/microsoft/powershell/6-preview/Modules/PackageManagement/1.1.7.0/coreclr/netcoreapp2.0/Microsoft.PackageManagement.MetaProvider.PowerShell.dll
VERBOSE: Acquiring providers for assembly: /opt/microsoft/powershell/6-preview/Modules/PackageManagement/1.1.7.0/coreclr/netcoreapp2.0/Microsoft.PackageManagement.ArchiverProviders.dll
VERBOSE: Acquiring providers for assembly: /opt/microsoft/powershell/6-preview/Modules/PackageManagement/1.1.7.0/coreclr/netcoreapp2.0/Microsoft.PackageManagement.CoreProviders.dll
VERBOSE: Acquiring providers for assembly: /opt/microsoft/powershell/6-preview/Modules/PackageManagement/1.1.7.0/coreclr/netcoreapp2.0/Microsoft.PackageManagement.NuGetProvider.dll
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='ImportExcel'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'ImportExcel'.
VERBOSE: Performing the operation "Install-Module" on target "Version '5.1.1' of module 'ImportExcel'".
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
VERBOSE: The specified module will be installed in '/home/mihol/.local/share/powershell/Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'ImportExcel' with version '5.1.1' from the repository 'https://www.powershellgallery.com/api/v2/'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='ImportExcel'' for ''.
VERBOSE: InstallPackage' - name='ImportExcel', version='5.1.1',destination='/tmp/147239779'
VERBOSE: DownloadPackage' - name='ImportExcel', version='5.1.1',destination='/tmp/147239779/ImportExcel.5.1.1/ImportExcel.5.1.1.nupk
g', uri='https://www.powershellgallery.com/api/v2/package/ImportExcel/5.1.1'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/ImportExcel/5.1.1'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/ImportExcel/5.1.1'.
VERBOSE: Completed downloading 'ImportExcel'.
VERBOSE: InstallPackageLocal' - name='ImportExcel', version='5.1.1',destination='/tmp/147239779'
PS /home/mihol/.local/share/powershell/Modules> ls *
/bin/ls: cannot access '*': No such file or directory
PS /home/mihol/.local/share/powershell/Modules> Import-Module -Name ImportExcel
Import-Module : The specified module 'ImportExcel' was not loaded because no valid module file was found in any module directory.
At line:1 char:1
it does NOT seem to be caused by the issue described in #7258
@dfinke Could you please comment the issue?
@iSazonov the root cause seems that the specific module is not yet ready to run on Ubuntu.
Because this issue is common for many modules, I was more interested in getting a warning or clear error from pwsh. The silent failure is the real issue.
@alx9r Do you mean such behavior in #7377 ?
this is a duplicate of #7264 & is being tracked in https://github.com/PowerShell/PowerShellGet/issues/302
@iSazonov I don't know if #7377 is related. That is a rather different repro. What is similar is that both involve a call that should import a module but silently fails: (It looks like I misread this repro the first time through. It looks like Runspace.Open() in #7377 and Import-Module here.Import-Module is failing and outputting an error in OP's repro.)
Based on comment https://github.com/PowerShell/PowerShell/issues/7264#issuecomment-405320294 the commonality is WSL and I had another issue with nuget (from mono installation) on WSL before
https://github.com/NuGet/Home/issues/7170
From my limited understanding the destination directory is set incorrectly
'InstallPackageLocal' - name='ImportExcel', version='5.1.1',destination='/tmp/147239779'
Could my issue be caused by missing or empty $PSModulePath?
http://wahlnetwork.com/2015/08/10/psmodulepath/ describes this issue very detailed
checked environment variables on WSL:
PS /home/mihol> [Environment]::GetEnvironmentVariable('PSModulePath','User').split(":")
You cannot call a method on a null-valued expression.
At line:1 char:1
+ [Environment]::GetEnvironmentVariable('PSModulePath','User').split(": ...
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
PS /home/mihol> [Environment]::GetEnvironmentVariable('PSModulePath','Process').split(":")
/home/mihol/.local/share/powershell/Modules
/usr/local/share/powershell/Modules
/opt/microsoft/powershell/6-preview/Modules
PS /home/mihol> [Environment]::GetEnvironmentVariable('PSModulePath','Machine').split(":")
You cannot call a method on a null-valued expression.
At line:1 char:1
+ [Environment]::GetEnvironmentVariable('PSModulePath','Machine').split ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
@mi-hol Try [Environment]::GetEnvironmentVariable('PSModulePath','User') -split ":"
a blank line gets displayed, this would confirm the "You cannot call a method on a null-valued expression"
PS /home/mihol> [Environment]::GetEnvironmentVariable('PSModulePath','User') -split ":"
PS /home/mihol>
meaning on WSL only the 'process' environment is set, 'user' and 'machine' environment are null
I'm seeing a similar issue on 18.04 running on WSL. In my case, I'm installing an internal module from our Artifactory instance. The install-module command appears to work but it doesn't place the module in the expected location - /home/hillr/.local/share/powershell/Modules/. If I run install with -verbose is see this as the last bit of output:
VERBOSE: InstallPackageLocal' - name='BuildTools', version='1.1.1',destination='/tmp/497448447'
When I dir that /tmp dir, it doesn't exist. But my PSModulePath var is defined:
> $env:PSModulePath
/home/hillr/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/6-preview/Modules
/cc @SteveL-MSFT Seems the issue can be important and should be fixed before next release.
FYI here's the verbose output of my failed install-module (-scope currentuser):
VERBOSE: Repository details, Name = 'powershell-acme', Location = 'https://artifactory.it.acme.com/artifactory/a
pi/nuget/powershell-acme'; IsTrusted = 'True'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'powershell-acme'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://artifactory.it.acme.com/artifactory/api/nuget/powershell-acme' and P
ackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://artifactory.it.acme.com/artifactory/api/nuget/powershell-acme/FindPackage
sById()?id='BuildTools'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'BuildTools'.
VERBOSE: Performing the operation "Install-Module" on target "Version '1.1.1' of module 'BuildTools'".
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
m/artifactory/api/nuget/powershell-acme'.
VERBOSE: Searching repository 'https://artifactory.it.acme.com/artifactory/api/nuget/powershell-acme/FindPackage
VERBOSE: InstallPackage' - name='BuildTools', version='1.1.1',destination='/tmp/497448447'
VERBOSE: DownloadPackage' - name='BuildTools', version='1.1.1',destination='/tmp/497448447/BuildTools.1.1.1/KalBui
ldTools.1.1.1.nupkg', uri='https://artifactory.it.acme.com/artifactory/api/nuget/powershell-acme/Download/KalBui
ldTools/1.1.1'
VERBOSE: Downloading 'https://artifactory.it.acme.com/artifactory/api/nuget/powershell-acme/Download/BuildToo
ls/1.1.1'.
VERBOSE: Completed downloading 'https://artifactory.it.acme.com/artifactory/api/nuget/powershell-acme/Download/K
VERBOSE: Completed downloading 'BuildTools'.
VERBOSE: InstallPackageLocal' - name='BuildTools', version='1.1.1',destination='/tmp/497448447'
If Install-Module is failing (such that Get-Module -ListAvailable doesn't show it), then this issue should be tracked i the PowerShellGet repo. Looking at the verbose output, it seems that it's a issue with Install-Module unless I'm mistaken.
Another silent failure in PowerShellGet. Let's just rewrite the whole thing from scratch.