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

Not Running in Fish Shell #807

Closed
grokdesigns opened this issue Apr 27, 2018 · 14 comments · Fixed by #808
Closed

Not Running in Fish Shell #807

grokdesigns opened this issue Apr 27, 2018 · 14 comments · Fixed by #808
Assignees

Comments

@grokdesigns
Copy link

grokdesigns commented Apr 27, 2018

The output of thefuck --version (something like The Fuck 3.1 using Python 3.5.0):

The Fuck 3.26 using Python 3.6.5

Your shell and its version (bash, zsh, Windows PowerShell, etc.):

Fish v2.7.1 (works fine in Bash)

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

macOS 10.13.5 Beta (17F45c)

How to reproduce the bug:

Run 'fuck' command after entering any incorrect command in Fish shell.

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

DEBUG: Run with settings: {'alter_history': True,
 'debug': True,
 'env': {'GIT_TRACE': '1', 'LANG': 'C', 'LC_ALL': 'C'},
 'exclude_rules': [],
 'history_limit': None,
 'instant_mode': False,
 'no_colors': False,
 'priority': {},
 'repeat': False,
 'require_confirmation': True,
 'rules': [<const: All rules enabled>],
 'slow_commands': ['lein', 'react-native', 'gradle', './gradlew', 'vagrant'],
 'user_dir': PosixPath('/Users/user/.config/thefuck'),
 'wait_command': 3,
 'wait_slow_command': 15}
DEBUG: Total took: 0:00:00.296931
Traceback (most recent call last):
  File "/usr/local/bin/thefuck", line 12, in <module>
    sys.exit(main())
  File "/usr/local/Cellar/thefuck/3.26/libexec/lib/python3.6/site-packages/thefuck/entrypoints/main.py", line 25, in main
    fix_command(known_args)
  File "/usr/local/Cellar/thefuck/3.26/libexec/lib/python3.6/site-packages/thefuck/entrypoints/fix_command.py", line 36, in fix_command
    command = types.Command.from_raw_script(raw_command)
  File "/usr/local/Cellar/thefuck/3.26/libexec/lib/python3.6/site-packages/thefuck/types.py", line 81, in from_raw_script
    expanded = shell.from_shell(script)
  File "/usr/local/Cellar/thefuck/3.26/libexec/lib/python3.6/site-packages/thefuck/shells/generic.py", line 30, in from_shell
    return self._expand_aliases(command_script)
  File "/usr/local/Cellar/thefuck/3.26/libexec/lib/python3.6/site-packages/thefuck/shells/fish.py", line 65, in _expand_aliases
    aliases = self.get_aliases()
  File "/usr/local/Cellar/thefuck/3.26/libexec/lib/python3.6/site-packages/thefuck/shells/fish.py", line 60, in get_aliases
    raw_aliases = _get_aliases(overridden)
  File "/usr/local/Cellar/thefuck/3.26/libexec/lib/python3.6/site-packages/thefuck/utils.py", line 33, in wrapper
    memo[key] = fn(*args, **kwargs)
  File "/usr/local/Cellar/thefuck/3.26/libexec/lib/python3.6/site-packages/thefuck/utils.py", line 267, in wrapper
    return _cache.get_value(fn, depends_on, args, kwargs)
  File "/usr/local/Cellar/thefuck/3.26/libexec/lib/python3.6/site-packages/thefuck/utils.py", line 243, in get_value
    value = fn(*args, **kwargs)
  File "/usr/local/Cellar/thefuck/3.26/libexec/lib/python3.6/site-packages/thefuck/shells/fish.py", line 25, in _get_aliases
    name, value = alias.replace('alias ', '', 1).split(' ', 1)
ValueError: not enough values to unpack (expected 2, got 1)

If the bug only appears with a specific application, the output of that application and its version:

N/A

Anything else you think is relevant:

N/A

screenshot_20180426_17 50 13_tz8le7

@grokdesigns
Copy link
Author

I've tried the fixes in #717 and am still having the same issue.

@Chris-W-Weir
Copy link

I'm having this issue as well, I'm on Mac OS 10.13.4 with The Fuck 3.26 using Python 3.6.5

@scorphus scorphus self-assigned this May 2, 2018
@scorphus
Copy link
Collaborator

scorphus commented May 2, 2018

I managed to reproduce this on a fresh installation (Docker). I'll investigate this ASAP. Thank you for reporting.

scorphus added a commit to scorphus/thefuck that referenced this issue May 2, 2018
scorphus added a commit to scorphus/thefuck that referenced this issue May 2, 2018
@scorphus
Copy link
Collaborator

scorphus commented May 2, 2018

Fix is on its way. In the meantime, I guess you can use this temporary fix:

alias fish_key_reader /usr/local/bin/fish_key_reader

Please let me know if it works for you.

Edit: if the temporary fix doesn't work, try redeclaring with (space) every alias declared with = (equal sign):

alias foo echo  # declare like this
alias foo=echo  # instead of this

ps.: maybe you'd want to clear thefuck's cache with rm ~/.cache/thefuck

@Chris-W-Weir
Copy link

The temporary fix works for me after restarting my shell. Thanks!

@DmitriK
Copy link

DmitriK commented May 3, 2018

