-
Notifications
You must be signed in to change notification settings - Fork 511
using module "..\PathRelativeModule"
rejected by Intellisense
#64
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
Comments
I don't think there is such a construct as I believe what you want at the top of your test file is: Import-Module $PSScriptRoot\..\Module\Module.psd1 Note that quotes aren't needed around path arguments unless the path contains spaces. |
Well, both PowerShell the shell and the VS Code extension accept the syntax. VS Code only has an issue when it can't find the module path, but that only seems to be on this relative path syntax. For example, VS Code has no problem with this fully qualified path: using module ~\Projects\CmdUsageSyntax\CmdUsageSyntax So the feature is at the very least build in to the version of PowerShell I'm using. Though I haven't been able to find any good documentation on it, so it may very well not be supported. |
For reference, PowerShell ISE is able to resolve the path correctly when opening the script. However, if I point it at a path that does not resolve to a module, it raises an error on the using statement, so it is able to correctly distinguish between relative paths that contain a module and those that do not. |
The bug is most likely with https://github.com/PowerShell/PowerShellEditorServices and not with the vscode extension directly. |
Looks like we got more features with the v5 I was finally able to successfully import a module using a relative path: using module ..\..\..\..\Documents\WindowsPowerShell\Modules\Await The kicker is that the relative path is relative to where the current script resides (not the current dir). That's kind of weird and surprising. And it means that the extension needs to be aware of context i.e. |
Yeah, for It would be killer if you could auto-fill the values for $PSScriptRoot and $PSCommandPath and possibly resolve |
Thanks for the report, Andrew! As Keith identifies, this definitely seems to be an issue with the presumed cwd at the time the module resolve operation time takes place. We'll get this fixed in PowerShell Editor Services, I've filed a bug here: |
This was fixed in PowerShell/PowerShellEditorServices#99! I'm going to go ahead and close this now. Feel free to open a new issue if you're still having trouble. |
I've got a project with a file hierarchy like this:
At the top of Module.Tests.ps1, I have
using module "..\Module"
PowerShell itself seems to accept this statement (it loads all the module's functions and types as expected), but VS Code rejects it with the error "Could not find the module '..\Module'.". I believe this Intellisense is incorrect, but my understanding of the "using module" syntax is admittedly incomplete.
The text was updated successfully, but these errors were encountered: