omf-sdk icon indicating copy to clipboard operation
omf-sdk copied to clipboard

Can't find installed candidates in fish

Open gabrielfeo opened this issue 4 years ago • 7 comments

I have no idea if this could be related to omf-sdk, but I'm at a loss here. I can find candidates in zsh, but in fish sdkman is unaware of them. Same user.

The shell with syntax highlighting is fish:

Screen Shot 2021-02-04 at 16 52 52 Screen Shot 2021-02-04 at 16 57 18 Screen Shot 2021-02-04 at 16 54 32

I can't link candidates in fish either. It says "Invalid path" even though it's not malformed and sdk in zsh accepted it:

Screen Shot 2021-02-04 at 17 03 33

gabrielfeo avatar Feb 04 '21 19:02 gabrielfeo

TL; DR: SDKMAN_DIR must be defined in bash. This is what my sdk.fish does now:

bash -c "SDKMAN_DIR=$sdkman_prefix && source $sdkman_prefix/bin/sdkman-init.sh && sdk $argv"
Screen Shot 2021-02-04 at 20 42 36 Screen Shot 2021-02-04 at 20 57 41

@deather, would you be open to a PR with this change?

This comment gave me the clue. Since the bash omf-sdk starts (sdk.fish) is not a login shell, it doesn't run any of the profile scripts which would set SDKMAN_DIR. It doesn't have any of the variables I set in fish either.

I don't really understand why sdkman behaves like this if SDKMAN_DIR isn't set though, since what I have set is actually the default location, or why this solved the "Invalid path" problem.

gabrielfeo avatar Feb 05 '21 00:02 gabrielfeo

Hi @gabrielfeo,

Thanks to take the time to post the bug. Normally that is the init.fish which set the SDKMAN_DIR automatically. The only thing that I see why this variable is not set, it is due to fenv is missing.

  • Can you check first if fenv is installed with this command type fenv or checking if the folder .local/share/omf/pkg/ exists ?
  • Can you post the result of env | grep SDK in fish and bash -c "env" | grep SDK ?

We don't use the bash as login shell (-l option if I understood). I want to understand where is the problem before create the PR.

deather avatar Feb 05 '21 09:02 deather

Thank you for your help. SDKMAN_DIR is indeed defined:

Screen Shot 2021-02-05 at 19 21 53 Screen Shot 2021-02-05 at 19 37 13 Screen Shot 2021-02-05 at 19 37 26

I have a lot to learn about shells. I'd appreciate it if you could confirm if I got this right.

  1. SDKMAN_DIR will get passed down to bash because you export it
  2. fenv makes sure when sdkman changes JAVA_HOME from within bash, the change gets passed up to fish

Back to the problem, I now have no clue as to why re-defining the variable solves the issue:

Screen Shot 2021-02-05 at 19 35 56

gabrielfeo avatar Feb 05 '21 22:02 gabrielfeo

Your understanding is good about fenv, and export. If you read man set you will find more information about the option. The trick you purposed is to define SDKMAN_DIR for one session of bash.

The only thing we don't check is the .bash_profile and the .bashrc. Wen you use bash it loads automatically some files like these two.

  • Can you try bash --norc --noprofile -c "source $sdkman_prefix/bin/sdkman-init.sh && sdk l java | grep '>>>'" ?
  • Can you paste the content of the .bashrc file ?

deather avatar Feb 06 '21 05:02 deather

Here are the outputs of those commands. I don't have a .bashrc. I do have a .bash_profile, but it's probably irrelevant because it's not run in a non-login shell, according to this doc.

Screen Shot 2021-02-08 at 17 43 28

I just setup fish, omf and omf-sdk on another Mac to test this, and I had no issues. It's probably something local, maybe due to my home directory on this machine being in a non-standard location.

gabrielfeo avatar Feb 08 '21 20:02 gabrielfeo

When you said your home directory is not standard, you have redefined it with these kind of command https://stackoverflow.com/a/26427748/1595433 ? or you just change the $HOME variable ?

Can you give me the output of bash -c "echo $HOME", bash -c "echo ~" and bash -c "ls -la ~ | grep .sdkman" ?

deather avatar Feb 15 '21 17:02 deather

I moved my home directory using macOS's System Preferences:

Screen Shot 2021-02-15 at 20 26 40 Screen Shot 2021-02-15 at 20 25 08

gabrielfeo avatar Feb 15 '21 23:02 gabrielfeo