TITLE: vector bundle trivial over every compact subset, then it is globally trivial
QUESTION [33 upvotes]: Let $X$ be a non-compact metric space (though if the answer to the question is positive, then it probably also holds for more general spaces like, e.g., paracompact Hausdorff) and $E \to X$ a vector bundle over it.

Suppose that over every compact subset $K \subset X$ the restricted bundle $E|_K$ is trivial. Can we conclude that $E$ is globally trivial?

REPLY [19 votes]: If you let $T=S^1 \times D^2$ be the solid torus and pick an embedding $i: T \to \mathrm{int}(T)$ which multiplies by 2 in $\pi_1$, the direct limit $X = \varinjlim(T \xrightarrow{i} T \xrightarrow{i} \dots)$ is a smooth 3-dimensional manifold (non-compact, but admitting a proper embedding into $\mathbb{R}^4$).  Its homotopy type is $K(\mathbb{Z}[\frac12],1)$, so by the universal coefficient theorem $[X,\mathbb{C}P^\infty] = \mathrm{Ext}(\mathbb{Z}[\frac12],\mathbb{Z}) \neq 0$, so there exists a non-trivial complex line bundle $L \to X$.  (We can even take $L \subset X \times \mathbb{C}^2$ since $[X,\mathbb{C}P^1] = [X,\mathbb{C}P^\infty]$.)  Any compact $K \subset X$ is contained in a submanifold diffeomorphic to $T \simeq S^1$, so $L \vert_{K}$ is trivial.
EDIT: in fact, pick any homomorphism $\pi_1(X) = \mathbb{Z}[\frac12] \to \mathbb{C}^\times$ which doesn't factor through the exponential map $\mathbb{C} \to \mathbb{C}^\times$ and use that to define $L$.