vector bundle trivial over every compact subset, then it is globally trivial 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?

 A: As Igor Belegradek showed in the comments, one could find an example by finding a CW-complex $X$ and a map $X \to BO(n)$ which is not nullhomotopic, but where the restriction to every finite subcomplex is nullhomotopic.  Such a map is called a phantom map. The question "is this map nullhomotopic?" has the same answer whether or not we are asking our maps to preserve the basepoint, and so I will take some steps that are casual about basepoints.
For our example, we're going to take $n = 3$ and $X = \Sigma \mathbb{CP}^\infty$, the suspension of $\mathbb{CP}^\infty$.  This is a CW-complex whose finite subcomplexes are $\Sigma \mathbb{CP}^n$.
These spaces are simply connected, so $[\Sigma \mathbb{CP}^n, BO(3)] = [\Sigma \mathbb{CP}^n, BSO(3)]$ for all $n \leq \infty$.
Then $[\Sigma \mathbb{CP}^n,BSO(3)] = [\mathbb{CP}^n, SO(3)]$ for all $n \leq \infty$ by the loop-suspension adjunction. ("A vector bundle on a suspension is determined by a clutching function.")
We can also identify $SO(3)$ with $\mathbb{RP}^3$, which has $S^3$ as a double cover.  Again because $\mathbb{CP}^n$ is simply connected, $[\mathbb{CP}^n,SO(3)] = [\mathbb{CP}^n, S^3]$ for all $n \leq \infty$.
One of the famous examples of phantom maps is a map constructed by Brayton Gray: a map $\mathbb{CP}^\infty \to S^3$ which is not nullhomotopic, but where the restriction to $\mathbb{CP}^n$ is nullhomotopic for any $n$.  (I believe that this is in his paper "Spaces of the same $n$-type, for all $n$", and that a proof can be given using Milnor's $\lim^1$ sequence.)  Pushing this back, we get a vector bundle on $\Sigma \mathbb{CP}^\infty$ whose restriction to any finite subcomplex is trivial.
A: 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$.
