We consider an infinite horizon portfolio problem with borrowing constraints, in which an agentreceives labor income which adjusts to financial market shocks in a path dependent way. Thispath-dependency is the novelty of the model, and leads to an infinite dimensional stochasticoptimal control problem. We solve the problem completely, and find explicitly the optimalcontrols in feedback form. This is possible because we are able to find an explicit solutionto the associated infinite dimensional Hamilton-Jacobi-Bellman (HJB) equation, even if stateconstraints are present. To the best of our knowledge, this is the first infinite dimensionalgeneralization of Merton’s optimal portfolio problem for which explicit solutions can be found.The explicit solution allows us to study the properties of optimal strategies and discuss theirfinancial implications.