Skip to content

Add locking / Handle corrupt hosts-localdev #3

@ChrisHardie

Description

@ChrisHardie

Somehow my /etc/hosts-localdev file became populated in a way that led to errors with list/add/remove operations. It looked like:


---
- domain: domain.com
  ip: 195.5.83.200
195.5.83.200

Then I'd get:

$ localdev list
/Library/Ruby/Gems/2.0.0/gems/psych-2.0.17/lib/psych.rb:376:in `parse': (<unknown>): could not find expected ':' while scanning a simple key at line 4 column 1 (Psych::SyntaxError)
    from /Library/Ruby/Gems/2.0.0/gems/psych-2.0.17/lib/psych.rb:376:in `parse_stream'
    from /Library/Ruby/Gems/2.0.0/gems/psych-2.0.17/lib/psych.rb:324:in `parse'
    from /Library/Ruby/Gems/2.0.0/gems/psych-2.0.17/lib/psych.rb:251:in `load'
    from /Library/Ruby/Gems/2.0.0/gems/localdev-0.4.0/lib/localdev.rb:202:in `block in list'
    from /Library/Ruby/Gems/2.0.0/gems/localdev-0.4.0/lib/localdev.rb:201:in `open'
    from /Library/Ruby/Gems/2.0.0/gems/localdev-0.4.0/lib/localdev.rb:201:in `list'
    from /Library/Ruby/Gems/2.0.0/gems/localdev-0.4.0/lib/localdev.rb:43:in `initialize'
    from /Library/Ruby/Gems/2.0.0/gems/localdev-0.4.0/bin/localdev:22:in `new'
    from /Library/Ruby/Gems/2.0.0/gems/localdev-0.4.0/bin/localdev:22:in `<top (required)>'
    from /usr/local/bin/localdev:23:in `load'
    from /usr/local/bin/localdev:23:in `<main>'

Emptying the hosts-localdev file fixed this. It would be great to have some kind of integrity check on the file, or at least a better error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions