swiftly icon indicating copy to clipboard operation
swiftly copied to clipboard

Incorrect $PATH order when using Swiftly with oh-my-zsh / other PATH modifications

Open louisunlimited opened this issue 8 months ago • 1 comments

Hi! Swiftly seems to be a great addition to the ecosystem!

I noticed that currently the installer tries to read current shell info and appends what it need automatically, for me (zsh) it's:

# .zprofile
. "$HOME/.swiftly/env.sh"

This works if he shell is a login shell and no further PATH edits happen afterward. But in common setups the $PATH might be heavily appended and rebuilds $PATH, which might causes the Swiftly's shim to be at the end, making it ineffective. For my case, it looked like this, causing swiftly to not work because swift is not using swiftly ones.

which swift  # -> /usr/bin/swift
type -a swift
# swift is /usr/bin/swift
# swift is /Users/you/.swiftly/bin/swift

I was able to fix this by removing the line from .zprofile and to .zshrc which I use more often. I find that most other cli tools prompt adding to .zshrc instead of .zprofile so I thought perhaps it'll be good to at least prompt the user or give the user some choice to choose between rc and profile? I did notice some activity over at #255 regarding zprofile prompts, could this be a possible addition to that as well?

Mine setup might be a rare case but it just took me 2 hours to figure this out 🥲

louisunlimited avatar Mar 31 '25 08:03 louisunlimited

Thanks for reporting this. I think that swiftly should avoid .zshrc or .bashrc because they get sourced on every new shell process, which can slow things down. The profile files are sourced only by login shells, and not sub shells, but it should be inherited by the sub shells.

cmcgee1024 avatar Apr 01 '25 19:04 cmcgee1024