Linette claimed the first set 6-1 on centre court as the world number one struggled to capture the form that brought her the title in 2019.
The 25-year-old Australian took a medical time out at the end of the opener and played a little more verve at the start of the second set.
But after her Polish opponent held serve to make it 2-2, Barty shook her head and put her racket away.
Magda Linette progresses to the third-round after 2019 Champion Ashleigh Barty retires due to injury, 6-1, 2-2 [ret].
— Roland-Garros (@rolandgarros) June 3, 2021
The Pole meets Ons Jabeur next. #RolandGarros pic.twitter.com/qZvFBe3GaL
Though she had cited concerns about her left hip ahead of the French Open, it was nevertheless a disappointing denouement for Barty who missed the 2020 tournament due to her fears over the coronavirus pandemic.
"We have had such a brilliant clay court season," said Barty. "And to get a little bit unlucky with the timing to have something happen over the weekend and the just run out of time is heartbreaking.
"But it won't take away the brilliant three months that we have had as much as it hurts right now."
Linette will play Ons Jabeur - a straight sets winner of Astra Sharma - for a place in the last 16.