jorgebucaran / fisher

A plugin manager for Fish
https://git.io/fisher
MIT License
7.68k stars 262 forks source link

"Cannot create copy 'fish_user_key_bindings'" when launching fish #490

Closed dan-blanchard closed 5 years ago

dan-blanchard commented 5 years ago

I recently upgrade to fisher 3.1.1 from 2.x and I keep getting this error message when launching fish:

functions: Function 'fish_user_key_bindings_copy' already exists. Cannot create copy 'fish_user_key_bindings'
~/.config/fish/functions/fisher.fish (line 96):
        functions -c fish_user_key_bindings fish_user_key_bindings_copy
        ^
in function '_fisher_copy_user_key_bindings'
    called on line 52 of file ~/.config/fish/functions/fisher.fish

in function 'fisher'
    called on line 1 of file ~/.config/fish/conf.d/fisher.fish
    with parameter list 'copy-user-key-bindings'

from sourcing file ~/.config/fish/conf.d/fisher.fish
    called on line 250 of file /usr/local/Cellar/fish/2.7.1/share/fish/config.fish

from sourcing file /usr/local/Cellar/fish/2.7.1/share/fish/config.fish
    called during startup

       functionsfunctions - print or erase functions
        -

   Synopsis
       functions [ -a | --all ] [ -n | --names ]
       functions [ -D | --details ] [ -v ] FUNCTION
       functions -c OLDNAME NEWNAME
       functions -d DESCRIPTION FUNCTION
       functions [ -e | -q ] FUNCTIONS...

functions: Type 'help functions' for related documentation

I have fish installed via Homebrew on macOS Mojave.

fish version: 2.7.1 fisher version: 3.1.1

jorgebucaran commented 5 years ago

Do you have any code in your config.fish making a copy of fish_user_key_bindings?

And did you see https://github.com/jorgebucaran/fisher/issues/482 and/or https://github.com/jorgebucaran/fisher/issues/450?

dan-blanchard commented 5 years ago

I migrated using the steps in the migration guide (i.e., not using fisher update). I missed #482 when I was searching, sorry. The error isn't exactly the same though. My config.fish is relatively simple:

### PATH ###
set default_path /usr/bin /usr/sbin /bin /sbin
set homebrew /usr/local/bin /usr/local/sbin
set brew_rbenv "/usr/local/var/rbenv/shims"
set -gx PATH $homebrew $brew_rbenv $default_path

### Ruby (rbenv) ###
set -gx RBENV_ROOT /usr/local/var/rbenv

# Spark
set -x SPARK_HOME /usr/local/Cellar/apache-spark/2.2.1/libexec/
set -x PYSPARK_DRIVER_PYTHON ipython

# Pyenv
status --is-interactive; and source (pyenv init -|psub)

# Make sure hub completions work
complete -c hub -w git

# Disable extra virualenv bits
set -x VIRTUAL_ENV_DISABLE_PROMPT 1

# Less highlighting style
set -g source_highlight_style_file $HOME/.source-highlight/esc-solarized.style

# aliases
alias ping="prettyping --nolegend"
alias preview="fzf --preview 'bat --color \"always\" {}'"
alias du="ncdu --color dark -rr -x --exclude .git --exclude node_modules"

# Fisher
if not functions -q fisher
    set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config
    curl https://git.io/fisher --create-dirs -sLo $XDG_CONFIG_HOME/fish/functions/fisher.fish
    fish -c fisher
end

# add support for ctrl+o to open selected file in VS Code
set -x FZF_DEFAULT_OPTS "--bind='ctrl-o:execute(code {})+abort'"
jorgebucaran commented 5 years ago

@dan-blanchard No worries. We're debugging this together. What about some script in your ~/.config/fish/conf.d that is copying your fish_user_key_bindings function?

Fisher can't copy your fish_user_key_bindings function because a copy already exists. The problem is, no copy should exist.

By the way, what's in your fish_user_key_bindings function?

dan-blanchard commented 5 years ago

The only mentions of fish_user_key_bindings in my .config directory are my fish/functions/fish_user_key_bindings.fish file:

function fish_user_key_bindings
    fzf_key_bindings
end

fish/functions/fisher.fish itself.

jorgebucaran commented 5 years ago

@dan-blanchard What is fzf_key_bindings? Can you produce the function definition?

functions fzf_key_bindings
dan-blanchard commented 5 years ago

It's from this fisher package: https://github.com/jethrokuan/fzf

jorgebucaran commented 5 years ago

@dan-blanchard That package doesn't define a function named fzf_key_bindings AFAIK. Instead, it provides key bindings via a conf.d snippet. Perhaps you are using an old version?

Regardless, can you produce the function definition? I'd like to see the definition to be sure it isn't doing anything odd.

One more thing, please run the following and show me what you get.

functions fish_user_key_bindings
functions fish_user_key_bindings_copy
dan-blanchard commented 5 years ago
~/D/d/.config/> functions fish_user_key_bindings
# Defined in /Users/dan/.config/fish/conf.d/fisher.fish @ line 4
function fish_user_key_bindings
    for file in $fisher_path/conf.d/*_key_bindings.fish
            source $file >/dev/null 2>/dev/null
        end
        if functions -q fish_user_key_bindings_copy
            fish_user_key_bindings_copy
        end
end

~/D/d/.config/> functions fish_user_key_bindings_copy
function fish_user_key_bindings_copy
    fzf_key_bindings
end

I just realized that I may have accidentally installed fzf key bindings twice (once via fisher and once via shell script that comes with the fzf Homebrew package). I'll try deleting the file that contains fzf_key_bindings and reinstalling the fisher fzf package.

dan-blanchard commented 5 years ago

Removing and reinstall the fzf recreated the file fish/conf.d/fzf_key_bindings.fish, and now I'm getting a host of errors that I wasn't before.

I think I'll have to try to wipe all the fisher stuff and reinstall again.

jorgebucaran commented 5 years ago

@dan-blanchard You don't need to remove and reinstall z, just running fisher would have done it.

And ~/.config/fish/conf.d/fzf_key_bindings.fish is definitely correct, that's how the package key bindings work, via a conf.d snippet as said above.

dan-blanchard commented 5 years ago

Reinstalling fresh made more of a mess of things, which lead me to discover that since I keep my .config directory on iCloud, it creates duplicate files with 2 suffixes on them if files get deleted and recreated before it can finish syncing (e.g., ./fish/functions/more 2.fish).

dan-blanchard commented 5 years ago

Okay, I'm going to chalk this up to me having installed the fzf keybindings both within and outside of fisher, since now that I've wiped everything fresh and reinstalled, I no longer have anything in functions fish_user_key_bindings_copy.

Thank you for helping me debug this!

jorgebucaran commented 5 years ago

@dan-blanchard I no longer have anything in functions fish_user_key_bindings_copy.

And do you still have the same output for functions fish_user_key_bindings?

dan-blanchard commented 5 years ago

Yup!