-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
up/down arrow history doesn't work on pipenv shell on windows #876
Comments
FWIW, it works in 'ConEmu', just not the normal 'Windows Console Host' process that you get by running cmd.exe directly, so whatever they're doing in there to pass along the arrow keys is what you'd need. Not sure it's worth it to implement seperately in pipenv, but at least this is some kind of a workaround. |
This is an issue with |
This is still not in the patched PEW in this repo or in Pew directly, but I wanted to let others who end up here that if you use Powershell instead of the command prompt it does work. |
(FYI in the next release -- which will be today -- we are no longer using pew for managing subshells). |
I tried installing from the repo and after I did pipenv shell, command history still didn't work. This is how I installed:
I tried it with an existing virtualenv and a newly recreated one. Let me know if I should try another branch. |
Right this is a limitation of subshells in windows. There isn’t a fix for that and nobody is actively implementing one (this would effectively mean reimplementing subshells as far as I understand). Just sharing that pew is no longer involved in this aspect |
I keep seeing that said that, but with virtualenvwrapper-win Virtualenvwrapper-win Worth noting: virtualenvwrapper-win does not support powershell it is mentioned there are versions which do, but I'm not sure which is the best so I won't link to one. Maybe a pipenvwrapper-win needs to appear. But that would be sad I think. If there are suggestions on approaches to fixing, I'm happy to take a swing, I just don't know this area well enough to do without a little guidance. Thanks! |
Just want to mention there is always |
I'm intrigued, but I don't understand. How would you use |
I’m afraid I don’t quite understand the use cases you mentioned :( Could you be more specific what you think is the problem with |
I I see your point now (tried a few more things). When you AND your command history work (up arrow). That seems like how it should work to begin with. I wonder if there are any downsides to this approach. |
I can’t speak for everyone but I very rarely use subshells myself and I know @uranusjr doesn’t either. Since we are the main devs on the project following our workflow is most likely a safe bet |
I had assumed Thanks! |
up arrow still doesn't work for me in this scenario. I'm using latest version 2018.7.1 |
Okay, now we purged Pew, we should track this on our own :p From the discussion in pew-org/pew#165, I think the simplest way to do this right now is to perform DLL-injection. Vendor the Clink executable, and when we are about to launch cmd.exe, instead of running it directly, run Clink instead. We can probably reuse Clink’s startup BAT file, or |
Semi check semi todo list:
|
Seems like there is a fork to make DOSKEY work. Cmder also uses the fork (if I read the thread correctly), so that seems like well-proofed work. |
We need to find a way to be clever about this. I guess we can build platform dependent wheels. |
I’m thinking maybe we can perform a one-time download at runtime, to avoid vendoring altogether. Only plain cmd.exe users would need to make that download once (unless the user clears cache). |
Note: The above comment is outdated. Clink released 0.4.9 which included the DOSKEY fix, and Cmder is using that instead of the fork. |
@mungojam this may no longer be relevant with the new changes down the road, but for me on Windows 10, this worked:
Now you're at a new prompt run a command like DIR and then hit the up arrow... bingo! |
@w7pea One thing I have realised is that |
@mungojam Are you starting VS Code from inside the virtualenv? So if I start a clean CMD and do this...
You will see requests is installed because VS Code was started inside your Virtualenv.
You only see what you have installed in your OS, not the virtualenv. As for the hanging install from the Git Repo. I can't reproduce that sorry. |
VS Code can be configured to automatically pick up the virtual environment. You don’t even need to https://code.visualstudio.com/docs/python/environments Also the conversation is slowly drifting away. Further discussion should probably happen elsewhere. |
Thanks for the tips, useful for me to be able to get it working for myself, but I look forward to when I can point my colleagues at generic pipenv guides and things work as they are used to with |
I am on Windows 10 Pro (10.0.17134 Build 17134) with Pipenv 2018.11.14 and the |
If you start by using If however you simply use |
This is still a thing over here on my windows 10 machine running the latest windows 10 and the latest pipenv. |
I can access my cmd shell history using |
This happens for me with latest pipenv on Windows 10 1903. I don't recall it happening a year or so ago. |
Hi guys, having the same issue with pipenv on my machine (Windows 10 1903/pipenv 2018.11.26) but I played around with it today and noticed some things while trying to get command history working for my personal scrapy project for when I use scrapy's shell from within a pipenv ( I found that if instead of invoking pipenv through its .exe ( Non-working Before: So I did some more digging and testing and noticed that when the pipenv shell is started it's done so as So I'm guessing from my testing that if a process sits between the invoking process and the currently active child process it screws up command history, because I'd also loose my command history if I used scrapy's native scrapy.exe from Python's Scripts folder (like pipenv.exe) inside the pipenv shell so I also have to use For the TL;DR:
This just worked for me and I'm not sure if this works for anybody else yet, so if anyone else could double check and test this on their Windows systems that would be much appreciated to know. (Just remember to edit using a program started with admin privileges for editing pipenv.shells._handover if you installed python under "C:\Program Files" or "C:\Program Files (x86)") |
Given LanetheGreat's work, would it be possible to introduce an environment variable that would control whether or not the new shell was spawned with |
|
Up arrows working on my VS Code in Windows after python -m pipenv shell |
Writing here to draw attention to the issue as it still not solved. Yes - I'm facing the same problem. Looking forward for possible solution(s). |
it works for me, thank you |
worked like a charm on Pycharm terminal. I will use this workaround for now. |
Confirmed: it doesn't work in VS Code's built-in console but works on external consoles. |
I have a same problem in powershell and cmd even with |
Interestingly for me, I can't traverse history at all when running |
Not sure if anyone mentioned already, but I tried opening another cmd from the pipenv shell using "start cmd.exe" and it seemed to preserve the environment while enabling up/down arrow history... |
I see this issue got closed. |
I just tried this on Win 10 from cmd.exe using pipenv 2022.5.2, doesn't seem to be fixed. @matteius - could you share which version it this was fixed/closed in? It'd be great to start using that. |
@rocketmonkeys Apparently it (the up and down arrows) does not work in cmd.exe when you run |
This stopped working for me even in Git bash and PowerShell. |
No Python REPL history is also an issue on Windows 11 / Powershell / pipenv shell. A workaround is to activate the virtual environment created by pipenv using the Activate.ps1 script. Not very convenient but I guess okay if you only need REPL history occasionally but still want to stick with pipenv on Windows. |
Doesn't work in either Powershell or git bash. In the latter nothing happens, in the former the cursor literally moves up or down the screen. Also doesn't work in any VSCode consoles. @matteius |
In the cmd shell, usually you can hit 'up arrow' to get your previous command. Once you run 'pipenv shell', this no longer works. if you run some commands inside the pipenv shell and then hit 'up' it does nothing.
The text was updated successfully, but these errors were encountered: