Bug 1305765 - windows oc cli doesn't use home env variable as home directory
windows oc cli doesn't use home env variable as home directory
Product: OpenShift Container Platform
Classification: Red Hat
Component: Command Line Interface (Show other bugs)
All Windows
unspecified Severity medium
: ---
: ---
Assigned To: Fabiano Franz
Wei Sun
Depends On:
  Show dependency treegraph
Reported: 2016-02-09 03:00 EST by Christophe Augello
Modified: 2016-05-12 12:28 EDT (History)
8 users (show)

See Also:
Fixed In Version: atomic-openshift-
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-05-12 12:28:30 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Christophe Augello 2016-02-09 03:00:32 EST
Description of problem:
Since oc windows oc cli seems to use homeDrive + homePath to define the user's home directory. before oc kubeconfig was written in directory from HOME env variable.

Version-Release number of selected component (if applicable):
oc cli

How reproducible:

Steps to Reproduce:
1. Have homeDrive != actual home drive (Z:\ vs C:\

Actual results:
C:\Users\XXXX>oc version
oc v3.1.1.6
kubernetes v1.1.0-origin-1107-g4c8e6f4

C:\Users\XXXX>oc whoami
error: open Z:\/.kube/config: The system cannot find the path specified.

C:\Users\XXXX>env | grep HOMEDRIVE

C:\Users\SHJN2064>env | grep HOME

Expected results:
If HOME is set, use home prior to homeDrive + homePath

Additional info:
Comment 1 Fabiano Franz 2016-02-11 15:58:16 EST
We have to be careful about relying in the HOME env var on Windows because in many cases it is set to the wrong location, we've seen for example HOME=/c in a few cases. 

The recommended way of doing it is to first try HOMEDRIVE + HOMEPATH and then fallback to USERPROFILE, which is what we are doing[1]. We could add a check for the existence of these two locations, and add HOME as a third location which would be used if any of the other two options are available as env vars and/or path doesn't actually exist.

Could you please confirm what you have in USERPROFILE? 

[1] References
Comment 2 Fabiano Franz 2016-02-19 12:24:34 EST
Fixed in https://github.com/openshift/origin/pull/7449
Comment 3 Yanping Zhang 2016-02-22 00:00:35 EST
The fix works on latest origin client oc v1.1.3-170-g14b50fd, but the codes are not merged in enterprise, so still can reproduce the bug on the latest oc v3.1.1.904, wait for a puddle containing the fix to verify the bug.
Comment 4 Christophe Augello 2016-02-22 07:15:39 EST


Could we implement in https://github.com/openshift/origin/pull/7449 in downstream?
Comment 5 Fabiano Franz 2016-02-22 12:37:30 EST
Christophe yes, it's coming downstream soon.
Comment 6 Yanping Zhang 2016-02-22 21:35:37 EST
Tested on v3.1.1.905
Steps to verify:
$ export HOMEDRIVE=Z:
$ env|grep HOME
$ ./oc.exe whoami
$ env|grep HOME
$ ./oc.exe whoami

The bug has been fixed on v3.1.1.905, so move it to Verified.
Comment 9 errata-xmlrpc 2016-05-12 12:28:30 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.