If you are a software engineer who works for a bank and if you are allowed to use Mac machines e.g. a Macbook you most likely do not have admin access. As a software engineer, for you to be productive, it is important for you to be able to freely install and experiment with all the software development tools out there. Now the question is, as a software engineer, how do you do your best work when you have to work with a Macbook without admin access? Add to it, you cannot even install Homebrew on your Mac. This post aims to be a guide on how to install software on your Mac without Homebrew & admin access or Homebrew by adding path variables to your terminal profile.

Background

In the last 15 years of my career, not once had I worked in a bank, hence I had no idea of just how restricted the development environment is. My most recent job is to build software at a bank and as I entered the highly regulated banking industry, I realised something. Banks are generally Windows shops. My god! everyone here uses Windows, the engineers I work with, love GUI based applications. If they were to try and find something in a large codebase, they would use a GUI based search tool, as opposed to grep. This was a surprise for me, seriously, in the last 13 years of my 15 years career in software engineering, I have worked with Unix based systems for development. Either a Mac or Ubuntu. Hence, coming to work for a bank was a huge shift for me in many ways. As of the last few months, they introduced MacBooks for engineers in the bank and I was one of the first people to be given the opportunity (or I was just a guinea pig) to get the Macbook. OMG, I was just so so happy, in my first year at the bank I used a Windows machine but it was good to be have the command line again. You can argue there’s Git bash but not the same. Now obviously, since I am working in a highly regulated industry where security is the biggest concern, I had no admin access on the machine hence I could not install what I wanted. I do not think it is very hard but it does require some familiarity in working with the command line.

NOTE: Using HomeBrew was not an option. I could not install HomeBrew and install software through it.

Perquisites

Before getting into how to do so, there are a few things you must be familiar with, such as

Command line familiarity

Having a bit of familiarity with the terminal or the command line would help. If you have worked with Git Bash on your Microsoft Windows PC, that is considered command line familiarity.

Knowing your bash shell

This is something that may not be immediately obvious but it is important to know what type of shell you are on. You can do so by,

 echo $0

If it comes up as zsh that means the the shell used by your Mac when you start your terminal is a z-shell. If it comes as bash, that means, it uses a bash shell.

NOTE: This tutorial assumes you are working with a z-shell.

How to unzip archives and copy directories (optional)

This step is entirely optional as it can be very easily achieved using GUI, but this tutorial will show how to achieve the steps mentioned using command line. It will talk about how to unzip directories using tar and how to copy directories using cp.

Install software on Mac without homebrew

There are two types of applications that you may want to install,

From source

This is more common when you are working with open-source tools. This involves downloading a tarball or an archive from a website and installing it to the /usr/local directory. This would not be possible when you do not have admin access. Hence, in this case what you need to do is download the archive i.e. a tarball extract it to a directory you can access and add it to your path such that you can access the executables in the bin directory. Continue reading this post and you will come across a section on how to install MongoDB on your Mac.

From Apple Disk Image (.dmg)

Software in a folder with a bin directory or you download an Apple disk image (.dmg) file with an executable that you copy to your Applications folder.

How to install MongoDB without admin access

This follows a similar approach to what I mentioned in my previous post on how to setup Java 18 without admin access. Please read that if you need to know more about how to install Java.

How to setup Java 18 on your mac – My Day To-Do (mydaytodo.com)

Download MongDB archive

Download MongoDB community edition from here. The latest version at the time of writing this document was 6.0.0.

Unzip to preferred location

Copy the archive to a directory of your choice and then unzip it. For example, if the downloaded file is in your Downloads directory, it would be in /Users/<your-username>/Downloads/mongodb-macos-x86_64-6.0.0.tar. Create a directory called Software in your in your home directory and copy the tarball there. Once copied, unzip the tar ball

mkdir software && cd software
cp ~/Downloads/mongodb-macos-x86_64-6.0.0.tar ~/software
tar xvzf mongodb-macos-x86_64-6.0.0.tar

