3

I have installed SDKMAN! as root on my server and want all my users (developers) to have access to it.

For that I did:

export SDKMAN_DIR="/usr/local/sdkman" && curl -s "https://get.sdkman.io" | bash
source "/usr/local/sdkman/bin/sdkman-init.sh"

Then for a user, I added these lines at the end of .profile and .bashrc:

#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/usr/local/sdkman"
[[ -s "/usr/local/sdkman/bin/sdkman-init.sh" ]] && source "/usr/local/sdkman/bin/sdkman-init.sh"

From that user (non root), the sdk command works, but when I try to install Java, I get a lot of errors for folders and files permissions, that's OK because most of those where created by root, not by my current user.

Then I try:

sudo sdk install java 9.0.4-open

And got:

sudo: sdk: command not found

Not sure what I'm doing wrong, maybe I need to install SDKMAN! for each user on my server, which would be a pain.

Any suggestions?

Pablo Pazos
  • 3,080
  • 29
  • 42
  • 1
    Run `type sdk` and it will probably say that it's a shell function. – Roman Aug 17 '19 at 00:53
  • `sudo su -` and then `source /usr/local/sdkman/bin/sdkman-init.sh` - you could also add the `.profile` entry for `root` (and then just `sudo su -`) - before running `sdk`. – Elliott Frisch Aug 17 '19 at 00:55
  • @ElliottFrisch should that be done every time a normal user wants to run sdk? Or is that permanent? – Pablo Pazos Aug 18 '19 at 14:49
  • @ElliottFrisch followed those steps, is the same as executing SDKMAN as root, and Java is installed only for root, the idea is that is available for all users. – Pablo Pazos Aug 26 '19 at 21:15
  • That isn't how sdkman works. If you haven't created the users yet, you could copy the setup to [`/etc/skel`](http://www.linfo.org/etc_skel.html). – Elliott Frisch Aug 26 '19 at 21:35
  • @ElliottFrisch not sure what you mean with "that isn't how sdkman works", can you expand? I can interpret your answer as "there is no way to make sdkman work for all users installing once and having one user installing something like Java and that be available for all users. But I guess that is the answer to this question. – Pablo Pazos Aug 27 '19 at 01:04
  • @PabloPazos Pretty much. One of the major advantages of sdkman is being able to dynamically select your version of the tool. `sdk ls java` and `sdk use java 8.0.212.hs-adpt` or `sdk use java 12.0.1.hs-adpt` (for example). Simply saying "install Java for all users" is the domain of the system level package manager. – Elliott Frisch Aug 27 '19 at 01:11
  • Fair enough. Yes I know the first part from using it for a while on my dev machine working with different Groovy/Grails projects and just for one user (me). The question was about the global availability of installed packages on a shared server. – Pablo Pazos Aug 27 '19 at 02:44

1 Answers1

1

It seems it is not possible to install SDKMAN! once as root and that be available for all users. I guess each user needs to install it and then each users needs to install it's own version of Java, which is a pain if I manage one server and need several users to have the same configuration.

Pablo Pazos
  • 3,080
  • 29
  • 42