Peel and chop onions and garlic, fry in oil. Also cut the ham into small pieces and roast it with it. Add the pumpkin cubes and roast for a few more minutes. Now pour in the vegetable stock and simmer for about 10 minutes (possibly longer, until the pumpkin cubes are soft). Stir in the cream cheese and season with the spices.
In the meantime, cook the spaghetti according to the package instructions and then serve immediately with the sauce.
Sprinkle with freshly grated parmesan if you like.