jorgebucaran / fisher

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

Multiple prompts? #629

Closed jorgebucaran closed 3 years ago

jorgebucaran commented 3 years ago

No, it's not really possible to use multiple prompts at the same time, but what happens if you do this:

fisher install ilancosman/tide matgreen/lucid.fish

Fisher will install Tide, then Lucid. Problem? Yes.

This is not usually an issue, because a good plugin will use a prefix like _foobar_ to "scope" functions and variables, but some special functions like fish_prompt, fish_right_prompt, etc., can't be named that way. This issue is clear for prompts. Above, when Lucid is installed, Lucid's fish_prompt.fish will overwrite Tide's fish_prompt.fish. What's even worse, Tide's fish_right_prompt will coexist with Lucid's fish_prompt!

The solution is, of course, to uninstall Tide before installing Lucid, and vice-versa (or when installing any prompt). The issue is, however, should we uninstall the current prompt by default when installing a new prompt? Should we not let you?

Checking if a plugin is probably a prompt is easy enough:

for file in $plugin/functions/fish_{,right_}prompt.fish
    if test -e $file
        # Plugin is a prompt
    end
end

This issue is similar but not the same as #624. There, we discuss dealing with a pre-existing user prompt, here, Fisher-managed prompts.

mattgreen commented 3 years ago

The issue extends beyond fish_prompt.fish to any file that might be contained in two plugins. Suppose plugin A uses a dependency called left-pad.fish, and plugin B does as well. When B is installed, what happens to left-pad.fish? When A is removed, does it remove left-pad.fish and leave B inoperable?

Two potential approaches:

  1. View a plugin plus all of its dependencies as a set of files. At install time, test the plugin-to-be-installed's set against the sets of installed plugins. If there is any overlap, abort the user to tell them about it. (To protect against the test case you mentioned, you really need to test the plugins being installed against each other.)

  2. Install each plugin to a separate directory, and use $fish_function_path as an overlay as mentioned on the other thread. Even there, there are still determinism issues around the ordering of plugins on $fish_function_path, so you'd likely want to warn users.

jorgebucaran commented 3 years ago

When B is installed, what happens to left-pad.fish? When A is removed, does it remove left-pad.fish and leave B inoperable?

Fish doesn't have other scope but global, so a good plugin will use a prefix like _foobar_ to "scope" functions and variables.
Even using the overlay approach, (fyi that's how Fisher 1.x used to work), you'd still run into the same issue I described above where Tide's fish_right_prompt would coexist with Lucid's fish_prompt, thus you'd still want to uninstall Tide before installing Lucid. There's a precedent for that as well in Fisher 1.x and 2.x, but I am not sure if I want to bring that back.

IlanCosman commented 3 years ago

I'm not sure as to this specific scenario, but in general I'd say it's okay to let users screw their configuration up with bad choices. Protecting the user from every issue that could arise will cause massive code expansion. This case is fairly common though so idk.

jorgebucaran commented 3 years ago

Closing for the same reason given in #638.