bulletmark / edir

Program to rename, remove, and copy files and directories using your editor
139 stars 8 forks source link

Fails on Windows with an error about no such file or directory '/dev/tty' #20

Closed JohnWilliston closed 9 months ago

JohnWilliston commented 9 months ago

Perhaps edir was never designed to work on Windows, but I've used vidir with vim successfully in many Windows command shells and thought it would be great to upgrade to edir instead when I learned of it. So I installed pipx, then used that to install edir, but when I run it I get the following error:

Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "C:\users\john.local\bin\edir.exe__main__.py", line 7, in File "C:\Users\John.local\pipx\venvs\edir\Lib\site-packages\edir.py", line 578, in main paths = Fpath.get_path_changes() ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\John.local\pipx\venvs\edir\Lib\site-packages\edir.py", line 380, in get_path_changes editfile(fpath) File "C:\Users\John.local\pipx\venvs\edir\Lib\site-packages\edir.py", line 64, in editfile with open('/dev/tty') as tty: ^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '/dev/tty'

Any thoughts? Or is edir simply not intended for use on Windows?

bulletmark commented 9 months ago

I wouldn't say I deliberately exclude Windows, I just have never tried it and have never had anybody else report an issue here. I have made a trivial change which may fix this. Can you please try the master branch?

JohnWilliston commented 9 months ago

I downloaded the new code from GitHub and ran it with a simple "python edir.py" and got the following instead:

Traceback (most recent call last): File "", line 189, in _run_module_as_main File "", line 112, in _get_module_details File "C:\Users\John\VidirTest\edir.py", line 22, in from platformdirs import user_config_path ModuleNotFoundError: No module named 'platformdirs'

It clearly changes the errors. Is that helpful?

bulletmark commented 9 months ago

That module not found error is completely unrelated. How are you installing edir on your windows machine?

JohnWilliston commented 9 months ago

Well, when I first tried to use it, I let pipx install it via the following command:

pipx install edir

That was what I was using when I first reported the issue. When you told me you had updated your code, I assumed you wanted me to download the latest and greatest from GiHub. As such, I downloaded the edir.py file to my local directory and invoked it using the aforementioned "python edir.py" command. For the record, I have Python 3.12.0 installed.

If that's not what you intended for me to do, please clarify what you meant when you said "Can you please try the master branch?" Thanks!

bulletmark commented 9 months ago

Sorry, I assumed you knew how to do that. Type:

pipx install -f git+https://github.com/bulletmark/edir
JohnWilliston commented 9 months ago

Aha, that solved the issue! For what it's worth, I did know I could do a pipx install from GitHub like that, but I didn't realize that's what you were expecting. I thought I could just run the script as I've run so many other Python scripts. I guess not. Not sure why. But then I'm not an expert on either Python or pipx.

bulletmark commented 9 months ago

So I can close this bug?

JohnWilliston commented 9 months ago

Please do and thanks for your help! I now have edir working on Linux, macOS, and Windows. Yay!

bulletmark commented 9 months ago

Actually, I am not sure it fully works correctly on Windows as it assumes '/' in file paths in some areas of the code so will leave this bug open. I haven't used Windows for 28+ years but will download it to Virtualbox and try it out.

JohnWilliston commented 9 months ago

Oh, ok. I'll post other issues here if I find any. So far I've only tested deleting files and folders, which works great.

bulletmark commented 9 months ago

OK, have fixed those issues and released new version 2.26.

You should switch back to the PyPi version, i.e. pipx install -f edir (and then perhaps you also need a pipx upgrade edir?)