Skip to content
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

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

Open
pblanton opened this issue May 22, 2024 · 18 comments
Open

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

pblanton opened this issue May 22, 2024 · 18 comments

Comments

@pblanton
Copy link

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
@Emen-c
Copy link

Emen-c commented May 24, 2024

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

@flyingmongoose
Copy link

flyingmongoose commented May 27, 2024

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
Copy link

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
Copy link

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
Copy link

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
Copy link

Found in a #1434

pip uninstall thefuck
pip install https://github.com/nvbn/thefuck/archive/master.zip

@unikitty37
Copy link

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
Copy link

lloydbayley commented Jun 12, 2024

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
Copy link

antgel commented Jun 21, 2024

@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
Copy link

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
Copy link

mhalano commented Jun 24, 2024

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

@antgel
Copy link

antgel commented Jun 24, 2024

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

As mentioned ^^^:
#1449 (comment)

@Kol9yN
Copy link

Kol9yN commented Jun 28, 2024

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
Copy link

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
Copy link

Kol9yN commented Jun 30, 2024

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

@krstp
Copy link

krstp commented Jul 3, 2024

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')

@george-gca
Copy link

george-gca commented Jul 20, 2024

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

@unikitty37 there is pipx. I applied the changes made in 0420442 and https://github.com/nvbn/thefuck/pull/1404/files to the pipx installed version, located in ~/.local/share/pipx/venvs/thefuck/lib/python3.12/site-packages/thefuck/.

@nulf
Copy link

nulf commented Sep 20, 2024

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.

This worked perfectly for me on Ubuntu 24.04 with zsh. Thanks a bunch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests