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

fish: Unknown command 'git_ahead' (OS X Yosemite) #217

Closed
Oikio opened this issue Dec 29, 2015 · 25 comments
Closed

fish: Unknown command 'git_ahead' (OS X Yosemite) #217

Oikio opened this issue Dec 29, 2015 · 25 comments

Comments

@Oikio
Copy link

Oikio commented Dec 29, 2015

Helo everyone,
I'm new to fish and after instalation omf on mac, when I'm inside folder representing git repository, I got this error after every command (commands work though):

fish: Unknown command 'git_ahead'
/Users/oikio/.local/share/omf/themes/default/fish_prompt.fish (line 6): git_ahead $ahead $behind $diverged $none
                                                                        ^
in command substitution
    called on line 50 of file '/Users/oikio/.local/share/omf/themes/default/fish_prompt.fish',

in function 'fish_prompt',
    called on standard input,

in command substitution
    called on standard input,
@oranja
Copy link
Contributor

oranja commented Dec 29, 2015

Which version of Fish is installed?
fish --version

@Oikio
Copy link
Author

Oikio commented Dec 29, 2015

fish, version 2.1.2

@oranja
Copy link
Contributor

oranja commented Dec 29, 2015

As discussed here, Fish 2.1.2 doesn't support the -V flag that OMF uses in the git helper functions (lib/git).
Can you please try to upgrade Fish to 2.2.0 and report back?

@Oikio
Copy link
Author

Oikio commented Dec 29, 2015

Oh, did not update my homebrew for some time.
Same error with 2.2.0, only lines changed (Also after I reinstalled omf):

~/.local/share/omf/themes/default/fish_prompt.fish (line 1): git_ahead $ahead $behind $diverged $none
                                                             ^
in command substitution
    called on line 4 of file ~/.local/share/omf/themes/default/fish_prompt.fish

in function 'fish_prompt'
    called on standard input

in command substitution
    called on standard input

@oranja
Copy link
Contributor

oranja commented Dec 29, 2015

I will leave this for a while, perhaps one of the team members will know what exactly is causing this problem.
If you don't get a response in the near future (or perhaps it won't hurt anyway), it might be helpful if you prepared some information on your environment:

  1. How did you install OMF?
  2. Did you try omf update?
  3. Does the refresh command help? Closing all instances of Fish and trying again?
  4. Can you post the output of echo $fish_function_path? and ls $OMF_PATH/lib/git?

@Oikio
Copy link
Author

Oikio commented Dec 29, 2015

