Multiuser setup with linuxbrew (Docker)

I’m trying to have a Docker image packaged with linuxbrew.
The setup is to create a user “sf” with sudo privileges and then install linuxbrew via the regular command. Nothing fancy.

Afterwards, the intention is to pull this image, run it, create another user “ci” with sudo privileges, which should have access to run “brew install” and similar. In the setup of user “ci”, I currently install linuxbrew (again), because I cannot be sure if linuxbrew is already installed and working properly. Reinstalling homebrew/linuxbrew on a working machine is more or less equivalent to “brew update” afaik.

But running the linuxbrew install script via user “ci” fails because it does not have permissions to /home/linuxbrew.

I have tried creating a “brew” group and assign both users “sf” and “ci” to it, and also
“sudo chgrp -R brew /home/linuxbrew”, but the install script fails anyway “Permission denied” when tar is executed https://github.com/Linuxbrew/install/blob/master/install-ruby#L24-L25

Any pointers?

EDIT: actually the error messages say smth else than “Permission denied”

698tar: portable-ruby/2.3.7/bin/irb: Cannot open: File exists
699tar: portable-ruby/2.3.7/bin/erb: Cannot open: File exists
700tar: portable-ruby/2.3.7/bin/gem: Cannot open: File exists
701tar: portable-ruby/2.3.7/bin/rdoc: Cannot open: File exists
702tar: portable-ruby/2.3.7/bin/ruby: Cannot open: File exists
703tar: portable-ruby/2.3.7/bin/ri: Cannot open: File exists
704tar: portable-ruby/2.3.7/bin: Cannot utime: Operation not permitted
705tar: portable-ruby/2.3.7/bin: Cannot change mode to rwxr-xr-x: Operation not permitted

Why not just use the homebrew/linuxbrew docker containers?

Use the Homebrew/brew Docker image, and run as the user root.

the “linuxbrew/docker” containers do not solve the situation. I need to run with a specific user, not root.

forget about Docker for a second. I’m trying to understand if/how linuxbrew is supposed to work in a multi-user setup. if it’s not, I guess the solution is to change the ownership of /home/linuxbrew to the specific user

thanks!

In principle it should be possible to run Homebrew in a multi-user situation. In practice, it’s not supported, and my experience has been that it does not work. I think it could with some patches to the Homebrew source code. In the mean time, I’d suggest using sudo to ensure that Homebrew is always run as the linuxbrew user. The homebrew/brew Docker image comes with a linuxbrew user created for this purpose.