Is the following statement true (and if not, are there additional assumptions that make it true?)
A vector bundle on a variety which is trivial if restricted to a closed subvariety is trivial on an open neighbourhood of this variety.
I would be particularly happy with a proof or reference treating vector bundles as locally free sheaves I am mainly interested in the cases of algebraic vector bundles over $\mathbb{C}$ and holomorphic vector bundles, although I think this statement would be interesting in other categories of vector bundles as well.
Some additional remarks and questions:
1) If the statement is true, can we weaken the assumptions? (e.g. more general classes of schemes instead of varieties, reflexive or even coherent sheaves instead of vector bundles)
2) There are two possible notions for "restriction" if thinking of a vector bundle as a locally free sheaf: Pullback to the closed subvariety in terms of sheaves or in terms of sheaves of modules. Does this distinction matter here or are the conditions (maybe by some Nakayama's Lemma argument?) equivalent in our case?
3) If closed would have to be changed to proper/compact, that would still be enough for me.
4) I think this holds in the continuous category by the following (sketchy) argument (Say $X$ is a paracompact Hausdorff space and the closed subspace is called $Z$):
On $Z$ there are $n$ linearly independent sections $s_i$. Take a trivializing open cover of the ambient space $X$ for the vector bundle and extend the $s_i$ on each of the open sets having nonempty intersection with $Z$ (this is possible because wikipedia tells me that hausdorff paracompact spaces are normal). The extended sections are still linearly independent on (probably smaller) open subsets still covering $Z$ and we can glue them using a partition of unity.
Here is a sketch (and there are other methods too) for jorst.
For any point $p\in\mathbb{P}^2$, one has an exact sequence, $0\to\mathcal{O}_{\mathbb{P}^2}(-2)\to\mathcal{O}_{\mathbb{P}^2}(-1)\oplus \mathcal{O}_{\mathbb{P}^2}(-1)\to \mathfrak{m}_p\to 0$, where $\mathfrak{m}_p$ is the ideal sheaf defining $p$. Take a quadric $Q$ not passing through $p$ and consider the inclusion $\mathcal{O}_{\mathbb{P}^2}(-2)\to\mathcal{O}_{\mathbb{P}^2}$ given by multiplication by $Q$. Then we can take the push out of the above sequence using this map to get an exact sequence, $0\to\mathcal{O}_{\mathbb{P}^2}\to E\to\mathcal{m}_p\to 0$. Using the fact that $Q$ does not pass through $p$, one easily checks that $E$ is a vector bundle. If we restrict to any line $L$ not passing through $p$, the sequence becomes, $0\to \mathcal{O}_L\to E_{|L}\to \mathcal{O}_L\to 0$, which splits and so $E_{|L}$ is trivial. If these sections lift to $E$ in a neighbourhood of $L$, one sees that they actually lift to $E$ over the whole projective space. But then $E$ must have at least two sections, which is absurd from the exact sequence, since $H^0(\mathfrak{m}_p)=0$.