In this article, we’ll learn how to install a package on Linux Netlify Agent Without Sudo Privileges and without the use of a package manager.
Netlify provides serverless backend for web applications and static websites. It is very convenient to host static websites when you do not need any special installations on top of it.
However, if you want to use any third-party package on Netlify container which Netlify doesn’t have already, it becomes a problem as with Netlify containers you do not get sudo privileges.
We can solve this issue if we utilize our Linux skills. We never really try to understand how a package manager works and how it actually does the installation for us. The solution lies in that process only.
Follow these steps to install a package on Linux Netlify Agent without sudo privileges:
- Get the binary of the package you want to install.
- Set its path to user’s
if [ "$NETLIFY" = "true" ]; then wget https://git.savannah.gnu.org/cgit/parallel.git/plain/src/parallel chmod 755 parallel cp parallel sem mkdir ~/bin mv parallel sem ~/bin/ source ~/.profile fi
First, we are checking whether our build is running on Netlify or not because you might be using multiple platforms for the deployment and will probably a package manager installing GNU Parallel there. Hence, this check is required only on Netlify:
if [ "$NETLIFY" = "true" ];
$NETLIFY is an environment variable, boolean, which returns
true if the build is running on NETLIFY, and
false if it is not. If you are using some other platform, you can find the similar variable for that as well and use it.
Next, we are downloading the GNU Parallel binary using
Then, we are making the binary executable and putting it inside user’s local bin and re-applying the
chmod 755 parallel cp parallel sem mkdir ~/bin mv parallel sem ~/bin/ source ~/.profile
I hope this tutorial helped you install a package on Linux Netlify Agent without sudo privileges. This is a pretty clean solution when you don’t have sudo privileges in Netlify Agent.
If you want to learn more such Linux tricks, check out our other blogs on Linux by clicking here!