Skip to content

Add fish startup flag --no-config, take 2 - #5417

Closed
mqudsi wants to merge 1 commit into
fish-shell:masterfrom
mqudsi:no-config2
Closed

mqudsi wants to merge 1 commit into
fish-shell:masterfrom
mqudsi:no-config2

Conversation

@mqudsi

@mqudsi mqudsi commented Dec 15, 2018 •

Copy link
Copy Markdown
Contributor

This prevents fish from loading the user configuration file, both at
startup and at any point thereafter, in both interactive and
non-interactive modes.

As fish relies extensively on $__fish_config_dir for core
functionality (universal variables), this is achieved by creating a new
runtime path (using the existing code to do so) to serve as the user
config dir.


Either this or #5416 should be merged, depending on how far we want to take this.

This prevents fish from loading the user configuration file, both at
startup and at any point thereafter, in both interactive and
non-interactive modes.

As fish relies extensively on `$__fish_config_dir` for core
functionality (universal variables), this is achieved by creating a new
runtime path (using the existing code to do so) to serve as the user
config dir.
@ridiculousfish

Copy link
Copy Markdown
Member

What is this for?

@floam

floam commented Dec 15, 2018 •

Copy link
Copy Markdown
Member

I think to get a one-off unconfigured fish. Like, what env HOME=(mktemp -d) fish does.

@mqudsi

mqudsi commented Dec 17, 2018

Copy link
Copy Markdown
Contributor Author

The primary reason is that currently there's no way to distribute reproducible fish scripts. The behavior of a invoking a non-interactive fish script relies heavily on the user's config.fish file, which breaks fish-based packages. c.f. #5246 and others. (cc @jorgebucaran)

Secondarily, it allows testing fish in a stock fashion without the user configuration influencing anything. env HOME=(mktemp -d) does not work because it breaks launching a great number of external tasks as they are created with the wrong $HOME.

More generally, it's an alternative approach to @faho's #5394, which at the very least gives the user an option of expliictly not reading config.fish even if the default is to do so.

@Jomik

Jomik commented Dec 25, 2018

Copy link
Copy Markdown
Contributor

Useful for cases like using fish in a nix build step, seen in my dotfiles

@mqudsi

mqudsi commented Feb 10, 2019

Copy link
Copy Markdown
Contributor Author

Actually, our own github issue template recommends that users reproduce their issue with a clean configuration via env HOME=(mktemp -d) fish, which can break their own apps if they try to source anything from $HOME while reproducing the problem (on second thought, maybe that's good because it gives us a more reproducible result).

This could also take the place of that.

@faho

faho commented Mar 13, 2019

Copy link
Copy Markdown
Member

Okay, so this one picks $XDG_RUNTIME_DIR as config directory, thereby bypassing ~/.config/fish/config.fish.

That also stops the uvars and the conf snippets in ~/.config/fish/conf.d from being read, and the functions/completions from showing up in the path variables.

So far, so good.

However, it also

  • blocks history

  • sets $__fish_config_dir, so you can't use the default if you wanted to (but that also stops third-party scripts from using them)

I'm not sure about either of these. It doesn't seem like config really has anything to do with history, but I'm not sure what users typically expect here. Stopping third-party scripts from still accessing the config if you've disabled it seems like the correct thing, but I'm not sure if it's not better to allow access to the config if something really wants? What if this leads to people hardcoding ~/.config/fish? (Then again bash doesn't mask $HOME, and its config file is simply ~/.bashrc)

Also, this is already a problem with env_get_runtime_path(), but $XDG_RUNTIME_DIR isn't directly usable as a fish directory. On my system it's /run/user/$uid, so fish would just directly dump /run/user/1000/fish_variables in there. This would also mean all fish processes (of the same user) running without config would share uvars, which I don't think we want? (If $XDG_RUNTIME_DIR isn't set, this uses /tmp/fish.($USER) - which would also share uvars, but at least wouldn't clash with other programs using the tmp directory)

I imagine the way to go about it is to disable uvar persistence entirely when run without config.

@mqudsi

mqudsi commented Mar 21, 2019

Copy link
Copy Markdown
Contributor Author

Also, this is already a problem with env_get_runtime_path(), but $XDG_RUNTIME_DIR isn't directly usable as a fish directory.

Yes, I ran into that. I thought it was just a bad configuration on my end. We need to create a random directory within that folder and use that. It would be great if we had a way to delete it on exit as well.

I imagine the way to go about it is to disable uvar persistence entirely when run without config.

Do you know of an easy way to do that?

@faho

faho commented Mar 25, 2019

Copy link
Copy Markdown
Member

It would be great if we had a way to delete it on exit as well.

I'd recommend against that. These dirs should be cleaned up by the system if it wants. E.g. on my system /tmp and /run are on tmpfs (i.e. non-persistent) and /run is defined to be.

I'm always wary of deleting anything, because if that goes wrong it goes wrong badly.

Do you know of an easy way to do that?

I would imagine, from a cursory reading, inhibiting env_stack_t::universal_barrier() in env.cpp would inhibit writing, but if I'm reading this correctly it reads the uvars once the env_universal_t is created?

Simply setting that to NULL won't work because we should still set universal variables internally (can't have set -U var val fail to set $var to val). It just can't sync.

@mqudsi

mqudsi commented Apr 1, 2019

Copy link
Copy Markdown
Contributor Author

With regards to the latter part of your comment: yes, and I imagine a lot of other hidden gotchas would pop up if we tried to disable certain values. So my idea was to let it read (and write) whatever it wants, just from a pristine environment.

@floam

floam commented Apr 3, 2019

Copy link
Copy Markdown
Member

Maybe there is a different way: allow the user to specify the config locations. They could point it at /dev/null

@floam

floam commented Apr 3, 2019 •

Copy link
Copy Markdown
Member

Maybe fish-specific environment variables.

@Jomik

Jomik commented Apr 4, 2019

Copy link
Copy Markdown
Contributor

Maybe there is a different way: allow the user to specify the config locations. They could point it at /dev/null

I would like this more, tbh. Because it'd be a nice way to make a declarative fish installation with Nix.

@mqudsi

mqudsi commented Apr 4, 2019

Copy link
Copy Markdown
Contributor Author

Unfortunately/dev/null cannot be supplied as a parameter to system functions expecting a directory.

@Jomik

Jomik commented Apr 4, 2019

Copy link
Copy Markdown
Contributor

I think you'd probably want an error if you give --config a file that does not exist. But --no-config could "easily" just point at the default config file that ships with fish.

@mqudsi

mqudsi commented Apr 4, 2019

Copy link
Copy Markdown
Contributor Author

I understand what you're saying but the blocker here isn't about where the actual config file itself (config.fish) comes from but rather the runtime directory fish uses to store state on-disk after loading the state from the file (or no file) in question.

I should explain that the entire point of this branch is to add a feature which would enable reproducible builds (among other things). Subsequent runs of fish with --no-config should be deterministic and present the same state (not accounting for users explicitly changing the system configuration, as this is not a sandbox).

Comment thread src/fish.cpp Resolved
@faho

faho commented May 28, 2019

Copy link
Copy Markdown
Member

Closing this one for now, since there's some issues that need to be addressed before it is ready to merge.

@faho faho closed this May 28, 2019
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants