Subject:

zsh and the search for .circleci


Date: Message-Id: https://www.5snb.club/posts/2023/zsh-and-the-search-for-circleci/

I was using my shell one day, and hit tab on a . and ended up with

jess@neon ~
# .circleci
----------Completing external command----------
.circleci    .emscripten  .github
----------Completing builtin command----------
.

what the fuck? why do i have .circleci as a command?

Well, okay. Can we see where the file is?

jess@neon ~
# which .circleci   
.circleci not found

Guess not.

A quick find | grep \.circleci shows that .circleci files exist on my drive. They seem to be fairly common, and generally show up in project directories. But that’s nothing to be concerned about.

And there’s one instance of .emscripten, in my home directory. It’s what looks to be a python script to configure emscripten. But that wouldn’t cause it to show up, since it’s not in my $PATH.

The hash builtin command exists, which can tell us exactly where things are coming from.

jess@neon ~
# hash | grep -E "(circleci|github|\.emscripten)"
.circleci=/usr/lib/emscripten/.circleci
.emscripten=/usr/lib/emscripten/.emscripten
.github=/usr/lib/emscripten/.github

Huh. Why’s that in my $PATH?

jess@neon ~
# echo "$PATH" | tr ":" "\n" | grep "/usr/lib/emscripten"
/usr/lib/emscripten

Looks like the whole /usr/lib/emscripten is in my $PATH, which would lead to every file inside it being “executable” by typing it in. zsh doesn’t seem to filter out non-executable files from the auto completion.

Sure enough, if I try and execute AUTHORS, which exists in that directory…

jess@neon ~
# AUTHORS
zsh: permission denied: AUTHORS

Now to find out what is adding that to my $PATH. It’s not coming from /etc/profile or my .zshrc, I know that much.

jess@neon ~
# cat /etc/profile | grep em

jess@neon ~[1]
#  

But looking at /etc/profile, it’s mainly just code to source things from the actual profile, in /etc/profile.d. This way multiple packages can ask for things to be put in it.

Well, let’s check out there.

jess@neon ~
# cd /etc/profile.d 
binaryen.sh    gawk.sh  locale.sh           perlbin.sh
emscripten.sh  gpm.sh   mozilla-common.csh  vte.csh
freetype2.sh   jre.csh  mozilla-common.sh   vte.sh
gawk.csh       jre.sh   perlbin.csh         

Ah. well. What’s in emscripten.sh?

jess@neon /etc/profile.d
# cat emscripten.sh
#!/bin/sh
export PATH=$PATH:/usr/lib/emscripten

Well. We found it.

How did I go about fixing it?

jess@neon ~
# pacman -Rs emscripten      
[sudo] password for jess: 
checking dependencies...

Packages (3) acorn-1:7.4.0-1  binaryen-1:96-1  emscripten-2.0.0-1

Total Removed Size:  464.32 MiB

:: Do you want to remove these packages? [Y/n] y
:: Processing package changes...
(1/3) removing emscripten           [######################] 100%
(2/3) removing binaryen             [######################] 100%
(3/3) removing acorn                [######################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...

I didn’t really need emscripten to be installed, and that was a good prompt to just remove it.

Alternative solutions would be to actually file a bug report asking a more selective directory to be put into the $PATH, or to remove the directory from your $PATH and make a new directory containing symlinks to just the executables, and add that to your $PATH.