Open jbrains opened 5 years ago
I changed my local etc/config
to set sdkman_auto_answer
to ${sdkman_auto_answer:-false}
instead of just false
, but I can't find the place to contribute this back. i planned to add a comment to the configuration file template to suggest using ${configuration_variable:-fallback_value}
, if they want that flexibility.
@jbrains I'm back from my break and finally getting around to these issues, apologies for taking so long to reply!
I just tried your example above (without making any changes to the .sdkman/etc/config file and it works fine for me as I would have expected. I can feed in the env vars per command and see them taking effect. I added a debug statement and see the following on the CLI:
$ sdkman_auto_answer=true sdk install maven 3.6.0
Auto Answer: true
...
$ echo $sdkman_auto_answer
false
$ sdk install maven 3.6.0
Auto Answer: false
...
This in turn makes me think that you might have your shell configured as a login shell. I've seen problems like this cropping up many times in the past, and this is usually the cause. Using a login shell prevents the state of the shell being updated, instead stubbornly holding on to the state that it was initialised in when the current session (usually the X or Gui session) was opened.
Would you be able to check if you are in fact running a login shell? If so, could you confirm that changing it to an interactive shell fixes this? If this doesn't fix it, let's try diagnosing what the problem seems to be on your machine.
@marc0der Thank you for the extra information. I can tell you that I am definitely running byobu
as a login shell, because rvm
suggested that I do this. I have since moved away from rvm
, replacing it with rbenv
, which should obviate the need for running byobu
as a login shell.
If my shell configuration makes sdkman
behave the way you expect, then perhaps we ought to document this particular behavior, especially since I'm probably not the only person in the world who tried to use sdkman
and rvm
and doesn't know enough about login/interactive shell to diagnose what looks like unexpected behavior. It might help, for example, to add a comment with a link to this issue to some wiki page entry to help the next person who bumps into this problem.
@marc0der I don't see the behavior you expect, so let me check what I've done:
In .sdkman/etc/config
, I have the following:
sdkman_auto_answer=false
sdkman_auto_selfupdate=false
sdkman_insecure_ssl=false
sdkman_curl_connect_timeout=7
sdkman_curl_max_time=10
sdkman_beta_channel=false
sdkman_debug_mode=false
sdkman_colour_enable=true
In ~/.sdkman/src/sdkman-install.sh
, I've added an echo inside function __sdk_install
:
if [[ ${VERSION_VALID} == 'valid' ]]; then
__sdkman_determine_current_version "$candidate"
__sdkman_install_candidate_version "$candidate" "$VERSION" || return 1
echo "Auto answer: $sdkman_auto_answer"
if [[ "$sdkman_auto_answer" != 'true' && "$auto_answer_upgrade" != 'true' && -n "$CURRENT" ]]; then
__sdkman_echo_confirm "Do you want ${candidate} ${VERSION} to be set as default? (Y/n): "
read USE
fi
if [[ -z "$USE" || "$USE" == "y" || "$USE" == "Y" ]]; then
echo ""
__sdkman_echo_green "Setting ${candidate} ${VERSION} as default."
__sdkman_link_candidate_version "$candidate" "$VERSION"
__sdkman_add_to_path "$candidate"
fi
return 0
To be a little extra sure, I restarted the terminal. I'm using the built-in terminal for Pop!_OS (Ubuntu) in place of byobu
. I have verified that "run as login shell" is not checked.
➜ ~ set -o | grep interactive
interactive on
interactivecomments on
➜ ~ set -o | grep login
login off
When I run this command, I see "false" instead of "true".
➜ ~ sdk uninstall maven 3.5.2 && sdkman_auto_answer=true sdk install maven 3.5.2
Unselecting maven 3.5.2...
Uninstalling maven 3.5.2...
Found a previously downloaded maven 3.5.2 archive. Not downloading it again...
Installing: maven 3.5.2
Done installing!
Auto answer: false
Setting maven 3.5.2 as default.
What silly thing might I be doing incorrectly?
We require a conversation to take place in the appropriate Gitter Room before raising a new Github Issue. Please note that issues will be closed immediately if prior discussion did not take place. We need to do this to help manage the quality and validity of Issues raised on this project.
Please tick one:
Please explain the Issue / Feature Request here: I would like to be able to override a configuration setting (like
sdkman_auto_answer
) for a single command without needing to change a file. For example, I would like to be able to do this:and then even if
sdkman_auto_answer
isfalse
inetc/config
, thensdkman_auto_answer
will betrue
when the command is executed. This way, the environment variable set for this one command would override the value set in the configuration file.