intellij-powershell icon indicating copy to clipboard operation
intellij-powershell copied to clipboard

Does this plugin support powershell core?

Open Garfield550 opened this issue 3 years ago • 5 comments

System info:

macOS: Apple M1 macOS 11.4 (20F71)

~> which pwsh
/usr/local/microsoft/powershell/7/pwsh
$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Darwin 20.5.0 Darwin Kernel Version 20.5.0: Sat May  8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

IDEA Version

IntelliJ IDEA 2021.2 EAP (Ultimate Edition)
Build #IU-212.4416.7, built on June 23, 2021
IntelliJ IDEA EAP User
Expiration date: July 23, 2021
Runtime version: 11.0.11+9-b1504.3 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 11.4
GC: G1 Young Generation, G1 Old Generation
Memory: 752M
Cores: 8
Non-Bundled Plugins: org.toml.lang (0.2.149.3939-212), ru.adelf.idea.dotenv (2021.2.212), org.rust.lang (0.4.149.3939-212)
Kotlin: 212-1.4.32-release-IJ4416.7

Error info:

com.intellij.plugin.powershell.lang.lsp.languagehost.PowerShellNotInstalled: Can not find PowerShell executable in PATH
    at com.intellij.plugin.powershell.ide.run.PSExecutionUtilKt.findPsExecutable(PSExecutionUtil.kt:22)
    at com.intellij.plugin.powershell.lang.lsp.LSPInitMain$PowerShellInfo.<init>(LSPInitMain.kt:54)
    at com.intellij.plugin.powershell.lang.lsp.LSPInitMain.<init>(LSPInitMain.kt:65)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:47)
    at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:881)
    at com.intellij.serviceContainer.MyComponentAdapter.doCreateInstance(MyComponentAdapter.kt:35)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:113)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:67)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstance$default(BaseComponentAdapter.kt:60)
    at com.intellij.serviceContainer.ComponentManagerImpl.createComponents(ComponentManagerImpl.kt:407)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$loadComponents$5(ApplicationImpl.java:369)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:183)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:705)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:647)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:63)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:170)
    at com.intellij.openapi.application.impl.ApplicationImpl.loadComponents(ApplicationImpl.java:369)
    at com.intellij.idea.ApplicationLoader$startApp$loadComponentInEdtFuture$1.run(ApplicationLoader.kt:136)
    at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
    at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:794)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:350)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:133)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:189)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:403)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Garfield550 avatar Jun 28 '21 10:06 Garfield550

Not useful comment

Oh fine...

image

Garfield550 avatar Jun 28 '21 10:06 Garfield550

Somehow the com.intellij.util.EnvironmentUtil.getValue("PATH") doesn't not includ /usr/local/bin.

From Microsoft Docs, powershell core on macOS has a symbolic link is /usr/local/bin/pwsh, see: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-macos?view=powershell-7.1

Garfield550 avatar Jun 28 '21 10:06 Garfield550

For linux, pwsh symbolic link is /usr/bin/pwsh, https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7.1

Garfield550 avatar Jun 28 '21 10:06 Garfield550

Another issue is I have lots of powershell profile, loading profiles took more than 1700ms.

Last login: Fri Jun 25 19:18:39 on ttys003
PowerShell 7.1.3
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

Loading personal and system profiles took 1790ms.

Garfield550 avatar Jun 28 '21 11:06 Garfield550

Hi, I installed powershell core from Windows store, and the plugin just cannot find the PowerShell in PATH.

Plugin 'com.intellij.plugin.adernov.powershell' failed to initialize and will be disabled. Please restart PyCharm.

com.intellij.plugin.powershell.lang.lsp.languagehost.PowerShellNotInstalled: Can not find PowerShell executable in PATH
    at com.intellij.plugin.powershell.ide.run.PSExecutionUtilKt.findPsExecutable(PSExecutionUtil.kt:22)
    at com.intellij.plugin.powershell.lang.lsp.LSPInitMain$PowerShellInfo.<init>(LSPInitMain.kt:54)
    at com.intellij.plugin.powershell.lang.lsp.LSPInitMain.<init>(LSPInitMain.kt:65)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:47)
    at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:876)
    at com.intellij.serviceContainer.MyComponentAdapter.doCreateInstance(MyComponentAdapter.kt:35)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:113)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:67)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstance$default(BaseComponentAdapter.kt:60)
    at com.intellij.serviceContainer.ComponentManagerImpl.createComponents(ComponentManagerImpl.kt:401)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$loadComponents$5(ApplicationImpl.java:370)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:624)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:698)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:646)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:623)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175)
    at com.intellij.openapi.application.impl.ApplicationImpl.loadComponents(ApplicationImpl.java:370)
    at com.intellij.idea.ApplicationLoader$startApp$loadComponentInEdtFuture$1.run(ApplicationLoader.kt:141)
    at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
    at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:348)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:407)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

In general, powershell core will create a hardlink after installed. The hardlink program is called pwsh.exe and is located at C:\Users\<User Name>\AppData\Local\Microsoft\WindowsApps path.

hahaleyile avatar Dec 03 '21 08:12 hahaleyile

@Garfield550, currently, this works for me on macOS with pwsh being placed in /usr/local/bin/pwsh. Could you please check in the latest plugin version?

@hahaleyile, could you please provide more information on the issue? In particular, what is in your PATH when you start the IDE? To check the real PATH environment variable the IDE sees, I recommend double-clicking the process in Process Hacker and going to the Environment tab.

Sometimes, these kinds of issues may be caused by not getting the right environment in the IDE, and the most effective way to fix it is to restart the computer after changing the environment. (There are, of course, less intrusive ways to do it).

ForNeVeR avatar Sep 24 '23 20:09 ForNeVeR

@Garfield550, currently, this works for me on macOS with pwsh being placed in /usr/local/bin/pwsh. Could you please check in the latest plugin version?

@hahaleyile, could you please provide more information on the issue? In particular, what is in your PATH when you start the IDE? To check the real PATH environment variable the IDE sees, I recommend double-clicking the process in Process Hacker and going to the Environment tab.

Sometimes, these kinds of issues may be caused by not getting the right environment in the IDE, and the most effective way to fix it is to restart the computer after changing the environment. (There are, of course, less intrusive ways to do it).

Apologize, I have reinstalled the whole system, and do not meet this problem again.

hahaleyile avatar Sep 26 '23 06:09 hahaleyile

This issue was closed because it has been open for 14 days, but no requested information was received. Please leave a comment if you think this is a mistake.

github-actions[bot] avatar Oct 19 '23 01:10 github-actions[bot]