Skip to content

Update Host: Windows + git bash running vagrant leads to line ending confusion and two dozen UAC prompts while trying to change the hosts file #282

@danowar2k

Description

@danowar2k

#171 isn't fixed (anymore?) in 1.8.9 but maybe it's another cause, so here we go...

  • Windows 7
  • at least since Vagrant 2.2.14 - 2.2.16
  • git version 2.31.0.windows.1
  • vagrant destroy VMNAME started in git bash

Cause:

  • Pathname.read reads the Windows CRLF hosts file and transforms the CRLFs in the file into LF because it "thinks" it should be Unix line endings. This is content A.
  • The file content with LF is checked for changes, the new block with LFs is inserted using regex substitution and then the whole file content is changed from LF to CRLF using String.encode on Windows. This results in content B
  • Content A and content B is compared using !=
  • A has LF, B has CRLF, so they are not equal, so B is saved to file
  • Next time hostmanager checks, it reads the hosts file again, converts the CRLF to LF, etc. etc. etc.

This led to two dozen UAC prompts for writing to the system directory containing the hosts file.

Why that is happening now I can't say. As Ruby hasn't the reputation of having a very stable API, maybe Vagrant had an update of the embedded Ruby version (2.6.7 in Vagrant 2.2.16) and the Pathname.read function now works slightly different than before...but I only discovered the problem when I tried to destroy one of my VMs and was bombarded by UAC prompts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions