As a new PhD supervisor, how should I deal with taking a student to a wrong direction?

On the grand scheme of things, what you just described is not the worst I've heard of. There are cases where a student spends years of their Ph. D. on a problem with nothing to show for in the end, for a variety of reasons. Sometimes even experienced advisors will, intentionally or unintentionally, end up letting their students work on ideas that are terrible in hindsight. A couple of months wasted in the first year really is not a big deal (and there are certainly worse ways to waste one's time as a grad student). Besides just learning the lesson and moving on, here are a couple perspectives that I find helpful:

  1. Defining the research question is not the sole responsibility of the advisor. It is true that the advisor sometimes has to act as a quality check for the students' work, but the point of PhD is to take responsibility for your own work. So the fact that the student just accepted the research question without asking whether it's valid or not (I assume) is partly the student's fault as well.
  2. Try to salvage the effort spent as much as possible. Oftentimes it is possible to recast what you've done in light of a different research question, and you should consider whether that's possible in your case. I'd go so far as to say that one should always work on things that will be publishable even if your original hypothesis turns out to be wrong.

It might be worth checking the policies of your university in relation to supervision requirements. At my university a junior academic (e.g., post-doc) cannot be the primary supervisor of a student, and needs to take a secondary position under the primary supervision of a more experienced academic. From your description it sounds like you have been a victim of the bait-and-switch, being appointed as co-supervisor but then effectively doing the job of a primary supervisor. If you are uncomfortable with this, you could raise it with your Head of Department, and you'd get a sympathetic hearing.

As to the present issue with your student, two months working on a badly formulated problem does not seem to me to be that bad. It is possible that the student would have learned something from the experience anyway, and you should try to help the student draw useful lessons from the failed attempt. If this is impossible, and you think it really was a total waste, you should just apologise to the student for the wild-goose-chase and move on. Plenty of students have had a lot more time than that wasted by bad supervision, and two months is very little in the scope of their candidature.


A few short thoughts:

I eventually also ended up defining a problem for the student,

That's a tad over-controlling. Defining the problem should be at most a joint endeavor of the PhD candidate and the supervisor.

which after 2 months of work, we discovered it is invalid.

Invalid, or too hard to tackle? Or perhaps not as interesting as you had believed?

The student is in his first year, and this is his first research problem.

Yeah, I really dislike this custom of a direct PhD track as the default. It's better IMHO to have a smaller-scope M.Sc. as the default target for graduates interested in trying research, while a direct PhD should be reserved for people who have a good idea of what research they want to do exactly. Your situation is part of the unfortunate but foreseeable consequences. Of course, it's not relevant to suggest to the student to switch...

For more concrete advice I would need more context, such as what has motivated the Ph.D. candidate to go into doing research, what motivated you to choose/define the problem you did, whether this is part of a larger, multi-person single effort or not, etc.