I am Java developer trying to set up my local CI server using Linux Mint. One of the crucial tools I would like to use is SDKMAN - the tool that allowes easy installation and management of different versions of libraries/languages (eg. Java/Scala/Maven).
Until now I was always installing it as a simple user on my local machine and it was working like a charm. The problem is that on the machine that I am configuring a couple of others users should be present (eg. specific ones for Jenkins/Docker/etc).
In order for these users to use SDKMAN too I've followed the guide presented here - and it almost worked. Installation was performed as ROOT. In order to make sure that the users have access to this folder I've run:
sudo chmod -R a+w /usr/local/sdkman
Ok. Let's roll. I've logged as different user (Jenkins) and tried to install latest version of Scala. The installation went smoothly. However when I've relogged and logged as other user (Docker) I've tried to install Scala but with different version. And that caused a problem. The oputput is:
$ sdk install scala 2.12.7 Downloading: scala 2.12.7 In progress... Installing: scala 2.12.7 mv: cannot move '/usr/local/sdkman/tmp/out/scala-2.12.7' to '/usr/local/sdkman/candidates/scala/2.12.7': Permission denied Done installing! Do you want scala 2.12.7 to be set as default? (Y/n): n
It seems that the folder /usr/local/sdkman/candidates/scala was created by user Jenkins and set the permissions/ownership to following.
drwxrwxr-x 3 jenkins jenkins 4096 May 9 12:06 scala
And therefore user Docker cannot add/modify anything in it! So the whole concept of using SDKMAN is not applicable here! I can install languages/libraries but it seems that users cannot install different versions of them as it seems that they do not have access rights to do so.
My question is - how to handle the permissions here in order to get the result I am expecting (every user can install whatever they want). I've tried creating separate group for SDKMAN users and changing recursively group ownership for base folder to 'sdk' but when new candidates are created the owner/group is the same and equals the username performing the operation.
Temporary fix is to proceed with group solution, installing all necessary versions of tools/languages and after that performing:
sudo chgrp -R sdk /usr/local/sdkman
On the folder. However maybe there is some more robust solution for it?