Regarding origins of the word “bug”:
In 1878 it appears twice in letters by Thomas Edison. Once in a letter to Western Union President William Orton:
“You were partly correct, I did find a ‘bug’ in my apparatus, but it was not in the telephone proper. It was of the genus ‘callbellum.’ The insect appears to find conditions for its existence in all call apparatus of telephones.”
And in a letter to Theodore Puskas:
“This thing gives out and then that. ‘Bug’—as such little faults and difficulties are called—show themselves, and months of anxious watching, study, and labor are requisite before commercial success—or failure—is certainly reached.”
(Apparently, Edison began using the word “bug” in the 1870s and was soon using it frequently. And, regarding the phrase “fixing a bug”, a British reporter wrote in 1889, “Mr. Edison…had been up the two previous nights working on fixing ‘a bug’ in his phonograph.”)
However, to me neither of the two letters look like they were introducing a new term. Rather, Edison is playing with the concept for effect, hinting at this having been an established term which Edison happened to like. (Mind the prominent position, once making the opening of a letter, once as the ending – see the images below. – In the letter to W. Orton, Edison is clearly trying to make a good impression, overall rather formal, but playful, and using his best longhand writing. However, if the term “bug” was new to you and just introduced here, the impression produced would be more the one of a madman. I doubt that Edison would have risked this in what was an important connection to him. If anything, it’s more like Orton had introduced the term to Edison, who is picking it up, just like he is picking up past conversations elsewhere, e.g. where he is assuring the absence of any mathematicians’ desks. )
I’ve read somewhere that “bug” had been a well used term in British engineering communities (no source for this).
Sources (including facsimiles of the letters):
[1] https://www.atlasobscura.com/articles/who-coined-term-bug-thomas-edison
[2] Error Page
[3] http://www.testingyes.com/term-bug-fort-myers-and-thomas-edison/
[Highlights by me, N.L.]