There is a way to do a purl cast on to compensate for not having enough yarn for the long-tail, but I’ve yet to learn how to do it. (I’ve seen Lily Chin demonstrate it on Knitty Gritty.)
Until I learn it, and to ensure I have enough yarn for the long-tail, I wrap the yarn around the needle as many times as I need stitches. (20 wraps for 20 stitches, for example). Then I add a little extra (maybe 6 inches) just in case.
Sorry you didn’t have enough yarn for the cast-on; it’s really frustrating, I know!