Ubuntu. Share SDKMAN/Grails/Groovy between Linux users.
Hi there! I hope you’re doing well :) Let’s talk how to install SDKMAN on Linux system with several users.
Some time ago I faced the problem: I needed Grails to be shared between
different users on our server. Surprisingly I found that default
SDKMAN installation doesn’t allow it out of the
box. The problem is that everything is installed in home directory of current
user. For example, I install SDKMAN as root user on my server. SDK is installed
to /root/.sdkman/
. After installation is finished you will see the text like:
Please open a new terminal, or run the following in the existing one:
source "/root/.sdkman/bin/sdkman-init.sh"
in the end of ~/.bashrc
and ~/.profile
you will also see something like:
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/root/.sdkman"
[[ -s "/root/.sdkman/bin/sdkman-init.sh" ]] && source "/root/.sdkman/bin/sdkman-init.sh"
But how is it going to work for other users? Let’s say I have another_user
on the same server who is non-priviledged user. I want him to be able to use
Grails which was installed by SDKMAN. I tried source "/root/.sdkman/bin/sdkman-init.sh"
,
but got error:
-su: /root/.sdkman/bin/sdkman-init.sh: Permission denied
Frankly speaking, I was disappointed :)
After some time I found the solution which solved my problem:
-
Uninstall SDKMAN and all the shit that came with him.
-
Use shared folder which all the users can access for SDKMAN installation. In my case I installed to
/usr/local/sdkman
. That’s pretty easy:export SDKMAN_DIR="/usr/local/sdkman" && curl -s "https://get.sdkman.io" | bash
. Installation instruction also tells about this option in the very bottom of the instruction, although I think it must be the default behaviour of their installer. -
Open
~/.profile
asanother_user
(I think it must be something like/home/another_user/.profile
on your computer) and copy here the lines from/root/.bashrc
which come after#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
-
Login as
another_user
and try to entersdk help
in console. Now it should work. As well as all the Grails, Groovy, Gradle etc. which installed using this SDKMAN installation. For every user which you want to be able to use SDKMAN you have to add those lines to~/.profile
as described above.
I hope this article helped you to save a little bit of your time :) Maybe some of you know how to do it easier. Share your ideas about it in comments!
Have a nice time and happy coding everybody!