Dev Notes

Various Cheat Sheets and Resources by David Egan/Carawebs.

Atom Crashes on Startup When A Repo has Uncommitted Changes


Atom, Git
David Egan

Atom is a free open source text editor “A hackable text editor for the 21st Century”. I really like it. It is fast, reliable, and hackable.

I recently experienced an odd crash when attempting to open a particular directory. The circumstances were a bit unusual and probably won’t crop up again, but I’m documenting this anyway to avoid repeating myself if it does reoccur.

Context

Building a git based generator to speed up my WordPress plugin workflow.

The generator scaffolds out a namespaced WordPress plugin. The project is closely based on the WordPress Plugin Boilerplate, except the class structure conforms to PSR-4 autoloading standards, and uses a Composer autoloader. Plugins devloped this way are not intended for distribution - they are for our own projects, where we always control the production environment.

Namespacing & autoloading may not be the “WordPress way”, but it encourages small, tidy classes and I like it a lot.

The workflow will involve invoking a BASH script that git clones the starter project, copies it, and renames files and file references within the new project. The script also gives the option to create and push to a new GitHub repo for the project.

The idea is to run one command, enter the new plugin name, and be ready to go.

The Problem

During testing my BASH script successfully:

  • Cloned the starter project
  • Copied and renamed the project
  • Amended filenames and references to files within the project

To save time, I chose NOT to set up a new git repo.

When trying to open the new project in Atom, Atom crashed. Safe mode did not help. Atom would open other directories without issue.

The Clue

This issue reported a crash when trying to open a file that had been modified but not committed.

Verification

On temporarily renaming the .git directory, the project repo opened in Atom without any problem.

Solution

When files were modified by my script, they contained uncommitted changes. I think this was what triggered the crash.

In this case, when creating a new project, if the user does not choose to create a new repo the original .git directory should be removed.


comments powered by Disqus