The above should unzip a directory called mongodb-macos-x86_64-6.0.0 which should have a bin directory with MongoDB executables like install_compass, mongod and mongos.

Add source location to path and export

For this step, check what shell is opened by default on your Mac. As discussed before, launch your terminal and run

echo $0
typing cd ~ will take your to your home directory (tilde key is a shortcut for accessing your home directory)

It will either be -zsh or bash. In case of zsh, create a file in your home directory, called .zshrc or in case of bash, create a file .bashrc. Vim is a command line text editor for unix based systems where by default, a file is opened in read-only mode. You can press i on the keyboard to get into editing mode and save it by pressing esc and typing :wq to close it.

vim ~/.zshrc
export MONGO_HOME=/Users<your-username>/software/mongodb-macos-x86_64-6.0.0
export PATH=$MONGO_HOME/bin
  • We start by opening the zshrc file
  • press i on your keyboard to be in editing mode
  • export MONGO_HOME
  • Add it to PATH
  • press esc key on keyboard and type :wq to save the file

Start MongoDB from the terminal

You may need to specify a few extra parameters for a location where mongo will save the database as well as a file to write logs

mkdir ~/software/mongodb-macos-x86_64-6.0.0/db
mkdir ~/software/mongodb-macos-x86_64-6.0.0/logs
touch ~/software/mongodb-macos-x86_64-6.0.0/logs/mongod.log
mongo --dbpath ~/software/mongodb-macos-x86_64-6.0.0/db --logpath ~/software/mongodb-macos-x86_64-6.0.0/logs/mongod.log

Shortcut to start Mongo?

You saw the command to start MongoDB from the terminal earlier. It seems a bit long does it now? You are probably thinking, there has to be a way for this to be easier and for you to not remember the dbpath and log path every time. Fortunately, yes there is a way you can do that, using this Unix feature called an alias. You can read up this Wikipedia definition of an alias. It is the ability to assign a string to replace another string. So instead of trying to remember the exact locations of your MongoDB db and logs, you can just run the type the string you specified as an alias. An alias to start MongoDB would be like

vim ~/.zshrc
alias startmongo='mongo --dbpath ~/software/mongodb-macos-x86_64-6.0.0/db --logpath ~/software/mongodb-macos-x86_64-6.0.0/logs/mongod.log'
:wq
  • Open your z-shell profile file with vim ~/.zshrc
  • Press i on your keyboard and go to the bottom of the file
  • Enter alias startmongo=’….’ startmongo can be any string you want it to be. If you want it to be nosqlstart, then type alias nosqlstart=’….’
  • Press Esc on your keybaord
  • Followed by :wq and hit enter

And that is all, you can download and install MongoDB without admin access.

How to install software from Apple Disk Image

You know what an Apple Disk Image is, it’s those installable files that you download online with a .dmg extension. When you download something and double click to install it, it will do so to the default Applications directory. Now, when you do not have admin access on the Mac, you do not have permissions to install this in the main applications folder. However, you can do so for the Applications folder for your user. All you need to do is launch finder and press cmd + shift + h which will open the finder with folders you have access to. To install any software .dmg file launch it by double clicking it on it and then simply copy it to your applications folder and the you will have successfully installed it.

Conclusion

Please be aware that this post is by someone who’s been using command line tools for more than 10 years. Hence, from the perspective of the writer, it may seem that it is quite easy to install all this. However if you cannot do all this on the first try, then please do not be too hard on yourself. It is perfectly ok to struggle with this, if you have used GUI based tools your career.

This post shows there is a way to do things even when you find yourself in a restricted environment. “There is always a way…”

Get updates?

If you find any of my posts useful and want to support me, you can buy me a coffee 🙂

https://www.buymeacoffee.com/bhumansoni

Alternatively you can have a read of one of my other posts on how to install software using command line

How to setup Java 18 on your mac – My Day To-Do (mydaytodo.com)

While you are here, maybe try one of my apps for the iPhone.

https://mydaytodo.com/apps/

Categories: Command line

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock