reitzig / sdkman-for-fish

Adds support for SDKMAN! to fish
MIT License
280 stars 13 forks source link

Enabling offline mode has no effect #17

Closed reitzig closed 5 years ago

reitzig commented 5 years ago

Expected

$ sdk offline enable
Offline mode enabled.
$ sdk install java 7.0.181-zulu
Stop! java 7.0.181-zulu is not available while offline.

Actual

Offline mode enabled.
$ sdk install java 7.0.181-zulu

Downloading: java 7.0.181-zulu
<snip>

Analysis

The problem is that sdk uses an environment variable ($SDKMAN_OFFLINE_MODE, to be precise) to signal offline mode across runs. This environment variable is not captured from the nested bash call to the fish session.

Plan

Capture all $SDKMAN_* variables, thereby fixing all unknown issues with similar cause. Use the same method as for capuring $PATH. Add tests.

reitzig commented 5 years ago

Initialization is similarly affected: conf.d/sdk.fish currently fills PATH correctly, but ignores any other effect sdkman_init.sh might have.

--> Call the bash initialization script during fish startup and capture its effects. We shouldn't even have to call it for every sdk call then!

reitzig commented 5 years ago

Ironically, offline mode is not affected by #19 -- because SDKMAN_OFFLINE_MODE is not an environment variable, which made the code more awkward.