SeeminglyScience / EditorServicesCommandSuite

Collection of editor commands for use in PowerShell Editor Services.
Other
152 stars 13 forks source link

Error when profile loads (all hosts) #31

Closed fatherjack closed 5 years ago

fatherjack commented 6 years ago

As per the advice I have inserted the following to my profile

Import-Module EditorServicesCommandSuite
Import-EditorCommand -Module EditorServicesCommandSuite

This was working for some time but

however, each time my profile now loads now I get

Import-EditorCommand : The term 'Import-EditorCommand' is not recognized as the name of a cmdlet, function, script file,

what have I done wrong please?

SeeminglyScience commented 6 years ago

Hmm, thanks for the report @fatherjack! Is this inside the VSCode integrated console or a standard standalone PowerShell window?

I ask because Import-EditorCommand is from the PowerShellEditorServices.Commands module, which is typically only available within the VSCode integrated console.

If this is within the VSCode integrated console, could you provide a screen shot?

sheldonhull commented 6 years ago

I'm also having this issue. I just installed the PSReadline vsix update to try it out, and the commands are not registering as extension commands.

Import-Module EditorServicesCommandSuite

works...

then running the following:

Import-EditorCommand -Module EditorServicesCommandSuite

fails with the following:

Import-EditorCommand : The term 'Import-EditorCommand' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Import-EditorCommand -Module EditorServicesCommandSuite
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Import-EditorCommand:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

full detail

Exception             : System.Management.Automation.CommandNotFoundException: The term 'Import-EditorCommand' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
                        included, verify that the path is correct and try again.
                           at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
                           at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
                           at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
                           at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
                           at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections,
                        FunctionContext funcContext)
                           at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                           at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject          : Import-EditorCommand
CategoryInfo          : ObjectNotFound: (Import-EditorCommand:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
PSMessageDetails      :
SeeminglyScience commented 6 years ago

@sheldonhull Ah yeah that's a bit different. Looks like the Commands module isn't loading automatically in that preview.

In the mean time as a workaround you can import it directly in your profile. I have something like this as the first line in my profile:

Import-Module $HOME\.vscode\extensions\ms-vscode.powershell-2.0.0\modules\PowerShellEditorServices\Commands\PowerShellEditorServices.Commands.psd1

If your vscode extension path is different or you're not on Windows the path will need to change, but that should work until it's put back into the build.

I'm going to leave this issue open until it's fixed in the nightly so it's discoverable.

/cc @rjmholt

rjmholt commented 6 years ago

Yes this is fixed in https://github.com/PowerShell/PowerShellEditorServices/pull/741. Rather than build a new preview manually, when this is merged, AppVeyor will create a build and I can distribute it from the link.

SeeminglyScience commented 5 years ago

@fatherjack I assume you got this figured out. If not feel free to reopen the issue, thanks!