Search code examples
linuxdockerubuntu

Why is binary installed as tracked alias


I install pex file like this when building the container:

RUN curl -fL https://github.com/pex-tool/pex/releases/download/v2.13.0/pex -o /usr/local/bin/pex
RUN chmod +x /usr/local/bin/pex

When I run it and check the type, it gives me "tracked alias". The pip from the same directory shows differently:

$ type pip
pip is /usr/local/bin/pip
$ type pex
pex is a tracked alias for /usr/local/bin/pex

But looks the same with ls -la /usr/local/bin:

-rwxr-xr-x 1 root root 4190750 Jul 30 15:00 pex
-rwxr-xr-x 1 root root     226 Jul 23 07:24 pip

What does it mean?


Solution

  • The difference you are seeing between tracked alias for pex and the regular executable file for pip is because of the particular way the shell tracks these commands. Tracked aliases speed up execution by eliminating the need for the shell to search the PATH variable for a pull path name, you can read more about this here.

    In other words the Output below indicates that the pip is recognized as a standard executable file located at bin.

    $ type pip
    pip is /usr/local/bin/pip
    

    The Output regarding pex however indicates that pex is recognized as a tracked alias. The first time you ran pex your shell remembered that pex was located in bin and hashed that command to be able to reach it faster.

    $ type pex
    pex is a tracked alias for /usr/local/bin/pex
    

    The reason for both of them not being aliases or regular executables is probably due to their usage history. Pip is a more regular command known by most linux-related shell environments whilst pex is probably much less common and newly installed why it gets recognized as a tracked alias.