[Bug] Fallback handling of pathman failure (e.g. permission denied)
What were you trying to install (or what else went wrong)?
Any webi package.
Background
Well, lately I've been messing around with the nix package manager which builds some dependencies and also dotfiles and links them in the place they should go, for example, the zsh package actually creates readonly .zshrc and .zshenv and .zprofile files. The package manager is pretty cool for a lot of things, but the readonly natures comes from it trying to be "pure" and functional etc, which... sometimes ends up bugging me because I might want to create a change to my path on the fly, but I need to generate the configs again. Anyway, that's all a side-note.
What exactly did you do?
curl -sS https://webinstall.dev/awless | bash
What went wrong?
The problem I noticed with readonly dotfiles managed with this, is when I go to install something with webi or the curl installer, is that pathman tries to add ~/.local/bin to the path on each installer, which fails with
Saved as /Users/creedh/Downloads/awless-darwin-amd64.tar.gz
Extracting /Users/creedh/Downloads/awless-darwin-amd64.tar.gz
Installing to /Users/creedh/.local/opt/awless-v0.1.11/bin/awless
failed to add "/Users/creedh/.local/bin" to PATH: open /Users/creedh/.zshrc: permission deniedInstalled 'awless' v0.1.11 as /Users/creedh/.local/bin/awless
failed to add "/Users/creedh/.local/bin" to PATH: open /Users/creedh/.zshrc: permission denied%
Now, maybe this issue actually belongs to pathman itself, but webi should probably know the situation also.
You might ask, well if using nix for packages why use Webi? Well, the reality is, not all packages are in nix and also, sometimes nix can be a little hard to work with and debug. I'm honestly thinking of migrating off of it. Plus, this may not be the only case where someone has a readonly .zshrc? I couldn't say for sure, but maybe certain dotfiles get managed by an organization (in which case maybe editing the path isn't even possible).
I wonder if there is a better way to handle this. Some thoughts:
- Handle a failed path "add" with a helpful message like "Failed to add
~/.local/binto your path, so your program may not be found by your OS. Consider addingPATH=.....", etc - In addition to a helpful message if it can't add the path, I wonder if it'd be possible to skip the attempt at adding if the directory is already found in the path. I imagine you could check the current path and determine what's there? Obviously I didn't dig into the implementation there, but I wonder if that'd make sense. I'd be happy to look at the source for Pathman too.
Which OS did you try on?
- [X] Mac
- [ ] Windows
- [ ] Linux
What type of computer (i.e. laptop, desktop, Raspberry Pi)?
- [X] Laptop or Desktop (amd64 / x86-64)
- [ ] Raspberry Pi (ARM-64)
- [ ] Other (please specify, if you know)
Hey Creed,
Sorry it's been so long without following up on this.
Why is permission denied? Did some other tool modify the permissions of .zshrc?
It does write everything to ~/.config/envman/PATH.env, so we could say
Add
source ~/.config/envman/PATH.enveach time you wish to use webi, or wherever your PATHs are updated.
Yeah. I mentioned in there that I had been using a tool called nix to manage some of my dotfiles, sort of as an experiment. I know it's probably not the most common case, but still possible.
Yeah, even just a message that says what to add to your path or what to source in the case that it couldn't write to the file.
I still don’t understand.
why is it read only?
why not just make it read-write?
Agreed that a what-to-source message would be good.
I think that would belong in pathman.
I still don’t understand.
why is it read only?
why not just make it read-write?
I know. It's kind of weird. It's part of the nix "pure" functional style where it's outputs are "immutable". I'm not saying it's how I like things, and personally I'm working on migrating my dotfiles out of nix now, because it kept getting in the way (like this for example). Sure, I could write a script to change the generated files to read-write, but eh. I think it's just the nix way and I dont really want to mess with it. Overall, this wont be much a problem for me in the future, but yeah. Figured it should still have some graceful handling/messaging.
@creedasaurus, please check out #612 and give me your suggestions. Now is the time to fix this.
@creedasaurus Have you tried since earlier this year?
Closing since I don't think this is currently an issue, but feel free to reopen.