Interesting, I've cloned several other repos to reproduce error there and it works fine, no error messages.
So I've tried to remove and clone buggy repo again but error is still reproducable.

  1. Installed using curl script as in readme:
    curl -L https://github.com/oh-my-fish/oh-my-fish/raw/master/bin/install | fish

  2. Tried omf update with and without omf packages installed.
    But with packages I get errors regarding foreign-env, maybe this could lead to a clue (I've preinstalled nvm and foreign-env):

Updating Oh My Fish...
Oh My Fish is up to date.
✔ foreign-env successfully updated.
Installing package foreign-env
' does not existy 'foreign-env
.ould not install package foreign-env
✔ nvm successfully updated.
Welcome to fish, the friendly interactive shell
  1. No

  2. echo $fish_function_path:

/Users/oikio/.local/share/omf/themes/default /Users/oikio/.local/share/omf/pkg/omf/util /Users/oikio/.local/share/omf/pkg/omf/cli /Users/oikio/.local/share/omf/pkg/omf /Users/oikio/.local/share/omf/pkg/nvm/functions /Users/oikio/.local/share/omf/pkg/nvm /Users/oikio/.local/share/omf/pkg/foreign-env/functions /Users/oikio/.local/share/omf/pkg/foreign-env /Users/oikio/.local/share/omf/pkg/fish-spec/functions /Users/oikio/.local/share/omf/pkg/fish-spec /Users/oikio/.local/share/omf/lib/git /Users/oikio/.local/share/omf/lib /usr/local/Cellar/fish/2.2.0/etc/fish/functions /usr/local/Cellar/fish/2.2.0/share/fish/functions

ls $OMF_PATH/lib/git:

git_ahead.fish       git_is_dirty.fish    git_is_staged.fish   git_is_touched.fish
git_branch_name.fish git_is_repo.fish     git_is_stashed.fish  git_untracked.fish

@derekstavis
Copy link
Member

How have you reinstalled? To completely destroy Oh My Fish you can rm -rf ~/{.config,.local/share}/omf, rm ~/.config/fish/config.fish and then close and reopen all your fish sessions. This should wipe the installation completely.

@Oikio
Copy link
Author

Oikio commented Dec 29, 2015

@derekstavis Yes, I removed them both, reopened fish session and reinstalled after that.

@oranja
Copy link
Contributor

oranja commented Dec 29, 2015

So just to make it clear... You get the same error in every git repository folder, even without installing any plugins or themes (only the default theme)?

@Oikio
Copy link
Author

Oikio commented Dec 30, 2015

@oranja No, just in one repository in any of it's folders with any command even without installing any plugins or themes.

@oranja
Copy link
Contributor

oranja commented Dec 30, 2015

I must admit that I'm clueless, so I'm just throwing ideas...
Is there anything different about this repo? Spaces in the path perhaps? or any irregular character?
Is it a private or a public project? Perhaps if you can share it we can try to replicate and debug first-hand.

@Oikio
Copy link
Author

Oikio commented Dec 30, 2015

It's just boilerplate for little project, it's name contains -, but other project with dashes works fine on my mac. I've pushed it here: https://github.com/Oikio/s-world

Also I've tried to reproduce this bug on archlinux, but it works fine.

@derekstavis
Copy link
Member

What does type git_ahead outputs? I also found that this part of your log looks very odd:

Installing package foreign-env
' does not existy 'foreign-env
.ould not install package foreign-env

existy, .ould isn't written anywhere on the framework, how is this happening?

@Oikio
Copy link
Author

Oikio commented Dec 30, 2015

type git_ahead outputs: type: Could not find 'git_ahead'

Odd log message appears on omf update, still reproducable after several reinstallations of omf and it's plugins.

@oranja
Copy link
Contributor

oranja commented Dec 30, 2015

And if you cd into a different repository's folder and execute type git_ahead?
Also, would you mind sharing the full path of the problematic repository?

@Oikio
Copy link
Author

Oikio commented Dec 31, 2015

Same message in other repositories, but sometimes (cannot find out after which steps) I get this on type git_ahead:

Expected a command, but instead found a pipe
~/.local/share/omf/lib/git/git_ahead.fish (line 8):     | awk "/>/ {a += 1} /</ {b += 1} \
                                                        ^
from sourcing file ~/.local/share/omf/lib/git/git_ahead.fish
    called on line 4 of file /usr/local/Cellar/fish/2.2.0/share/fish/functions/type.fish

in command substitution
    called on line 2 of file /usr/local/Cellar/fish/2.2.0/share/fish/functions/type.fish

in function 'type'
    called on standard input
    with parameter list 'git_ahead'

source: Error while reading file '/Users/oikio/.local/share/omf/lib/git/git_ahead.fish'
type: Could not find 'git_ahead'

Problematic repository path is /Users/oikio/Projects/s-world

@oranja
Copy link
Contributor

oranja commented Dec 31, 2015

OK, so I found a way to reproduce the last output. Can you please get an hexdump of git_ahead?
At least one of these should work on OS X:
xxd $OMF_PATH/lib/git/git_ahead.fish
or
hexdump -C $OMF_PATH/lib/git/git_ahead.fish

@Oikio
Copy link
Author

Oikio commented Dec 31, 2015

xxd $OMF_PATH/lib/git/git_ahead.fish:

0000000: 6675 6e63 7469 6f6e 2067 6974 5f61 6865  function git_ahe
0000010: 6164 202d 6120 6168 6561 6420 6265 6869  ad -a ahead behi
0000020: 6e64 2064 6976 6572 6765 6420 6e6f 6e65  nd diverged none
0000030: 0d0a 2020 6769 745f 6973 5f72 6570 6f3b  ..  git_is_repo;
0000040: 2061 6e64 2062 6567 696e 0d0a 2020 2020   and begin..    
0000050: 7465 7374 202d 7a20 2224 6168 6561 6422  test -z "$ahead"
0000060: 3b20 616e 6420 7365 7420 6168 6561 6420  ; and set ahead 
0000070: 222b 220d 0a20 2020 2074 6573 7420 2d7a  "+"..    test -z
0000080: 2022 6265 6869 6e64 223b 2061 6e64 2073   "behind"; and s
0000090: 6574 2062 6568 696e 6420 222d 220d 0a20  et behind "-".. 
00000a0: 2020 2074 6573 7420 2d7a 2022 6469 7665     test -z "dive
00000b0: 7267 6564 223b 2061 6e64 2073 6574 2064  rged"; and set d
00000c0: 6976 6572 6765 6420 22c2 b122 0d0a 2020  iverged ".."..  
00000d0: 2020 7465 7374 202d 7a20 226e 6f6e 6522    test -z "none"
00000e0: 3b20 616e 6420 7365 7420 6e6f 6e65 2022  ; and set none "
00000f0: 220d 0a20 2020 2063 6f6d 6d61 6e64 2067  "..    command g
0000100: 6974 2072 6576 2d6c 6973 7420 2d2d 6c65  it rev-list --le
0000110: 6674 2d72 6967 6874 2022 407b 7570 7374  ft-right "@{upst
0000120: 7265 616d 7d2e 2e2e 4845 4144 2220 5e2f  ream}...HEAD" ^/
0000130: 6465 762f 6e75 6c6c 205c 0d0a 2020 2020  dev/null \..    
0000140: 7c20 6177 6b20 222f 3e2f 207b 6120 2b3d  | awk "/>/ {a +=
0000150: 2031 7d20 2f3c 2f20 7b62 202b 3d20 317d   1} /</ {b += 1}
0000160: 205c 0d0a 2020 2020 2020 7b69 6620 2861   \..      {if (a
0000170: 203e 2030 2920 6e65 7874 6669 6c65 7d20   > 0) nextfile} 
0000180: 454e 4420 5c0d 0a20 2020 2020 207b 6966  END \..      {if
0000190: 2028 6120 3e20 3020 2626 2062 203e 2030   (a > 0 && b > 0
00001a0: 2920 7072 696e 7420 5c22 2464 6976 6572  ) print \"$diver
00001b0: 6765 645c 223b 205c 0d0a 2020 2020 2020  ged\"; \..      
00001c0: 656c 7365 2069 6620 2861 203e 2030 2920  else if (a > 0) 
00001d0: 7072 696e 7420 5c22 2461 6865 6164 5c22  print \"$ahead\"
00001e0: 3b20 5c0d 0a20 2020 2020 2065 6c73 6520  ; \..      else 
00001f0: 6966 2028 6220 3e20 3029 2070 7269 6e74  if (b > 0) print
0000200: 205c 2224 6265 6869 6e64 5c22 3b0d 0a20   \"$behind\";.. 
0000210: 2020 2020 2065 6c73 6520 7072 696e 7466       else printf
0000220: 205c 2224 6e6f 6e65 5c22 7d22 0d0a 2020   \"$none\"}"..  
0000230: 656e 640d 0a65 6e64 0d0a                 end..end..

@oranja
Copy link
Contributor

oranja commented Dec 31, 2015

This is a bit invasive, but will please try the following:
cat $OMF_PATH/lib/git/git_ahead.fish | tr -d \r > $OMF_PATH/lib/git/git_ahead.fish
and after that
refresh

Also, do you have core.autocrlf set in Git?
git config --list | grep core.autocrlf

Last thing, how is core.eol set?:
git config --list | grep core.eol

@derekstavis
Copy link
Member

Good idea, haha! That damn 0d0a could be the issue...

@oranja
Copy link
Contributor

oranja commented Jan 6, 2016

@Oikio any luck?

@Oikio
Copy link
Author

Oikio commented Jan 6, 2016

@oranja I've tried:
cat $OMF_PATH/lib/git/git_ahead.fish | tr -d \r > $OMF_PATH/lib/git/git_ahead.fish
And problem is gone, everything works fine now. Thank you!

In case you need more infomation for futher invatigation:
core.autocrlf=true
and there is no core.eol settings in git config.

@oranja
Copy link
Contributor

oranja commented Jan 6, 2016

Since you are working on a Mac, core.autocrlf=true is an odd choice.
It means that all Linux/Mac newlines (LF) are automatically converted by Git to Windows newlines (CR+LF) on checkout, and vice-versa. It is usually recommended for developers on working on Windows. As you have witnessed yourself, Windows newlines often confuse *nix tools.

It is generally recommended to set core.autocrlf to input on *nix machines, but perhaps you have your reasons for having it set to true. In this case, I suggest at least setting core.autocrlf=input as local project configuration in $OMF_PATH.

For more information and useful instructions:
https://help.github.com/articles/dealing-with-line-endings/#platform-mac
https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#Formatting-and-Whitespace

@Oikio
Copy link
Author

Oikio commented Jan 6, 2016

Yes it's odd, I'm already trying to find out why I've changed it to true. Anyway it looks like whatever I needed it for is not relevant now, so I've set it to input.

@derekstavis
Copy link
Member

Congrats @oranja! Thanks! Closing as its unrelated to omf.

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

3 participants