Sdkman-cli: GVM doesn't work with Fish shell

Created on 29 Sep 2014  ·  29Comments  ·  Source: sdkman/sdkman-cli

The previous work-around for using GVM with the Fish shell was to add all the 'current' links to the PATH. This appears to be broken with newer versions of GVM. The 'current' link is only set to the default version of the given tool and doesn't get updated when 'use'-ing a different version.

Most helpful comment

I wrote a script like this and saved as $HOME/.config/fish/conf.d/sdkman.fish. Seems it works. And it does not depend on bass:

#!/usr/bin/fish

# sdk command
function sdk
        bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk $argv"
end

# add paths
for ITEM in $HOME/.sdkman/candidates/* ;
        set -gx PATH $PATH $ITEM/current/bin
end

All 29 comments

Unfortunately we do not support fish shell. Only bash and zsh are supported (as well as power shell through posh GVM).

The real solution would be to write a client for fish shell that utilises the GVM API.

Not cool guys, totally not cool. I've been using GVM alongside fish shell for about 1 year and today my setup was broken after update from GVM to sdkman.

As before, we do not officially support fish shell. If you want to get involved to make it compatible, feel free to fork and contribute to this free service that we are providing to you.

+1

Thanks but this is not working solution.

Simple workaround, add to ~/.config/fish/config.fish:

# sdkman
set PATH $PATH (find ~/.sdkman/candidates/*/current/bin -maxdepth 0)

Completion script from your blog is working after removing first invalid method named: __fish_gvm_no_command.

Sorry, fixed the post.

Thx, works like a charm :+1:

You should support fish-shell, I don't think that should be a difficult task and fish-shell is much better than the old fashioned bash shell. Also thanks for this great work, sticking with bash for now.

We still have no major plans to support fish shell as it still has a pretty
small user base. You could always try ZSH of course ;-P

On Tue, 19 Apr 2016 at 16:01 Giancarlo Chiappe [email protected]
wrote:

You should support fish-shell, I don't think that should be a difficult
task and fish-shell is much better than the old fashioned bash shell. Also
thanks for this great work, sticking with bash for now.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
https://github.com/sdkman/sdkman-cli/issues/294#issuecomment-211966527

So, this is all about popularity :) I dont get why happy fish user could try ZSH? Could you explain?

Probably because making sdkman compatible with a new shell (with
corresponding automated tests) is a lot of work and effort. Remember that
this project is free and worked on in our own spare time.

If the fish shell community wants to be supported, we would gladly
accommodate them and we welcome good quality PRs to our project.
On Tue, 19 Apr 2016 at 20:25, Mariusz Smykuła [email protected]
wrote:

So, this is all about popularity :) I dont get why happy fish user could
try ZSH? Could you explain?


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
https://github.com/sdkman/sdkman-cli/issues/294#issuecomment-212077909

Closing this issue as sadly no PRs were received.

i know is a closed post, but just FYI, you can add fish shell support easily with this snippet of code

function sdk
     bass source ~/.sdkman/bin/sdkman-init.sh --no-use ';' sdk $argv
end

has a dependency on the bass library : https://github.com/edc/bass

example :

fish -home-marc_007

Please take look at blog entry describing sdkman along with fish shell ;) http://tedwise.com/2016/02/26/using-sdkman-with-the-fish-shell (praises for Ted Wise).

@Markcial this doesn't work for me.

 ❯ sdk list
$  is not a valid variable in fish.
- (line 33): printf "                                                         $ sdk install activator";printf '
                                                                               ^
from sourcing file -
        called on line 14 of file ~/.config/fish/functions/bass.fish

in function “bass”
        called on line 2 of file ~/.config/fish/functions/sdk.fish
        with parameter list “source /home/amos/.sdkman/bin/sdkman-init.sh --no-use ; sdk list”

in function “sdk”
        called on standard input
        with parameter list “list”

source: Error while reading file “-”

 ❯              

@amosbird Fixed on edc/bass, can you try upgrading your edc/bass with fisher up edc/bass please?

@Markcial Thanks. It works now.

I wrote a script like this and saved as $HOME/.config/fish/conf.d/sdkman.fish. Seems it works. And it does not depend on bass:

#!/usr/bin/fish

# sdk command
function sdk
        bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk $argv"
end

# add paths
for ITEM in $HOME/.sdkman/candidates/* ;
        set -gx PATH $PATH $ITEM/current/bin
end

@ctwise I'm getting lots of errors:

~> sdk list
mktemp: too few X's in template ‘env’
mktemp: too few X's in template ‘env’
bash: -c: line 0: syntax error near unexpected token `newline'
bash: -c: line 0: `source ~/.sdkman/bin/sdkman-init.sh && sdk list && printenv > '
~/.config/fish/functions/sdk.fish (line 12): Invalid redirection target: $path_env
          echo "$elem" >> $path_env
                       ^
in function “sdk”
    called on standard input
    with parameter list “list”

It seems the interface of mktemp has changed:

TEMPLATE must contain at least 3 consecutive 'X's in last component.

So, simple fix:

set after_env (mktemp -t env.XXX)
set path_env (mktemp -t env.XXX)

Thanks a lot, huge help!

I wonder how much work it would be to make this into a PR. Sdkman's installer could detect if .config/fish exists and then write those scripts of yours in the correct places?

@ctwise The list of commands apparently need an update, too: outdated doesn't exist anymore. (I didn't check everything).

Maybe, at this point, it'd be good to have a Github project for your scripts (and deploy them via fisher or similar), then we could collaborate to keep it up to date more easily. Are you up for setting that up?

@marc0der The fish script @ctwise posted on his blog still has it (but otherwise works fine). Sorry for hijacking your bugtracker for communicating with him about something you have no intentions to support; will endeavour to move the discussion elsewhere.

No probs, feel free to keep discussing it here. I just didn't understand the context so my bad...

@reitzig Please use @yookoala solution, works like a charm, and it is very simple.

@mariuszs I can see how @yookoala's snippet makes sdk and installed binaries available (and more simply so than the other alternatives); it doesn't provide auto-completion, though (which is the bigger part of @ctwise's post).

I set up a repo: reitzig/sdkman-for-fish. There is some work to do on the completions; pull requests appreciated.

@ctwise and @yookoala, I hope you are fine with the MIT license and credits; if not, please let me know.

_Update:_ Completion is now up to date and improved (doesn't complete arbitrarily many parameters, which sdk doesn't support). Also fixed bugs with the sdk function itself (subshells would get duplicate PATH entries; sdk use didn't work). Install with fisher install reitzig/sdkman-for-fish.

_Update 2:_ To all who google here, I can only recommend to install "my" version. What was posted above was simply broken; for instance, sdk use and sdk offline just wouldn't work. Check out the growing issue list in case of doubt -- this has turned out to be a larger bite than what I thought I signed up for!

@marc0der At this point, would it be conceivable to have the SDKMAN! installer detect the presence of fish, and either install support there (potentially destructive, so meh) or give the user a hint how they can get it?

I'm open to either approach. We seem to have a lot of fish shell users now so why not give them first class support?

The installer script can be found here:
https://github.com/sdkman/sdkman-hooks/blob/master/app/views/install.scala.txt

I posted a draft: https://github.com/sdkman/sdkman-hooks/pull/9

It would be great if one of the other fish users could chime in. As the author of the (not yet fully matured and battle-tested) integration I feel slightly awkward pushing this.

Was this page helpful?
0 / 5 - 0 ratings