nvbn / thefuck

Magnificent app which corrects your previous console command.
MIT License
83.62k stars 3.41k forks source link

Having a hard time getting set up on Ubuntu 24.04 #1449

Open pblanton opened 1 month ago

pblanton commented 1 month ago

The output of thefuck --version (something like The Fuck 3.1 using Python 3.5.0 and Bash 4.4.12(1)-release):

pblanton@ThreadRipper:~$ thefuck --version
Traceback (most recent call last):
  File "/home/pblanton/.local/bin/thefuck", line 5, in <module>
    from thefuck.entrypoints.main import main
  File "/home/pblanton/.local/lib/python3.12/site-packages/thefuck/entrypoints/main.py", line 8, in <module>
    from .. import logs  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^
  File "/home/pblanton/.local/lib/python3.12/site-packages/thefuck/logs.py", line 8, in <module>
    from .conf import settings
  File "/home/pblanton/.local/lib/python3.12/site-packages/thefuck/conf.py", line 1, in <module>
    from imp import load_source
ModuleNotFoundError: No module named 'imp'

Your system (Debian 7, ArchLinux, Windows, etc.):

Ubuntu 24.04

How to reproduce the bug:

install on Ubuntu 24.04 and try to run thefuck --version

The output of The Fuck with THEFUCK_DEBUG=true exported (typically execute export THEFUCK_DEBUG=true in your shell before The Fuck):

Same error
For-Elyisa commented 1 month ago

It seems thefuck can`t work on python 3.12. The last release was build in 2022. May need someone update it.

flyingmongoose commented 1 month ago

The apt package doesn't work Using pip just gives struggles But Snap did the trick.

https://snapcraft.io/install/thefuck/ubuntu#install

It's not the most recent version but it's still useful

Darkextratoasty commented 1 month ago

quick fix for pip installed version at least:

open ~/.local/lib/python3.12/site-packages/thefuck/conf.py replace line;

from imp import load_source

with;

import importlib.machinery

and lines;

settings = load_source(
    'settings', text_type(self.user_dir.joinpath('settings.py')))

with;

settings = importlib.machinery.SourceFileLoader('settings', text_type(self.user_dir.joinpath('settings.py'))).load_module()

then open ~/.local/lib/python3.12/site-packages/thefuck/types.py replace import statement as above;

from imp import load_source

with;

import importlib.machinery

and line;

rule_module = load_source(name, str(path))

with;

rule_module = importlib.machinery.SourceFileLoader(name, str(path)).load_module()

This worked for me on Fedora 40 using fish shell in tilix terminal emulator, can't say for any other combination.

danielbmeireles commented 1 month ago

The workaround proposed by @Darkextratoasty worked on my machine:

DISTRIB_ID=Ubuntu DISTRIB_RELEASE=24.04 DISTRIB_CODENAME=noble DISTRIB_DESCRIPTION="Ubuntu 24.04 LTS"

george-gca commented 1 month ago

It is just sad when a great OSS is left abandoned. Maybe it is time for someone to create a fork with proper updates (there are more than 80 PRs in this repo!!).

lloydbayley commented 1 month ago

Found in a #1434

pip uninstall thefuck
pip install https://github.com/nvbn/thefuck/archive/master.zip
unikitty37 commented 3 weeks ago

If you're not a Python dev who already has a virtualenv setup, you'll need to add one as per these instructions:

python3 -m venv ~/.local --system-site-packages

and make sure ~/.local/bin is in $PATH.

Really wish Python stuff was easier to use without all these gymnastics 😁

lloydbayley commented 3 weeks ago

If you're doing it in dev for testing, then you could always use the pip argument of --break-system-packages but it's not recommended for production environments. I have absolutely NOT done that on my live systems without any problems so-far! 😝

antgel commented 2 weeks ago

@Darkextratoasty A .patch file would have been nice, but I can't complain, for what I paid I'm very happy. Thank you so much!

Sandman6z commented 1 week ago

I also met this problem under my Linux Sandman-PC 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux. And I found that maybe the python-dev package was already stop support any more. However, use python3-dev or python-dev-is-python3 from the prompt need to change the code.

mhalano commented 1 week ago

I found this topic on Stack Overflow: it seems should be importlib instead of imp with Python 3.12.

antgel commented 1 week ago

I found this topic on Stack Overflow: it seems should be importlib instead of imp with Python 3.12.

As mentioned ^^^: https://github.com/nvbn/thefuck/issues/1449#issuecomment-2137634221

Kol9yN commented 1 week ago

quick fix for pip installed version at least:

open ~/.local/lib/python3.12/site-packages/thefuck/conf.py replace line;

from imp import load_source

with;

import importlib.machinery

and lines;

settings = load_source(
    'settings', text_type(self.user_dir.joinpath('settings.py')))

with;

settings = importlib.machinery.SourceFileLoader('settings', text_type(self.user_dir.joinpath('settings.py'))).load_module()

then open ~/.local/lib/python3.12/site-packages/thefuck/types.py replace import statement as above;

from imp import load_source

with;

import importlib.machinery

and line;

rule_module = load_source(name, str(path))

with;

rule_module = importlib.machinery.SourceFileLoader(name, str(path)).load_module()

This worked for me on Fedora 40 using fish shell in tilix terminal emulator, can't say for any other combination.

please can you make a pull request with this fix?

Darkextratoasty commented 1 week ago

please can you make a pull request with this fix?

No, because this is a hacky work-around and it's not clear if it has other, unwanted effects. If someone with more knowledge than myself and a decent set of unit tests can verify that it's a clean fix, then a pull request could be added. Also I know basically nothing of git, so I don't even know how to go about doing a pull request.

Kol9yN commented 1 week ago

@nvbn Коллега, пожалуйста, если есть возможность, исправьте установку под Убунту 22.04. Уж больно много плясок с бубном приходиться делать что бы в ато режиме раскатать софт... Благодарствую!

krstp commented 4 days ago

The proposed workaround somewhat works on:

Distributor ID: Ubuntu
Description:    Ubuntu 24.04 LTS
Release:        24.04
Codename:       noble

but when invoking <command> | fuck it yields:

zsh: command not found: lla
ll [enter/↑/↓/ctrl+c]Traceback (most recent call last):
  File "/usr/bin/thefuck", line 13, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/share/thefuck/thefuck/entrypoints/main.py", line 26, in main
    fix_command(known_args)
  File "/usr/share/thefuck/thefuck/entrypoints/fix_command.py", line 42, in fix_command
    selected_command = select_command(corrected_commands)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/thefuck/thefuck/ui.py", line 83, in select_command
    for action in read_actions():
  File "/usr/share/thefuck/thefuck/ui.py", line 14, in read_actions
    key = get_key()
          ^^^^^^^^^
  File "/usr/share/thefuck/thefuck/system/unix.py", line 23, in get_key
    ch = getch()
         ^^^^^^^
  File "/usr/share/thefuck/thefuck/system/unix.py", line 14, in getch
    old = termios.tcgetattr(fd)
          ^^^^^^^^^^^^^^^^^^^^^
termios.error: (25, 'Inappropriate ioctl for device')