A third way to think about Anton Petrunin's example is that $S^2 \to {\mathbb R}P^2$ is a ${\mathbb Z}_2$ principal bundle where the action of ${\mathbb Z}_2 = \lbrace +1, -1 \rbrace $ is the obvious action on vectors in ${\mathbb R}^3$. As ${\mathbb Z}_2$ is a subgroup of $U(1)$, the circle group of complex numbers of length one, you can use standard principal bundle constructions to extend this ${\mathbb Z}_2$ principal bundle to a $U(1)$ principal bundle. In the case at hand these constructions just give the quotient of $S^2 \times S^1$ by ${\mathbb Z}_2$ as above.
You can compute the transition functions of this $U(1)$ bundle explicitly with respect to the standard open cover of ${\mathbb R}P^2$ by just computing the same for the ${\mathbb Z}_2$ bundle $S^2 \to {\mathbb R}P^2$ and check that they give you a Cech representative for the non-zero class in $H^2({\mathbb R}P^2, {\mathbb Z}_2) = {\mathbb Z}_2$.
The fact that this $U(1)$ bundle has a reduction to ${\mathbb Z}_2$ also tells us that when we square it we will get a trivial $U(1)$ bundle. Just think of squaring the ${\mathbb Z}_2$ valued transitions functions to get transitions functions for the squared bundle. Obviously they all just take the value $1$.
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.
Best Answer
Let $U$ and $V$ be two copies of the real line and make a space $X$ by gluing them by the identity along the strictly positive half-line: $x\in U$ equals $x\in V$ for $x>0$. Now make a rank one vector bundle over this space by taking a trivial bundle over each of the lines: glue $U\times\mathbb R$ to $V\times \mathbb R$ by identifying $(x,y)\in U\times\mathbb R$ with $(x,f(x)y)\in V\times\mathbb R$ for $x>0$. Let's choose the clutching function to be $f(x)=x$, or any other nowhere zero continuous function of positive real $x$ that cannot be extended to a nowhere zero function of all real $x$. Surely $X$ is contractible, but the bundle can't be trivial since the function $f:U\cap V\to GL_1(\mathbb R)$ cannot be expressed as the quotient of a function extendible to $U$ and a function extendible to $V$, since that would make it itself extendible to all of $\mathbb R$.