-
-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Issue
gitnow assumes that fisher installs plugin into user's $__fish_config_dir. This is not always the case.
If a $fisher_path is used, the plugin fails to load and produces a lot of error messages on fish startup.
How to reproduce:
- Set
$fisher_pathto a custom path, e.g.~/.local/share/fisher. - Install fisher:
curl ... - Load
$fisher_path/conf.dand add functions/completions to the appropriate paths in your own configuration as described in First-class support for$fisher_pathjorgebucaran/fisher#640. - Try to install gitnow and observe the failure:
$ fisher install joseluisq/gitnow@2.11.0
fisher install version 4.4.3
Fetching https://api.github.com/repos/joseluisq/gitnow/tarball/2.11.0
Installing joseluisq/gitnow@2.11.0
/home/liri/.local/share/fisher/functions/__gitnow_config_file.fish
/home/liri/.local/share/fisher/functions/__gitnow_functions.fish
/home/liri/.local/share/fisher/functions/__gitnow_manual.fish
/home/liri/.local/share/fisher/conf.d/gitnow.fish
/home/liri/.local/share/fisher/conf.d/gitnow_config.fish
/home/liri/.local/share/fisher/completions/__gitnow_completions.fish
GitNow version is installed and ready to use!
Just run the `gitnow` command if you want explore the API.
source: Error encountered while sourcing file '/home/liri/.config/fish/functions/__gitnow_functions.fish':
source: No such file or directory
source: Error encountered while sourcing file '/home/liri/.config/fish/functions/__gitnow_manual.fish':
source: No such file or directory
source: Error encountered while sourcing file '/home/liri/.config/fish/functions/__gitnow_config_file.fish':
source: No such file or directory
source: Error encountered while sourcing file '/home/liri/.config/fish/completions/__gitnow_completions.fish':
source: No such file or directory
Installed 1 plugin/s
I am pretty sure the issue is with gitnow_config.fish that tries to source fish functions directly. I am not sure why this is necessary.
Possible solutions
Check $fisher_path in gitnow_config.fish explicitly
Since $__fundle_plugins_dir is already queried in this file, checking $fisher_path could also be an option. This is how it looks on my PC after I install gitnow:
$ tree $fisher_path
/home/liri/.local/share/fisher
├── completions
│ ├── fisher.fish
│ └── __gitnow_completions.fish
├── conf.d
│ ├── gitnow_config.fish
│ └── gitnow.fish
├── functions
│ ├── fisher.fish
│ ├── __gitnow_config_file.fish
│ ├── __gitnow_functions.fish
│ └── __gitnow_manual.fish
└── themes
Make gitnow functions fish autoload-compliant
Don't explicitly source gitnow functions, and rely on $fish_function_path and other autoloaders to correctly load your plugin.
For backward compatibility that can be done with something like set -q __gitnow_dont_autoload.
This will require splitting existing gitnow function files into multiple files, one file per gitnow function:
__gitnow_config_file.fish__gitnow_read_config.fish__gitnow_get_clip_program.fish
__gitnow_functions.fish__gitnow_new_branch_switch.fish__gitnow_slugify.fish__gitnow_clone_repo.fish__gitnow_clone_msg.fish__gitnow_check_if_branch_exist.fish__gitnow_clone_params.fish__gitnow_gitflow_branch.fish__gitnow_msg_not_valid_repository.fish__gitnow_current_branch_name.fish__gitnow_current_branch_list.fish__gitnow_current_remote.fish__gitnow_is_git_repository.fish__gitnow_has_uncommited_changes.fish__gitnow_get_latest_tag.fish__gitnow_get_tags_ordered.fish__gitnow_get_latest_semver_release_tag.fish__gitnow_increment_number.fish__gitnow_get_valid_semver_release_value.fish__gitnow_get_valid_semver_prerelease_value.fish__gitnow_is_number.fish
See how fish autoloads functions.
Move gitnow functions from functions to conf.d subdirectory
These functions will be loaded once by the plugin system, since conf.d is automatically sourced. And if these functions are ordered correctly, for example
conf.d/__10_gitnow_config_file.fishconf.d/__10_gitnow_functions.fishconf.d/__90_gitnow_config.fish-- make sure this file is sorted after functions it relies on
This approach is not idiomatic in fish, but it will load these functions correctly, and there is no more need to source functions/*.fish files.