Why isn't there any ruler who used mass crossbow during the middle ages like formationed muskets

by Almsgivers

I dont know about crossbow production, but it's a fast way to arm peasant armies. Also cross bows are extremely effective against armor

Zinegata

The problem with your premise is that arming a peasant army is very different from having an effective army.

Missile infantry requires extensive training. Without training such "troops" would be more a menace to themselves than the enemy. It is one thing to pull a trigger. It is a different thing to aim and fire at another human being, and a completely different thing to aim and fire at a very angry looking human being in armor charging at you with a horse. Moreover can such untrained masses tell friend from foe? Can they even be relied upon to shoot in formation without ending up shooting each other?

This was why disciplined drill was necessary with musket armies - drill was designed to make everyone load, aim, and fire together so that the soldiers don't end up getting in each other's way and shooting one another. It also allowed the commanders to more easily direct the fire so they don't end up shooting their own allies.

Crossbows by most accounts also needed this kind of training, which is why crossbow troops were often specialist mercenaries. At Crecy for instance the crossbowmen were all mercenaries from Genoa. Interestingly, their opponents - the English longbowmen - were in fact semi-professional soldiers too (contrary to popular belief they were just ordinary peasants) who trained extensively in longbow use when not in campaign. Indeed, that the longbows were used as a massed-fire weapon - wherein individual longbowmen were not expected to target individual enemy soldiers and were instead tasked to blanket an entire area with arrows - attests to the teamwork and coordination needed to make the longbows work..