AcademySoftwareFoundation / rez

An integrated package configuration, build and deployment system for software
https://rez.readthedocs.io
Apache License 2.0
949 stars 338 forks source link

Shell history not working in cmd.exe or Python REPL #1234

Open nikshankarnoble opened 2 years ago

nikshankarnoble commented 2 years ago

Hi,

With Rez 2.103.4 (Python 3.7) on Windows 10, we are finding that using cmd.exe with Rez doesn't let you step through your command history with the up-arrow key. This issue was reported a couple of years ago but seemed to have been fixed in 2.35.0 https://github.com/nerdvegas/rez/issues/616

$ rez env
> $ echo Hello World!
> $ # hit up-arrow
> $ # no response.. :(

It works as expected in Powershell until you launch a Python REPL process, which it then no longer works inside of.

Any suggestions/help would be very much appreciated! :) Apologies I don't really have the knowledge to look into this myself.

Thanks, Nikhil

nerdvegas commented 2 years ago

I'm going to regard this as a feature request given current lack of support for managing shell history. Please see https://github.com/nerdvegas/rez/issues/1240

instinct-vfx commented 2 years ago

While i agree with the notion that this should be managed actively there is a specific issue with cmd that breaks this. It works with Terminal and Powershell as expected. I THINK Marcus did a fix ages ago and it was choosing different flags when calling cmd. But that might of course have other side effects. I can take a look if i find the time.

nerdvegas commented 2 years ago

Yeah I looked back at that old PR, and it seems like fixing cmd history was (for whatever reason) a side-effect of removing that interstitial cmd proc. Not sure what may have changed in the meantime.

I'll reopen this issue but for anyone working on it please refer to #1240 in the fixing branch name, cheers!

Thx A

On Wed, Mar 2, 2022 at 10:10 AM Thorsten Kaufmann @.***> wrote:

While i agree with the notion that this should be managed actively there is a specific issue with cmd that breaks this. It works with Terminal and Powershell as expected. I THINK Marcus did a fix ages ago and it was choosing different flags when calling cmd. But that might of course have other side effects. I can take a look if i find the time.

— Reply to this email directly, view it on GitHub https://github.com/nerdvegas/rez/issues/1234#issuecomment-1055952960, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMOUSUFTSZXRBWULXYUGLDU52PVNANCNFSM5PFETR2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you modified the open/close state.Message ID: @.***>

herronelou commented 2 years ago

This mentions history being fixed in 2.35.0 for powershell, however I'm using 2.104.9 and once I get into a context, whether from powershell or cmd, there is no more history whatsoever.

herronelou commented 2 years ago

I spent a little bit of time googling, and eventually landed on https://discuss.python.org/t/interactive-command-history-in-session-started-with-subprocess-on-windows/3701/2. ' Based on this, in the properties of my powershell window I increased the "Number of Buffers" past the default value of 4 (I randomly set the value to 12), and suddenly my history started working in the cmd that gets opened by rez-env, AND when launching python from that cmd (same session history only, but already much better than nothing at all).

instinct-vfx commented 2 years ago

As your link indicates i would argue this is more of a console host and shell issue than necessarily a rez issue. I always forget this was an issue because i use Windows Terminal as by console host and a mix of cmd and powershell and history is just fine even in nested shells.

herronelou commented 2 years ago

I don't disagree, it's just not particularly obvious at first, where launching commands from cmd or powershell has a properly working history, but as soon as rez is in the mix it seemingly suddenly stops working. That made me believe that Rez was at fault, and if I'm not mistaken, that's also what others might be believing based on this issue and #616 #1240 and #1320

It could also explain that removing a layer of subprocess via #627 has seemingly made it work a bit better, as that reduced the buffer stack by one, but that going any further down would still break.

If somebody else can confirm that this is indeed the issue that was mentioned, even though it's not a Rez issue, it might be worth mentioning somewhere in the docs how to workaround?

instinct-vfx commented 2 years ago

Absolutely should be mentioned in the docs. Shell plugin specific documentation and pitfalls would generally be a good addition to the docs as even just the differences between cmd and pwsh/powershell can be confusing.

instinct-vfx commented 2 years ago

Would you mind adding it to the documentation improvement discussion thread?

jtomori commented 1 year ago

Hello, I came across the same issue with Rez 2.111.3 on Windows 10 and cmd.exe. Setting Number of Buffers to 12 in the cmd properties helps with commands history in a rez context and also in Python REPL.

Attaching screenshot of cmd properties, so that it's easier to find fix in this thread.

Interestingly commands history worked well in IPython even with the default Number of Buffers setting of 4.