How to manage brew with a mutli user setup?

I have two user accounts on my machine. They can share the same tools and installations however I am unable to install things when switching between the accounts

First I get

$ brew install brotli

/usr/local/Homebrew/Library/Homebrew/utils/lock.sh: line 27: /usr/local/var/homebrew/locks/update: Permission denied
Traceback (most recent call last):
				2: from -e:1:in `<main>'
				1: from -e:1:in `new'
-e:1:in `initialize': Bad file descriptor (Errno::EBADF)
Error: Another active Homebrew update process is already in progress.
Please wait for it to finish or terminate it to continue.
Error: The following directories are not writable by your user:
/usr/local/share/man/man5
/usr/local/share/man/man7

You should change the ownership of these directories to your user.
	sudo chown -R $(whoami) /usr/local/share/man/man5 /usr/local/share/man/man7

And make sure that your user has write permission.
	chmod u+w /usr/local/share/man/man5 /usr/local/share/man/man7

Then I try setting permissions

$ sudo chown -R $(whoami) /usr/local/share/man/man5 /usr/local/share/man/man7
$ chmod u+w /usr/local/share/man/man5 /usr/local/share/man/man7
$ brew install brotli

/usr/local/Homebrew/Library/Homebrew/utils/lock.sh: line 27: /usr/local/var/homebrew/locks/update: Permission denied
Traceback (most recent call last):
				2: from -e:1:in `<main>'
				1: from -e:1:in `new'
-e:1:in `initialize': Bad file descriptor (Errno::EBADF)
Error: Another active Homebrew update process is already in progress.
Please wait for it to finish or terminate it to continue.
Error: Permission denied @ rb_sysopen - /usr/local/var/homebrew/locks/pkg-config.formula.lock

Multi user setups aren’t really supported by homebrew but there’s undoubtedly people who made it work on the internet and wrote about it.