Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[egit-dev] Why is EGit not falling back to HOMEDRIVE/HOMEPATH or user.home if HOME is not set?

Hi!

A user lately reported problems when HOME environment variable was not set on his Windows box: https://community.jboss.org/message/784626
He finally found out about the required steps to set the HOME env variable in http://wiki.eclipse.org/EGit/User_Guide#Setting_up_the_Home_Directory_on_Windows

I'm wonderingwhy EGit would not simply fall back to Windows env variables (HOMEDRIVE/HOMEPATH or USERPROFILE) or even java "user.home".
I bet there are reasons for insiting on HOME, but I miss them. I'd appreciate any insights a lot.

Looking at the EGit code I see it using HOME only and using the above constructions for the user message only:

ConfigurationChecker:

<snip>

    private static void checkHome() {
        String home = System.getenv("HOME"); //$NON-NLS-1$
        if (home != null)
            return; // home is set => ok
        home = calcHomeDir();
        String message = NLS.bind(UIText.ConfigurationChecker_homeNotSet, home);
        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
        boolean hidden = !store.getBoolean(UIPreferences.SHOW_HOME_DIR_WARNING);
        if (!hidden)
            Activator.handleIssue(IStatus.WARNING, message, null, false);
    }

    private static String calcHomeDir() {
        if (runsOnWindows()) {
            String homeDrive = System.getenv("HOMEDRIVE"); //$NON-NLS-1$
            if (homeDrive != null) {
                String homePath = SystemReader.getInstance().getenv("HOMEPATH"); //$NON-NLS-1$
                return new File(homeDrive, homePath).getAbsolutePath();
            }
            return System.getenv("HOMESHARE"); //$NON-NLS-1$
        } else {
            // The user.home property is not compatible with Git for Windows
            return System.getProperty("user.home"); //$NON-NLS-1$
        }
    }

</snip>

Thanks for your insights!

Cheers
André

Back to the top