bevry / dorothy

🧙🏻‍♀️ Bring your dotfile commands and configuration to any shell. Sensible defaults and hundreds of commands preloaded. Supports Bash, Zsh, Fish, Nu, Xonsh, Elvish, Dash, KornShell, macOS, Linux, Windows.
Other
296 stars 23 forks source link

Bug: crashes in `setup-environment-commands` due to misbehaving ecosystems causes `sources/environment.*` to be empty #235

Closed oscarvarto closed 2 weeks ago

oscarvarto commented 1 month ago

I am working on macOS Sonoma 14.5.

I tried doing a reinstall of Dorothy after removing ~/.local/share/dorothy and ~/.config/dorothy. After running the install command from the README.md:

bash -ic "$(curl -fsSL https://dorothy.bevry.me/install)"

from my terminal (no matter if I use nu/fish) I get a problem in fish shell. The sourcing of:

source '/Users/oscarvarto/.local/share/dorothy/init.fish' # Dorothy

is added at the end of my config.fish and then whenever I open fish, I get a lot of error messages:

fish: Unknown command: get-terminal-theme
~/.local/share/dorothy/sources/login.fish (line 37): 
get-terminal-theme --clear-cache
^~~~~~~~~~~~~~~~~^
from sourcing file ~/.local/share/dorothy/sources/login.fish
    called on line 11 of file ~/.local/share/dorothy/init.fish
from sourcing file ~/.local/share/dorothy/init.fish
    called on line 126 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
    called during startup
fish: Unknown command: command-exists
~/.local/share/dorothy/sources/ssh.fish (line 10): 
if command-exists gpg
   ^~~~~~~~~~~~~^
from sourcing file ~/.local/share/dorothy/sources/ssh.fish
    called on line 12 of file ~/.local/share/dorothy/sources/interactive.fish
from sourcing file ~/.local/share/dorothy/sources/interactive.fish
    called on line 13 of file ~/.local/share/dorothy/init.fish
from sourcing file ~/.local/share/dorothy/init.fish
    called on line 126 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
    called during startup
fish: Unknown command: command-exists
~/.local/share/dorothy/sources/ssh.fish (line 15): 
if command-exists ssh-agent
   ^~~~~~~~~~~~~^
from sourcing file ~/.local/share/dorothy/sources/ssh.fish
    called on line 12 of file ~/.local/share/dorothy/sources/interactive.fish
from sourcing file ~/.local/share/dorothy/sources/interactive.fish
    called on line 13 of file ~/.local/share/dorothy/init.fish
from sourcing file ~/.local/share/dorothy/init.fish
    called on line 126 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
    called during startup
fish: Unknown command: command-exists
~/.local/share/dorothy/sources/autocomplete.fish (line 14): 
if test "$AUTOCOMPLETE_TEA" != 'no' && command-exists tea
                                       ^~~~~~~~~~~~~^
from sourcing file ~/.local/share/dorothy/sources/autocomplete.fish
    called on line 13 of file ~/.local/share/dorothy/sources/interactive.fish
from sourcing file ~/.local/share/dorothy/sources/interactive.fish
    called on line 13 of file ~/.local/share/dorothy/init.fish
from sourcing file ~/.local/share/dorothy/init.fish
    called on line 126 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
    called during startup
fish: Unknown command: command-exists
~/.local/share/dorothy/sources/autocomplete.fish (line 25): 
if command-exists carapace
   ^~~~~~~~~~~~~^
from sourcing file ~/.local/share/dorothy/sources/autocomplete.fish
    called on line 13 of file ~/.local/share/dorothy/sources/interactive.fish
from sourcing file ~/.local/share/dorothy/sources/interactive.fish
    called on line 13 of file ~/.local/share/dorothy/init.fish
from sourcing file ~/.local/share/dorothy/init.fish
    called on line 126 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
    called during startup
fish: Unknown command: command-exists
~/.local/share/dorothy/sources/interactive.fish (line 16): 
if command-exists shuf
   ^~~~~~~~~~~~~^
from sourcing file ~/.local/share/dorothy/sources/interactive.fish
    called on line 13 of file ~/.local/share/dorothy/init.fish
from sourcing file ~/.local/share/dorothy/init.fish
    called on line 126 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
    called during startup
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

