How to melon / pumpkin farm in Minecraft?

I have two blocks of tilled dirt and water surrounding the blocks. One block has the seed planted and the other block is empty. There's a sprout but melons / pumpkins won't appear, even when using bonemeal.

If you have a wall or another plant on every side but one of the seedling the melon or pumpkin should grow on the free space in front of it (the dirt block)