vexx32 / PSKoans

A simple, fun, and interactive way to learn the PowerShell language through Pester unit testing.
GNU General Public License v3.0
1.72k stars 176 forks source link

VScode error: Could not find the module 'PSKoans'. commands typed in console window work fine. #468

Open doctrosix opened 2 years ago

doctrosix commented 2 years ago

Describe "Koan Bug, Issue, or Help Request"

All Koans.ps1 opened in VS code

Visual Studio Code Version 1.64.0

Module versions installed:

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
5.3.1                Pester                              PSGallery            Pester provides a framework for runnin...
0.67.1               PSKoans                             PSGallery            A module designed to provide a crash-c...

Context "The Problematic Assertions"

In every koan that VScode opens, it reports a problem with Line 1: using module PSKoans

In problems tab: ❌Could not find the module 'PSKoans'.

In a powershell 5.1 console window, commands like Show-Karma work just fine.

Context "Your Attempts"

I deleted the Pester and PSKoans folders from $env:HOMEPATH\Documents\WindowsPowerShell\Modules I reinstalled PSKoans, and Pester with these commands, in an administrator window:

$names = "Pester", "PSKoans"
foreach( $name in $names){
    Install-Module -Name $name -Force -Scope AllUsers -AllowClobber
}

Context "Additional Information"

It may be possible I've installed it incorrectly, but I do not know how to debug it further. I'm happy to provide you with any additional info you need.

The PSKoans have been wonderful in teaching me the finer details of powershell, over and above the everyday commands I use at work.

vexx32 commented 2 years ago

You may need to manually import the module into the PS Integrated Console that VS Code uses to run the PowerShell language server for using statements to work appropriately, I think. If that errors, it might give us a better indication as to why it can't find the module normally.

doctrosix commented 2 years ago

Actions taken: I opened VScode I gave the Integrated console the command: Import-Module PSKoans then, in a separate 'Windows Powershell' console window I typed: Show-Karma -Meditate My latest Koan loaded in VScode. ( AboutArrays.Koans.ps1 )

The using error in VScode is still popping up

In the separate 'Windows Powershell' console window, I also tried typing: using module PSKoans no errors reported.

Here's my $env:PSModulePath: C:\Users\mario\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules

PSkoans, and Pester are installed in:

C:\Program Files\WindowsPowerShell\Modules\PSKoans
C:\Program Files\WindowsPowerShell\Modules\Pester

I'm very happy to debug with you!