Not everyone loves compost. Although legions of ecstatic gardeners extol the alchemy of making Black Gold, someone will always issue a dark warning against a compost pile in your back yard. If you build it, they will come. Your precious crucible will soon house more fauna than the National Zoo.

Because we live in the country, we’re used to all manner of creatures scurrying, scampering and digging around the property. At one time or another, we’ve had raccoons, deer, skunks, porcupines, rabbits, birds and squirrels prey on garden plants, dealt with by a judicious mix of fences, nets, traps and buckshot. As for the compost pile, sea gulls and crows are the most avid customers, easily foiled by burying anything especially fresh and delicious (like last night’s lobster shells) in the heap, out of view. Visiting dogs are a problem only when the owners object to what we’ve “fed” their pet. (Ever hear of a leash?) We also, once, encountered the great bete noire of composting: the rat.

People logically find rats creepy, scary and an emblem of squalor. It is considered gauche to attract them to the neighborhood. And they are not, as people will tell you, only attracted by meat scraps, dairy, fish and cooked food. They like any food scraps, and the compost pile is also a handy place for them to nest and hide. But there’s a very simple solution: Build a wood-framed compost bin, and then staple hardware cloth mesh with half-inch openings to the bottom, the lid and all four sides.

For us it’s very important to keep rats out of livestock feed and out of the greenhouse, where they would eat young plants, so we monitor all areas to keep the farm rat-free. A friend once took the aggressive approach of running a hose from his truck’s exhaust pipe to an obvious rat burrow in his compost pile. That was a success, but his experiment with a blast from his flame gun was not. He set the pile on fire. Most likely, it was too dry. A healthy, moist, rapidly decomposing heap is far less likely to attract rodents.

We’re much more bothered by the far more numerous and destructive voles that nibble our salad crops. Part of our vole program is to encourage the participation of owls, hawks, snakes and other helpful predators. Mowing weedy areas in the yard helps to expose voles to their sharp eyes. That helps to deter rats, too. My husband has also suggested that we get a Jack Russell terrier. These very cute and hyperactive animals dispatch all rodents — rats especially — with glee. Unfortunately, they dig up the garden mercilessly in the process.

One day I was turning a compost pile, and when I got down to the bottom, a rat suddenly ran out. I admit it gave me a bit of a start.

“We’re getting a Jack Russell,” my husband said.

“We. Are. Not. Getting. A. Jack. Russell.”

“Well, how about a Jack Daniel’s?” he replied.

Not a bad idea.

Damrosch is a freelance writer and the author of “The Garden Primer.”

More online

6Read more about growing your own food at washingtonpost.