Jira (BOLT-1156) Bolt's r10k should use %LOCALAPPDATA% for Windows cachedir

4 views
Skip to first unread message

Reid Vandewiele (JIRA)

unread,
Mar 1, 2019, 2:51:03 PM3/1/19
to puppe...@googlegroups.com
Reid Vandewiele created an issue
 
Puppet Task Runner / Bug BOLT-1156
Bolt's r10k should use %LOCALAPPDATA% for Windows cachedir
Issue Type: Bug Bug
Assignee: Unassigned
Attachments: Image from iOS.jpg
Created: 2019/03/01 11:50 AM
Priority: Normal Normal
Reporter: Reid Vandewiele

The bolt puppetfile install command, when run on Windows, uses r10k's default cachedir setting of ~/.r10k. This can be problematic when used with roaming profiles, in the event the HOME environment variable on Windows points to e.g. a network drive that is unavailable.

In general, it's not good practice to rely on HOME for this kind of thing on Windows. We should ensure that when bolt puppetfile install is invoked on Windows it uses LOCALAPPDATA, instead of HOME, for the cachedir.

This could be done in Bolt, or seems like it could equally well be handled as an improvement to r10k itself (followed by Bolt using that fixed version of r10k).

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Reid Vandewiele (JIRA)

unread,
Mar 6, 2019, 1:42:03 PM3/6/19
to puppe...@googlegroups.com
Reid Vandewiele commented on Bug BOLT-1156
 
Re: Bolt's r10k should use %LOCALAPPDATA% for Windows cachedir

This seems to be a problem not infrequently for corporate Windows users.

Kevin Reeuwijk [March 1]
[...] it has nothing to with roaming profiles, but with a user’s homedrive. This is something you don’t usually see in Linux but very prevalent in corporate Windows environments. It gives the user a mapped network drive to a personal space on a file server, to promote storing documents on the server instead of on the client. Some users employ Offline Files functionality to keep this drive available even in disconnected scenarios, but it’s not a loved feature due to plenty of bugs. Hence there are also plenty of users that simply don’t have their homedrive (H: in this case) mapped at all when disconnected from the corpnet. That was the case here and created a problem for r10k caching.

Kevin Reeuwijk [March 6]
[...] %HOMEDRIVE% will get set as soon as the IT admin configures a home drive for the user in Active Directory. This is still a common practice, so it's something you'll encounter frequently. In the Bolt Workshop in Denmark today, we had another 2 users that had this issue.

Kevin Reeuwijk (JIRA)

unread,
Jul 29, 2019, 6:49:04 AM7/29/19
to puppe...@googlegroups.com

I managed to reliably reproduce this problem. The culprit is the HOMEDRIVE and HOMEPATH environment variables.

When a Windows admin configures the "Home folder" of an Active Directory user to connect to a network drive, the HOMEDRIVE and HOMEPATH environment variables for the user will change on the Windows client:

  • User with Home folder set to a network drive (H
    • HOMEDRIVE = H:
    • HOMEPATH = \
  • User with Home folder not configured
    • HOMEDRIVE = C:
    • HOMEPATH = \Users\username

When 'bolt puppetfile install' runs the first time, it will attempt to create a .r10k directory in %HOMEDRIVE%%HOMEPATH%, which translates to H:\.r10k for the user with a home network drive, and C:\Users\testuser\.r10k for the user without a home network drive.

If the user is disconnected from their network drive, r10k fails to create the .r10k folder and the errors in the screenshot appear. I have verified that running the following commands first will work as a temporary workaround:

$Env:HOMEDRIVE = C:
$Env:HOMEPATH = "\Users\$Env:USERNAME"

If the user's home network drive is connected, r10k does work and no workaround is needed. However, having the .r10k folder created on the user's home network drive is undesirable. The same goes for the Bolt analytics file, which ends up at H:\.puppetabs\bolt\analytics.yaml in the connected home network drive scenario. These things should go to the user's profile, not their home network drive:. On Windows:

  • r10k should use the LOCALAPPDATA environment variable
  • Bolt should use the APPDATA environment variable

Glenn Sarti (JIRA)

unread,
Jul 29, 2019, 7:50:03 AM7/29/19
to puppe...@googlegroups.com
Glenn Sarti commented on Bug BOLT-1156

As an addendum

APPDATA will roam with the user (log into different PCs). Also APPDATA honors folder redirection (which is much preferred than the "old" HOMEDRIVE/HOMEPATH env vars)

LOCALAPPDATA will NOT roam and is specific to the machine the user is on.

As a rule, you should not be constructing the paths, but use the special folders API and/or environment variables (APPDATA, LOCALAPPDATA) for this information

Desktop, My Documents etc. can all be redirected and is actually preferred than setting HOMEDRIVE etc.

Other note is dot folders (e.g. .r10k) are not hidden on Windows. A common refrain from windows people is stop polluting my profile with dot folders.

Reply all
Reply to author
Forward
0 new messages