The issue comes from targeting a creature you know exists that is still Invisible. When a creature is hidden/Invisible, how can you know where to target?
This distinction was a lot clearer in the 2014 rules, when being invisible was an entirely separate condition from being hidden. Being unseen but not hidden (for example, if you are invisible but out in the open) would mean attackers know your location, and so can target you with attacks, but have disadvantage on their attack rolls. Being unseen is a prerequisite to becoming hidden, since the rules stated that you can’t hide from a creature that can see you. If you are hidden, a creature no longer knows your location, and has to guess where to attack. Now, if you don’t move after becoming hidden, it’s probably pretty easy to guess your location, and either target it, or move to a location from which they
can see you, which would result in you no longer being hidden, since you would lack the prerequisite of being unseen. However, if you hide and then move to a new location, without being spotted in the interim, a creature just has to pick a spot to attack and hope you’re there.
The 2014 PHB states “When you attack a target that you can't see, you have disadvantage on the attack roll. This is true whether you're guessing the target's location or you're targeting a creature you can hear but not see. If the target isn't in the location you targeted, you automatically miss, but the DM typically just says that the attack missed, not whether you guessed the target's location correctly.” I would assume the 2024 PHB deleted this text as part of its crusade against wordcount. But, yeah, the attacker would have to specify where it’s attacking, make an attack roll with disadvantage regardless of if the target is actually there, and if they aren’t there the DM would say the attack missed, regardless of the results. If it’s the DM controlling the attacker, you might have to improvise some sort of random method for determining if the attacker guesses the right location.
How do you guess its location?
You just guess. Either specify a square/hex if playing on a grid, a one-inch area if playing by measurements Warhammer style, or give a verbal description (e.g. “fifteen feet northwest of where I last saw him”) in theater of the mind. If it’s an NPC controlled by the DM who’s guessing, you might have to improvise a randomized way of determining whether the attacker guesses the right location.
In the example of a rogue hiding behind a boulder and then sneaking out to hit someone, if I Ready an action to attack the rogue when I can target it, does that mean as soon as the rogue leaves full cover I can now attack (I just get disadvantage)?
Again, the answer was clear under the 2014 rules - if the rogue leaves cover, the they stop being hidden because they stop being unseen, unless the DM determines that you’re sufficiently distracted not to see the rogue when they leave cover, in which case you wouldn’t be able to target them because you don’t know their location, and your Ready trigger doesn’t occur.
In the 2024 rules it’s less clear because they’ve conflated hiding with invisibility. The latest errata says the hide action gives you the invisible condition while you’re hidden, and the condition ends if a creature finds you. But, the only things it specifies for how a creature finds you is if you attack, cast a spell with a verbal component, or make a sound louder than a whisper, or if an enemy beats your stealth check with their perception check. So, my strict RAW interpretation would be that when the rogue pops out, if your passive Perception is still lower than the result of their Stealth check, then they are still hidden from you and your Ready trigger doesn’t occur. But if they attack you after popping out, the attack roll would cause them to stop being hidden, so their Invisible condition would end, and you would be able to target them again, which means at that point your Ready trigger would go off and you could attack them without disadvantage.
What if the rogue is hiding in Magical Darkness - can I attack them anyway?
Well, if they are hiding (via a successful hide action) in the darkness, then you don’t know their location and have to guess where to attack. But the area of magical darkness at least narrows down the range of possible locations they could be in.
How do I know where the rogue is if I can't see them?
Well, if they’re hidden, you don’t. If they aren’t hidden, you determine their location by relying on other indications of their presence - most likely sound in this case.