Example of a bijective continuous self mapping whose inverse is not continuous on a complete subspace of $\mathbb{R}$ I gave an answer to the following question Finding an (easy) example of a bijective continuous self mapping whose inverse is not continuous. In this question the OP asked for a continuous mapping $f: (X,d) \rightarrow (X,d)$ which is bijective, continuous and not a homeomorphism (and $(X,d)$ a metric space). The famous Kavi Rama Murthy then remarked that all the counterexamples are for metric spaces which are incomplete. I gave it some thoughts and come up with a counterexample where the space is complete. However, I did not manage to make it work within $\mathbb{R}$. So my question is:

Does there exist some closed subset $X\subseteq \mathbb{R}$ and a function $f: X \rightarrow X$ which is bijective, continuous (wrt to the subspace topology) and not a homeomorphism.

My intuition tells me that it is not possible as there are at most two noncompact connected components. Thus, preventing us to play the game of gluing together connected components to prevent the inverse function to be continuous. Let me elaborate a bit on this thought.
We note that we may wlog assume that $X$ has no unbounded connected components. Simply as those would be the only noncompact connected components and as continuous functions send compact sets to compact sets and our $f$ is bijective, we would have that it sends unbounded connected components to unbounded connected components. Either the image of the unbounded connected component covers an unbounded connected component, or we need to cover a bounded half-open interval by countably many compact disjoint intervals (which is not possible using a Baire-category argument, see for example here https://terrytao.wordpress.com/2010/10/04/covering-a-non-closed-interval-by-disjoint-closed-intervals/). Thus, unbounded connected components get swapped or fix and hence, the $X$ with the unbounded connected components replaced by points are a counterexample as well.
Hence, $X$ can be taken to be a countable union of compact intervals. On the other hand, it is not possible that $X$ is compact (continuous functions from a compact space into a Hausdorff space are closed, which would make our function a homeomorphism).
Furthermore, using again that we cannot cover a half-open interval with countably many disjoint compact intervals, we get that all that $f$ can do is permuting connected components (it maps some intervals to another interval and points to points). 
 A: It seems my intuition was wrong. Indeed, such an example does exist. I always find it a bit strange when people answer their own question, but for once I'll do it myself (I did not know the answer when I posted the question and as you may see on my profile I do not use this as a cheat to gain reputation).
After some more thought I realized that one of the things that could go wrong is that the inverse function "sends points to infinity". Namely, if we had 
$$ Y= \{ 0 \} \cup \bigcup_{n\in \mathbb{N}_{\geq 1}} \left\{ \frac{1}{2^n}\left( 1 + \frac{1}{2} \right) \right\} \cup \bigcup_{n\in \mathbb{N}_{\geq 1}} \left\{ 2^n\left( 1 + \frac{1}{2} \right) \right\}, $$
then we could do some kind of "inversion" around $1$ while fixing the origin. Namely, we want for $n\in \mathbb{N}_{\geq 1}$
$$f(0):=0, \quad f\left( 2^n\left( 1 + \frac{1}{2} \right) \right) := \frac{1}{2^{n}}\left( 1 + \frac{1}{2} \right). $$
Then clearly the inverse of this function (if it was bijective) would be discontinuous at the origin. How to we make this bijective? We apply the trick that we can "create" or "destroy" a point if we add some converging sequence for it, simply by shifting along the sequence. Hence, we define
$$ X= \{ 0 \} \cup \bigcup_{n\in \mathbb{N}_{\geq 1}} \left\{ \frac{1}{2^n}\left( 1 + \frac{1}{2^k} \right) \ : \ k\in \mathbb{N}_{\geq 1} \right\} \cup \bigcup_{n\in \mathbb{N}_{\geq 1}} \left\{ 2^n \left( 1 + \frac{1}{2^k} \right) \ : \ k\in \mathbb{N}_{\geq 1} \right\}. $$
We "shift into $\frac{1}{2^n}$" and "shift out of $2^n$". Namely, we define for all $n\in \mathbb{N}_{\geq 1}$
$$ f(0):= 0, \qquad f\left( \frac{1}{2^n} \right) := \frac{1}{2^n}, \qquad f\left( 2^n \right) := 2^n. $$
and
$$ f\left( \frac{1}{2^n}\left( 1 + \frac{1}{2^k} \right) \right)
:= \frac{1}{2^n}\left( 1 + \frac{1}{2^{k+1}} \right), \qquad
 f\left( 2^n\left( 1 + \frac{1}{2^k} \right) \right) = \begin{cases} 2^n \left( 1 + \frac{1}{2^{k-1}} \right),& k\neq 1, \\
\frac{1}{2^n}\left( 1 + \frac{1}{2} \right),& k=1.\end{cases}$$
Thus, we found a continuous, bijective map $f: X \rightarrow X$ which is not a homeomorphism. And $X\subseteq \mathbb{R}$ is a closed set and thus complete.
