In fact, your mushrooms may falter even if you do everything right, which probably seems like a paradox: How can it be so hard to grow them in the relatively sterile confines of a temperature-controlled home, yet so easy to find them bursting out of piles of cow shit?
It helps to think of mushroom cultivation as microscopic world building rather than plant growing. If you prepare a clay pot for a seedling and place it on a window sill inside your home but never actually plant anything, you can reasonably expect the pot to remain barren indefinitely. When you make a good home for mycelium, however, you’ve made a damp, welcoming environment for all manner of tiny, invisible, and invasive travelers. Do nothing with that container, and unwelcome life will eventually find a way there, just as it does on a forgotten piece of sharp cheddar in the back of your fridge.
One must make peace with failure—initially but also throughout one’s mycological journey.