I have this issue, but I don't think the fix works for me, although I may not be applying it right. I tried adding it to the ~/.config/fish/functions/fuck.fish function, as well as running it separately, and the error was still the same.
Additionally, I have not defined any aliases for my shell, so there are no '=' for me to remove. Running 'alias' returns nothing except for the alias from the temporary fix.

@scorphus
Copy link
Collaborator

scorphus commented May 3, 2018

@DmitriK I'm sorry to read that. Maybe you stumbled over another issue? Can you please post the output with the error with THEFUCK_DEBUG set to true and exported? (aka set -x THEFUCK_DEBUG true)

@DmitriK
Copy link

DmitriK commented May 3, 2018

Sure, output follows. I know thefuck was working very recently, as I had run into #730, and everything worked when I fixed the environment variable mentioned in that issue. Something about my setup changed recently to cause this, but I'm not sure exactly what. For what it's worth, I'm on ArchLinux

DEBUG: Run with settings: {'alter_history': True,
 'debug': True,
 'env': {'GIT_TRACE': '1', 'LANG': 'C', 'LC_ALL': 'C'},
 'exclude_rules': [],
 'history_limit': None,
 'instant_mode': False,
 'no_colors': False,
 'priority': {},
 'repeat': False,
 'require_confirmation': True,
 'rules': [<const: All rules enabled>],
 'slow_commands': ['lein', 'react-native', 'gradle', './gradlew', 'vagrant'],
 'user_dir': PosixPath('/home/dmitri/.config/thefuck'),
 'wait_command': 3,
 'wait_slow_command': 15}
DEBUG: Total took: 0:00:00.100589
Traceback (most recent call last):
  File "/usr/bin/thefuck", line 12, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/thefuck/entrypoints/main.py", line 25, in main
    fix_command(known_args)
  File "/usr/lib/python3.6/site-packages/thefuck/entrypoints/fix_command.py", line 36, in fix_command
    command = types.Command.from_raw_script(raw_command)
  File "/usr/lib/python3.6/site-packages/thefuck/types.py", line 81, in from_raw_script
    expanded = shell.from_shell(script)
  File "/usr/lib/python3.6/site-packages/thefuck/shells/generic.py", line 30, in from_shell
    return self._expand_aliases(command_script)
  File "/usr/lib/python3.6/site-packages/thefuck/shells/fish.py", line 65, in _expand_aliases
    aliases = self.get_aliases()
  File "/usr/lib/python3.6/site-packages/thefuck/shells/fish.py", line 60, in get_aliases
    raw_aliases = _get_aliases(overridden)
  File "/usr/lib/python3.6/site-packages/thefuck/utils.py", line 33, in wrapper
    memo[key] = fn(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/thefuck/utils.py", line 267, in wrapper
    return _cache.get_value(fn, depends_on, args, kwargs)
  File "/usr/lib/python3.6/site-packages/thefuck/utils.py", line 243, in get_value
    value = fn(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/thefuck/shells/fish.py", line 25, in _get_aliases
    name, value = alias.replace('alias ', '', 1).split(' ', 1)
ValueError: not enough values to unpack (expected 2, got 1)

@DmitriK
Copy link

DmitriK commented May 3, 2018

I did some brute force debugging by adding some logging directly to the fish.py file where the exception occurs. On my system, 'alias_out' is an empty byte string, presumably because I don't generate aliases elsewhere, and a fresh instance of fish is spawned by Popen.

Anyway, I directly applied the diff in the PR to my copy, and that does fix the issue for me since the split length is checked explicitly. I'll keep the patch in there until an official package gets out.

scorphus added a commit that referenced this issue May 3, 2018
@scorphus
Copy link
Collaborator

scorphus commented May 3, 2018

Thanks for your inputs, @DmitriK! I've updated the fix and tests based on them. Also thanks for confirming it works on your side too. Please review and comment on it (#808).

@kristleifur
Copy link

kristleifur commented May 8, 2018

Hi there! I'm hitting something similar too. The alias fish_key_reader fix doesn't seem to work for me. Defined with a space. No other aliases exist. Fish 2.7.1 on MacOS X 10.13.4, using thefuck --HEAD from Homebrew. Output attached, including thefuck debug stuff.

fishfuckkfail.txt

Thanks a million for thefuck btw! Please let me know how I can help.

scorphus added a commit that referenced this issue May 11, 2018
@kristleifur
Copy link

I grabbed fish.py from commit dba7a8d and dropped it in /usr/local/Cellar/thefuck/HEAD-97f2d74/libexec/lib/python3.6/site-packages/thefuck/shells :)

Everything is fine now. Thanks!!

@nvbn nvbn closed this as completed in #808 May 13, 2018
nvbn pushed a commit that referenced this issue May 13, 2018
* #N/A: Remove `pip` from requirements.txt

* #807: Expect aliases declared with equal sign too

This fixes #807
@jrr
Copy link

jrr commented May 21, 2018

Will this be released (and published to homebrew) soon?

@nvbn
Copy link
Owner

nvbn commented May 22, 2018

@jrr the fix is included in 3.27, should be available in homebrew soon

riley-martine pushed a commit to riley-martine/thefuck that referenced this issue Dec 7, 2023
* #N/A: Remove `pip` from requirements.txt

* nvbn#807: Expect aliases declared with equal sign too

This fixes nvbn#807
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants