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

Initialize _fisher_plugins using fish_plugins file (#741) #746

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

charego
Copy link

@charego charego commented Oct 29, 2022

This change is for users who commit fish_plugins and plugin sources but omit fish_variables.

On a system where Fisher's universal variables are unset, most Fisher commands do not work out-of-the-box:

  • fisher list [<regex>]
    • returns nothing
  • fisher remove repo/plugin
    • fails with error: "Plugin not installed: repo/plugin"
  • fisher update repo/plugin
    • fails with error: "Plugin not installed: repo/plugin"
  • fisher update
    • fails with error about conflicting files, deletes fish_plugins file
  • fisher install repo/plugin
    • if fish_plugins contains the plugin, same behavior as bare fisher update
    • otherwise, installs the plugin, rewrites fish_plugins file with only "repo/plugin"

As of this commit all Fisher commands work except for fisher remove. Fisher still has no way of knowing which files to remove absent the universal variable that tracks the files associated to a plugin. It may make sense to reject calls like fisher remove repo/plugin if the _fisher_repo_2F_plugin_files universal variable is missing. Fisher could suggest the user run fisher update and try again.

Note: I haven't really investigated how this works with local plugins since I don't use those.

Attempt to fix #741.

@charego
Copy link
Author

charego commented Feb 9, 2023

Bump for further consideration, @jorgebucaran. Thanks.

@jorgebucaran
Copy link
Owner

I have been addressing and investigating issues all weekend, so I am taking a break for now. However, I wanted to let you know that I will certainly look into this matter soon and will incorporate this change (or a similar one, as I'm not certain this will be merged as is) before Fisher 5. This should occur in the not-too-distant future. 🙏

@ZuBB
Copy link
Contributor

ZuBB commented Aug 18, 2023

Is the issue described here possibly related to one I have?

vv@my-precious ~/.config/fish/conf.d $ fisher install oh-my-fish/plugin-bang-bang
fisher install version 4.4.3
Fetching https://api.github.com/repos/oh-my-fish/plugin-bang-bang/tarball/HEAD
fisher: Invalid plugin name or host unavailable: "oh-my-fish/plugin-bang-bang"
vv@my-precious ~/.config/fish/conf.d $ ll

@jorgebucaran
Copy link
Owner

I doubt it. It might be related to the curl or tar version or your OS. What's your OS, distro, and the curl and tar version you're using?

if command curl --silent -L \$url | command tar -xzC \$temp -f - 2>/dev/null
command cp -Rf \$temp/*/* $source
else
echo fisher: Invalid plugin name or host unavailable: \\\"$plugin\\\" >&2
command rm -rf $source
end

@ZuBB
Copy link
Contributor

ZuBB commented Aug 19, 2023

I doubt it. It might be related to the curl or tar version or your OS. What's your OS, distro, and the curl and tar version you're using?

its latest macos with m1 chip

vv@my-precious ~/work/own/careerpartner/src $ curl -V
curl 7.88.1 (x86_64-apple-darwin22.0) libcurl/7.88.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.51.0
Release-Date: 2023-02-20
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL threadsafe UnixSockets
vv@my-precious ~/work/own/careerpartner/src $ tar --version
bsdtar 3.5.3 - libarchive 3.5.3 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8 
vv@my-precious ~/work/own/careerpartner/src $ 

@ZuBB
Copy link
Contributor

ZuBB commented Aug 19, 2023

okay, I figured it out

#771

This change is for users who commit fish_plugins and plugin sources but
omit fish_variables. On a system where Fisher's universal variables are
unset, most Fisher commands were not working out-of-the-box:

* `fisher install <plugin>` - installs <plugin>, rewrites fish_plugins file with only <plugin>
                            - if <plugin> is in fish_plugins, same behavior as `fisher update`
* `fisher remove  <plugin>` - fails with error: Plugin not installed "<plugin>"
* `fisher update  <plugin>` - fails with error: Plugin not installed "<plugin>"
* `fisher update`           - fails with error about conflicting files, deletes fish_plugins file
* `fisher list   [<regex>]` - returns nothing

As of this commit all Fisher commands work except for `fisher remove`;
Fisher still has no way of knowing which files to remove absent the
universal variable that tracks the files associated to a plugin.

It may make sense to reject calls like `fisher remove <plugin>` if the
`_fisher_<plugin>_files` universal variable is missing. Fisher could
suggest the user run `fisher update` and try again.
@jorgebucaran
Copy link
Owner

@charego Sorry, but can you break down the main goal and reason for this PR again? Why's it a must-have?

@charego
Copy link
Author

charego commented Aug 22, 2023

Essentially, how to use Fisher with dotfiles? Is there a best practice as you see it? The instructions are geared toward interactive use. I would like to bootstrap Fisher from dotfiles on a new machine without interactive use.

@o-az
Copy link

o-az commented Mar 19, 2024

Essentially, how to use Fisher with dotfiles? Is there a best practice as you see it? The instructions are geared toward interactive use. I would like to bootstrap Fisher from dotfiles on a new machine without interactive use.

Same here. I would like to use Fisher declaratively through Nix Home Manager. Haven't had any luck so far.

@jorgebucaran
Copy link
Owner

Honestly, the reason I haven't been able to work on this is because I don't understand the aim at a fundamental level. Do you just want Fisher to fail silently if universal variables are not set?

@itsfarseen
Copy link

itsfarseen commented Mar 29, 2024

@jorgebucaran, from what I understand, the idea is to not use fish_variables to store fisher state as some of us don't commit fish_variables to our dotfiles repo.

So our options are:

  • Reconstruct the state from the fish_plugins file and the list of installed files in ~/.config/fish/;
  • Provide a flag to fisher update that would let us overwrite the files present in ~/.config/fish, but absent in fish_variables.

The reason we don't commit fish_variable is that it'll contain state that's only relevant to one machine.

For example, mine contains a bunch of variables set by Z that points to folders in my home dir, and the home dir will be different in different machines because of different usernames.

@itsfarseen
Copy link

@jorgebucaran One more thing to consider before merging this, maybe we should commit fish_variables to the dotfiles repo.

Plugins should not store non-portable data in fish_variables.

For reference:
#611
jethrokuan/z#104

itsfarseen added a commit to itsfarseen/dotfiles that referenced this pull request Mar 29, 2024
@jorgebucaran
Copy link
Owner

@itsfarseen from what I understand, the idea is to not use fish_variables to store fisher state as some of us don't commit fish_variables to our dotfiles repo.

That sounds a lot like #611. Fisher preserves the '~' in paths when saving plugins to the universal state, making it safer to commit fish_variables. While it might not be perfect, it does prevent committing data that obviously varies across machines, such as different usernames or home directories. What else are we missing?

@itsfarseen
Copy link

@jorgebucaran

Fisher preserves the '~' in paths when saving plugins to the universal state

Yes, but Z doesn't. And possibly other plugins too.

OP's solution to this is to not commit fish_variables to the dotfiles repo.

My opinion is that, ideally we should ask Z and other problematic plugins to implement proper handling of fish_variables, instead of trying to make fisher work with missing fish_variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Committing plugin source files (completions, conf.d, functions, themes) is not supported
5 participants