Example1:
When I install a package using a package manager such as the JavaScript package manager npm
, the package immediately becomes available to run from any directory on any terminal:
$ npm install -g redis-cli
I don't even have to restart my laptop, this command is now available to me:
$ rdcli
Example 2:
As for another example, let's install a Python module using the Python package manager pip
:
$ pip install rq
Now this command is available anywhere without restarting the OS:
$ rq
In contrast:
In contrast, when I add a folder to my Environment Variables' path, I have to restart the system:
C:\Program Files\smartmontools\bin
Now after restarting or doing this trick, this command is available to me:
$ smartctl.exe
Can anyone explain what trick package managers do in the background?
Extra:
One thing I noticed is that when you install a package with a package manger and you haven't restarted the system yet, it's only available to terminals, like CMD, Powershell or MinTTY, other apps don't see it yet, for example if you run this command in a terminal:
winpty rdcli
You will get this error:
winpty: error: cannot start 'rdcli': Not found in PATH
But after you restart the system, the command will work.