In the not-too-far future, Mars hosts a few mining complexes that extract, refine and send materials back to our planetary system, as well as some scientific research bases. Commutes between them and Earth are sparse and mainly reserved for the ore, with even sparser travels dedicated to rotating people in and out, so those complexes are of course equipped to be able to survive in autarchy for extended periods of time if need be — facilities, gear and qualified personnel.
Oh no, something funny happens to people on Earth. Due to the nature and unfolding of the event, travels between Earth and Mars have not been resumed in time for the colonists to be brought back before such an operation became impossible, so now they're stuck on their barren rock indefinitely, with no contact with anyone.
Well, fuck it. They've got mines, mining gear, refineries, automated and remote-controlled instruments and vehicles capable of assembling stuff and repairing each other, advanced machinery supported by A.I. software designed to synthesize materials ranging from anti-radiation shielding to medical products, all the brains (organic or artificial) needed to operate and engineer; they'll just build their own ship and get back to their homeworld on it.
For story reasons, I need this enterprise to be a multi-generational one stretching as long as a few centuries. Tee-hee.
There isn't really a shortage of factors I can leverage to push back the project's finish line:
The sheer size of it. Even with a relative abundance of raw resources and tools that are advanced for their original mission, the sustained engineering and building efforts alone make for a formidable challenge, I don't think I really need to expand on that. Especially since the assembly will be made in orbit, to stay in line with the "realistic-looking" approach I would like to take.
The resources allocation balance between the project and basic survival. Dedicating them to the ship means dedicating less to other daily essential tasks. This includes material resources as well as the personnel themselves. And survival will always take priority over the ship, should resources become scarce for whatever reason.
Building the ship might involve, at some point, stripping and repurposing parts from the colony among the ones most difficult (if possible at all) to manufacture — I'm mainly thinking about microchips for instance, but it could also be extreme late-game cases like using the generator(s) to power the ship. If it comes to that, then they start trading the operational status and the productivity of the colony for progress on the project.
So much could go wrong with the population. I should probably do the math to determine how many people there are, but regardless of what the figures are, the nature of the project (and the conditions under which it's being undertaken) forces the colonists to not grow over time, or to a minimal extent. That means everyone is an actively valuable individual, and any untimely death by accident, disease, homicide or suicide is a potential blow to the project. Also if, God forbid, they fall below the minimum viable population number, there isn't even the hope for an eventual recovery.
The previous point can be extended to gear/buildings. Having repair machines that can also take care of each other is one thing, but losing a complex, specialized facility to something as stupid as a fire is another.
How do you find time for the ship when you've got kids to care for, raise, and teach to? As I was writing the point about the population, I realized the colonists will also have to do that eventually — and do it well. They really can't afford to neglect that part, as ending up with a next generation that is not up to the task of carrying on their work makes the whole thing utterly pointless. So this is a major strain on both resources and the time they've got on their hands.
Those are the main things that come to my mind, I'm sure there are others. So my question is: several hundreds of years to complete the ship, in the realm of reasonable suspension of disbelief or way overkill?
Additional note: for the sake of framing, I should specify that whatever happened on Earth affected the population, not the environment, which the colonists know. Earth is still perfectly inhabitable and infinitely more preferable than Mars as a home, so they do have a strong incentive to go back there, as opposed to just declaring that Humans are now a Martian species and roll with it.