Retracting one contractible space to another What is an example of topological spaces $X \subseteq Y$ such that $X$ is closed in $Y$, and $X$ and $Y$ are both contractible, yet $Y$ does not retract to $X$? I'm having a hard time coming up with a quick example. Requiring $X$ to be closed in $Y$ seems to rule out the case where $[0, 1]$ does not retract to $(0, 1)$. Or is there no such example, and does such $Y$ always retract to such $X$?
 A: Let $Y = \mathbb{R}^2$.
For each positive integer $n$, let $A_n$ be the segment $\{\frac{1}{n}\} \times [0,1] \subset \mathbb{R}^2$.  Let
$$
X = \left(\{0\}\times [0,1]\right) \cup \left([0,1] \times \{0\}\right) \cup \bigcup_{i}A_i
$$
Then $X$ is closed in $Y$ and is contractible.  But there is no retraction $\mathbb{R}^2 \rightarrow X$.
To see this, suppose $f\colon \mathbb{R}^2\rightarrow X$ is a retraction, and consider the segment $S = [0,1] \times \{1\}\subset \mathbb{R}^2$.  This segment intersects $X$ at all the points $\left(\frac{1}{n}, 1\right)$, so the sub-segments between these points must be mapped by $f$ to paths along $X$ connecting them.  In particular, each such sub-segment must have a point $s_n$ mapped to $\left(\frac{1}{n}, 0\right)$, since any path from $\left(\frac{1}{n}, 1\right)$ to $\left(\frac{1}{n+1}, 1\right)$ in $X$ passes through this point.
Now consider the sequence $f(s_n)$.  On the one hand, it must converge to $\left(0,1\right)$ since the $s_n$ converge to $\left(0,1\right)$, which is fixed by $f$ since it lies in $X$.  On the other hand, since $f(s_n) = \left(\frac{1}{n}, 0\right)$, the sequence must converge to the origin, giving a contradiction.