I realized that moving the line:

source '/Users/oscarvarto/.local/share/dorothy/init.fish' # Dorothy

at the beginning of my config.fish gets rid of the error messages, but I think the first time I installed dorothy this wasn't a problem. So, I think I haven't found a way to do a complete uninstall of Dorothy to get the things the way they were at the beginning to start over. This is not good 🫤.

Why there is no easy way to completely uninstall Dorothy and possibly start from scratch?

=== On the other hand, Dorothy injects a lot of entries to my PATH, which I find very inconvenient, because I loose control of the expected behavior of my programs. E.g. it injected the path to XCode stuff, but then the compilation process for vterm in Emacs (needing a C compiler) failed to find stdlib.h. I had to remove the sourcing of Dorothy, make emacs read my original PATH again, and do the compiling process correctly.

oscarvarto commented 1 month ago

Now I will try to find the places where dorothy is referenced for several shells in my system and delete them. Maybe they are not in the right place?? Don't know for sure.

balupton commented 1 month ago

I'll be home in two hours. If you are available then, I could remote in and find out what is going on.

oscarvarto commented 1 month ago

Oh that would be awesome, but it’s almost 4:00 a.m. for me, and I haven’t slept while trying to fix issues (and I will need to work soon). I need to get at least some sleep. But we can probably do it on a more convenient time for both (please!) Thanks. I think Dorothy is good. I was using some stuff for ni shell.
On Thu, Jul 11, 2024 at 3:49 a.m., Benjamin Lupton @.***> wrote: I'll be home in two hours. If you are available then, I could remote in and find out what is going on.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

balupton commented 1 month ago

Okay, grab anytime on https://cal.com/balupton/call and we'll arrange a time. Sleep well

balupton commented 1 month ago

Join Zoom Meeting https://us05web.zoom.us/j/9855647764?pwd=Mll2RWc0M3M4NzhnOTdIck5oVHNYZz09

Meeting ID: 985 564 7764 Passcode: liberty53k

balupton commented 1 month ago

Actually, zoom just booted me and wants me to wait 6 minutes before starting a new meeting.

balupton commented 1 month ago

Okay, back in zoom

oscarvarto commented 1 month ago

I had some internet connectivity issues. Like I said in the call, my mother's in law service is bad :(

balupton commented 1 month ago

So it was definitely zoom hitting the 40m mark originally, then updating to v6 of the zoom client on my end caused me to have to wait 10 minutes or so before starting a zoom meeting. But now def internet connection issues.

So it was yarn not following standard conventions that caused the setup-environment-commands to fail, in which environment.fish was not detecting that failure and proceeding as if everything was okay, which it was not.

You can send a PR with those changes ~/.local/share/dorothy and I'll get them merged, as well as look into better error detection and handling so such failures are not silent.

For where you are at now, you can start moving things from ~/.config/fish/config.fish that ~/.local/share/dorothy/commands/setup-environment-commands doesn't already handle into your Dorothy User Config ~/.config/dorothy/config/interactive.fish file, e.g. https://github.com/bevry/dorothy/blob/master/config/interactive.fish and https://github.com/edmcman/dotfiles/blob/main/config/interactive.fish

If you want your environment changes to be cross-shell compatible, put them in /.config/dorothy/config/environment.bash instead (which is sourced by setup-environment-commands which converts it to a cross-shell compatible format), e.g. https://github.com/bevry/dorothy/blob/master/config/environment.bash and https://github.com/balupton/dotfiles/blob/main/config/environment.bash

Lastly, you'll want to git init and setup a repo for your ~/.config/dorothy directory, which is your Dorothy User Config. I will need to update Dorothy's install script to detect repository renames, and if so, prompt the user if they want to follow the direct or setup a new repo, as was the case for you where dotfiles became old-dot-files

So my todos:

oscarvarto commented 1 month ago

Thanks, @balupton for your help and patience. I'll try to do the MR soon.

balupton commented 1 month ago

Merged! Will get to the other tasks over the coming weeks.

balupton commented 2 weeks ago

Note the push fix for this, the detection of the crash and its human readable advice, is only applicable to posix shells and fish. Other shells will need someone experienced with those shells to implement the necessary support in their environment.* files