pkgx icon indicating copy to clipboard operation
pkgx copied to clipboard

Infinite loop with symlink to tea in the cwd

Open magnusviri opened this issue 3 years ago • 1 comments

tea 0.14.1

ln -s ~/.tea/tea.xyz/v\*/bin/tea tea_gum
./tea_gum

Every second or so it will launch another instance of tea. It looks like this:

51965 s005  S+     0:01.48 /Users/james/Tea/gum
51966 s005  S+     0:01.47 /Users/james/Tea/gum
51970 s005  S+     0:01.48 /Users/james/Tea/gum
51975 s005  S+     0:01.48 /Users/james/Tea/gum
52001 s005  S+     0:01.47 /Users/james/Tea/gum
52002 s005  S+     0:01.62 /Users/james/Tea/gum
52011 s005  S+     0:01.51 /Users/james/Tea/gum
52030 s005  S+     0:01.51 /Users/james/Tea/gum
52046 s005  S+     0:01.65 /Users/james/Tea/gum
52072 s005  R+     0:00.45 /Users/james/Tea/gum

It will keep doing this until canceled. It's happening because tea is finding the symlink in the cwd and running that rather than the real version of gum. I'm assuming this is happening because the cwd is listed earlier in the PATH than gum's location.

When working with the shell, I've never had the cwd listed in the path. Some programming enviroments may do that, search the cwd for includes and such. But the sh cli doesn't. You always have to add "./" to get the shell to look for binaries in the cwd. So I propose that the cwd be removed from PATH (assuming it's included).

magnusviri avatar Nov 24 '22 15:11 magnusviri

We don’t add . to the PATH. However we do add ~/.tea/tea.xyz/v\*/bin to the PATH in some situations to ensure tea can be found by sub processes and that is where you made the tea_gum symlink.

Where is gum?

Either way, this may be fixed with the latest release since I added a check that we don’t execute foo if foo is a symlink to tea when executing in tea -X foo mode.

mxcl avatar Nov 26 '22 14:11 mxcl

It's fixed.

magnusviri avatar Nov 27 '22 21:11 magnusviri