Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ~/.config/sdkman/config to override ~/.sdkman/etc/config #1069

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

felipecrs
Copy link
Contributor

Because the current approach is very dotfiles unfriendly.

Fixes #941

@felipecrs
Copy link
Contributor Author

I may need to add tests and fix the CI. I would just like to receive a greenlight from the maintainers before I spend time on it.

Copy link
Member

@marc0der marc0der left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really prefer to keep the base SDKMAN directory free from configuration. That is explicitly what the etc directory is for. Also, you will see no other files, just directories, in the base dir.

However, I would consider an override if you wanted an .sdkmanrc file in your home directory. That makes more sense and is more in line with what you would expect on a Unix system.

Another thing also not considered is the sdk config command for editing the configuration. Which of these files should it be responsible for editing?

@felipecrs
Copy link
Contributor Author

However, I would consider an override if you wanted an .sdkmanrc file in your home directory. That makes more sense and is more in line with what you would expect on a Unix system.

That's what I'm proposing, ~/.sdkmanrc as an override option only. I have no intention to change anything in ~/.sdkman/etc/config or how it works.

Another thing also not considered is the sdk config command for editing the configuration. Which of these files should it be responsible for editing?

Actually, I considered and changed sdk config to edit ~/.sdkmanrc instead of ~/.sdkman/etc/config. But I'm okay to change it back to etc/config if you do not agree.

@felipecrs felipecrs changed the title Allow ~/.sdkmanrc to overwrite ~/.sdkman/etc/config Allow ~/.sdkmanrc to override ~/.sdkman/etc/config Mar 14, 2022
@helpermethod
Copy link
Member

In any case please don't name it .sdkmanrc 😂. We already use .sdkmanrc files for storing per-project candidate versions.

An .sdkmanrc file in the $HOME directory looks like a similar file but per-user.

A lot of popular tools use that convention, e.g. NPM and direnv

https://docs.npmjs.com/cli/v8/configuring-npm/npmrc
https://direnv.net/#how-it-works

@felipecrs
Copy link
Contributor Author

How about ~/.sdkmanconfig (like ~/.gitconfig)?

@felipecrs felipecrs changed the title Allow ~/.sdkmanrc to override ~/.sdkman/etc/config Allow ~/.sdkmanconfig to override ~/.sdkman/etc/config Mar 15, 2022
@felipecrs felipecrs mentioned this pull request Mar 19, 2022
7 tasks
@tripleo1
Copy link

tripleo1 commented Mar 20, 2022

I would prefer not to have another file in my home directory.

Use .config or something. (see #941)

Just my 2 cents.

@felipecrs
Copy link
Contributor Author

felipecrs commented Mar 20, 2022

Yeah, I also agree.

I would prefer not to have another file in my home directory.

PS: sdkman won't create this file automatically.

@felipecrs felipecrs changed the title Allow ~/.sdkmanconfig to override ~/.sdkman/etc/config Allow ~/.config/sdkman/config to override ~/.sdkman/etc/config Mar 20, 2022
@felipecrs
Copy link
Contributor Author

Changed.

@marc0der
Copy link
Member

marc0der commented Mar 20, 2022

I'll be very honest, but I'm leaning towards not having this capability at all. I honestly don't think that our users want this feature since it has never been asked for before.

Another point is that modern Linux systems do not store configuration directly in the home directory. Instead, the ~/.config directory is used to contain all config files. And again different rules apply on Mac.

Besides that, I think that this has many undesired side effects and consequences that simply haven't been thought through.

@felipecrs
Copy link
Contributor Author

@marc0der I changed already to ~/.config.

@felipecrs
Copy link
Contributor Author

I honestly don't think that our users want this feature since it has never been asked for before.

@marc0der it seems that I'm no longer alone: #1160

If you want, I can rebase this PR.

@untainsYD
Copy link

Are there any updates on this issue? It is quite annoying that sdk-cli pollutes my home directory instead of creating .sdkmanrc file in ~/.config/sdkman/...

@felipecrs
Copy link
Contributor Author

I will wait for maintainers to comment before I rebase this PR.

@@ -34,6 +34,11 @@ if [ -f "${SDKMAN_DIR}/etc/config" ]; then
source "${SDKMAN_DIR}/etc/config"
fi

# Load the sdkman user config if it exists.
if [ -f "${HOME}/.config/sdkman/config" ]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"${XDG_CONFIG_HOME}/sdkman/config"

if XDG_CONFIG_HOME is not set then "${HOME}/.config/sdkman/config"

https://wiki.archlinux.org/title/XDG_Base_Directory#User_directories

@@ -95,6 +95,11 @@ function sdk() {
source "${SDKMAN_DIR}/etc/config"
fi

# Load the sdkman user config if it exists.
if [ -f "${HOME}/.config/sdkman/config" ]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

@sdavids
Copy link

sdavids commented Nov 3, 2023

Are there any updates on this issue? It is quite annoying that sdk-cli pollutes my home directory instead of creating .sdkmanrc file in ~/.config/sdkman/...

$ export SDKMAN_DIR="${XDG_DATA_HOME}/sdkman" && \
  curl -s "https://get.sdkman.io/" | bash

~/.zshrc

### sdkman - https://sdkman.io/

readonly sdkman_home="${XDG_DATA_HOME}/sdkman"

if [ -d "${sdkman_home}" ]; then
  export SDKMAN_DIR="${sdkman_home}"

  if [ -s "${sdkman_home}/bin/sdkman-init.sh" ]; then
    . "${sdkman_home}/bin/sdkman-init.sh"
  fi
fi

It would be nice if there were a SDKMAN_CONFIG_DIR:

$ export SDKMAN_DIR="${XDG_DATA_HOME}/sdkman" && \
  export SDKMAN_CONFIG_DIR="${XDG_CONFIG_HOME}/sdkman" && \
  curl -s "https://get.sdkman.io/" | bash

@felipecrs
Copy link
Contributor Author

@sdavids thanks for your suggestions, but I'll wait to have a go ahead from some maintainer before spending more time in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: stop mixing the default config with user config in a single file
8 participants