Maximus5 / ConEmu

Customizable Windows terminal with tabs, splits, quake-style, hotkeys and more
https://conemu.github.io/
BSD 3-Clause "New" or "Revised" License
8.55k stars 572 forks source link

Running command in conemu produces error, but same cammand runs successfuly in regular windows command prompt #2296

Open demdante opened 3 years ago

demdante commented 3 years ago

Versions

ConEmu Version status: 210314 preview x64 OS version: Windows 10 x64 Used shell version (Far Manager, git-bash, cmd, powershell, cygwin, whatever): {cmd (Admin)}

Problem description

Not sure if you are familiar with the hashicorp tool vagrant, but it is a command line tool that I use on almost a daily basis. I also use Conemu all the time as well, and have frequently run vagrant commands using conemu successfully. However, after installing the latest update to conemu this morning, whenever I would run, well, almost any vagrant command, I receive the following error:

conemu

You may think, as I did, that this was an issue with vagrant rather than conemu, so it took me a while to diagnose the problem as a result. However, it is most definitely conemu that is the source of the problem, as I am able to successfully run vagrant commands using the default, built-in windows command prompt:

cmd

Steps to reproduce

  1. Download and install vagrant
  2. After the required restart, using the most up-to-date version of conemu, run the below command:
vagrant init

This command, when it runs successfully, simply generates a vagrant config file. However, when run in conemu, it returns the above error.

Actual results

conemu

Expected results

cmd

Additional files

screenshots, See above All files that you requested are in the zip file linked below: https://www.dropbox.com/s/ih87ddhndfzq5dn/ConEmuLogs.zip?dl=0

warpsprung commented 3 years ago

I can confirm - have the same issue. Did not try the very version after 210202. But after this or the very next release the issue has been introduced.

demdante commented 3 years ago

@Maximus5 Any input? Any kind of acknowledgement you have seen and recognize this as a bug with conemu would be appreciated.

Maximus5 commented 3 years ago

For now, I can only confirm, that powershell, started by ruby in vagrant under ConEmu, crashes (exits unexpectedly). I don't know the reason yet.

The same powershell command started manually in ConEmu works.

adrianheron commented 3 years ago

Just in case you missed it in the dup issue ^^, one of the replies links to the corresponding issue that was raised on the vagrant side: https://github.com/hashicorp/vagrant/issues/12221. It provides some more detailed logs and shows that the problem is related to the subprocess call that attempts to determine the powershell version.

In the vanilla terminal the version "5" gets piped back to the subprocess successfully

 INFO subprocess: Starting process: ["C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\/powershell.EXE", "-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", "Write-Output $PSVersionTable.PSVersion.Major"]
 INFO subprocess: Command not in installer, restoring original environment...
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stdout: 5

But in conemu the version "5" shows up in the terminal and the subprocess gets nothing, and Vagrant reports the version as N/A

 INFO subprocess: Starting process: ["C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\/powershell.EXE", "-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", "Write-Output $PSVersionTable.PSVersion.Major"]
 INFO subprocess: Command not in installer, restoring original environment...
DEBUG subprocess: Selecting on IO
5

You can see the same rogue 5 appearing in the screenshots attached to this issue.

That's where my understanding of the issue ends, sorry I can't be more helpful.

mkoertgen commented 3 years ago

I am also seeing this specific problem with Vagrant. Alos took me a while to figure this out and reach the discussion here.

My 2 cents: I just cross-checked with CmderMini (current chocolatey version: https://chocolatey.org/packages/cmdermini/1.3.17) as an additional temporary workaround and i can confirm Vagrant is running fine

λ vagrant version                                 
Installed Version: 2.2.14                         
Latest Version: 2.2.14                            

You're running an up-to-date version of Vagrant!
zemzelett commented 3 years ago

Hi there, i had the same issue yesterday. I just figured out a way to run vagrant up succesfully: I unchecked "Inject ConEmuHk.dll into all processes started in ConEmu tabs" under Settings > General.

Cross checking what @mkoertgen stated, cmdermini works for me too. But there's a difference with the ConEmuHk.dll. Cmdermini seems to use an older version of it?

image

On the left is Cmder (Installed via Chocolatey choco install cmder [v1.3.18]) and on the right Cmdermini (installed via Chocolatey choco install cmdermini [v1.3.17])

As a quick and dirty test i replaced the dll files in Cmder with the ones from Cmdermini and checked the aforementioned box again and it sure worked.

So, from what i see, maybe some change in the ConEmuHk.dll does cause this problem.

Hope this helps.

synhi commented 3 years ago

I unchecked "Inject ConEmuHk.dll into all processes started in ConEmu tabs" under Settings > General.

it works for me.

zemzelett commented 3 years ago

Glad, that it works for other people too. Though i am not sure, what it means to completely turn off the DLL injection. There are good reasons, why this DLL exists.

I personally am working with an older version, for which i am also not sure if that's a good solution to the problem.

I just did some research tracking the ConEmu releases back. The "buggy behavior" was introduced with the 210304 release. With the 210206 release it works. Again, i just closed ConEmu, exchanged the DLLs, started ConEmu and ran vagrant up.

cheretbe commented 3 years ago

Came here with the same issue.

While reading ConEmu docs on hooks I've found an example of disabling hooks temporarily. This lead me to an idea to just use an alias for vagrant command.

:: Do this temporarily
doskey vagrant="cmd /c set ConEmuHooks=OFF & vagrant $* & set ConEmuHooks="

To set the alias permanently, go to Settings > Environment and add the following line:

alias vagrant="cmd /c set ConEmuHooks=OFF & vagrant $* & set ConEmuHooks="

Alias command in ConEmu settings does the same as doskey.exe in cmd shell.

This workaround works for me so far.

anselmhou commented 3 years ago

This works for me as well, as not sure the uncheck (from above) will do with other commands likely to do when working on non-vagrant tasks.

Thanks..

Came here with the same issue.

While reading ConEmu docs on hooks I've found an example of disabling hooks temporarily. This lead me to an idea to just use an alias for vagrant command.

:: Do this temporarily
doskey vagrant="cmd /c set ConEmuHooks=OFF & vagrant $* & set ConEmuHooks="

To set the alias permanently, go to Settings > Environment and add the following line:

alias vagrant="cmd /c set ConEmuHooks=OFF & vagrant $* & set ConEmuHooks="

Alias command in ConEmu settings does the same as doskey.exe in cmd shell.

This workaround works for me so far.

Kyshtynbai commented 3 years ago

Same issue here. Vagrant up fails on powershell check. Unchecking of injecting ConEmuHk.dll works, but god knows what will fail in this case :D. Hope this issue will be resolved.

Maximus5 commented 3 years ago

https://conemu.github.io/blog/2021/06/20/Build-210620.html