We know if we have a regular variety $X$ with $U$ an open sub-scheme such that $codim(X\setminus U)\geq 2$, then any reflexive sheaf has a unique extension from $U$ to $X$. My question is when a vector bundle on $U$ extends to a vector bundle on $X$? More precisely I have two types of questions:


1. What type of restrictions, the assumption that $X$ is variety such that every vector bundle on all $U$'s ($codim(X\setminus U)\geq 2$) extends to a vector bundle on $X$, imposes on $X$. (What are all these $X$'s).
2. What type of restrictions, the assumption that $X$ is variety such that every vector bundle on some $U$ ($codim(X\setminus U)\geq 2$) extends to a vector bundle on $X$, imposes on $X$ and $X\setminus U$?



Varieties satisfying the extension of vector bundles property
Here is the criterion:


**Lemma.** *Let $X$ be a regular variety, and let $U \subsetneq X$ be a nonempty open subset such that $\operatorname{codim}(X - U) \geq 2$. Then the following are equivalent:*


1. *Every vector bundle on $U$ extends to a vector bundle on $X$;*
2. *Every reflexive sheaf on $X$ that is locally free on $U$ is locally free;*
3. *$\dim(X) \leq 2$.*


*Proof.* 1 $\Rightarrow$ 2: if $\mathscr F$ is reflexive and $\mathscr F|\_U$ is locally free, then $\mathscr F|\_U$ extends to a vector bundle $\mathscr E$ on $X$. Since extensions of reflexive sheaves are unique [Tag [0EBJ](https://stacks.math.columbia.edu/tag/0EBJ)], we conclude that $\mathscr F = \mathscr E$, i.e. $\mathscr F$ is locally free.


2 $\Rightarrow$ 1: if $\mathscr F$ is locally free on $U$, then its unique reflexive extension $j\_\*\mathscr F$ is locally free by assumption.


3 $\Rightarrow$ 2: see [Tag [0B3N](https://stacks.math.columbia.edu/tag/0B3N)].


2 $\Rightarrow$ 3: pick a closed point $x \in X - U$. Since $X$ is regular, there exists a locally free sheaf $\mathscr E$ and a surjection $\mathscr E \twoheadrightarrow \mathcal I\_x$ [Tag [0F8A](https://stacks.math.columbia.edu/tag/0F8A)]. Its kernel $\mathscr F$ is reflexive [Tag [0EBG](https://stacks.math.columbia.edu/tag/0EBG)], and we get an exact sequence
$$0 \to \mathscr F \to \mathscr E \to \mathcal O\_X \to \mathcal O\_x \to 0.\tag{1}\label{1}$$
Restricting to $U$ gives a short exact sequence
$$0 \to \mathscr F|\_U \to \mathscr E|\_U \to \mathcal O\_U \to 0,$$
showing that $\mathscr F|\_U$ is locally free. By assumption, this implies that $\mathscr F$ is locally free. Then \eqref{1} shows that $\mathscr Ext^i(\mathcal O\_x,\mathscr G) = 0$ for any $i > 2$ and any coherent sheaf $\mathscr G$, so in particular $\operatorname{depth}(\mathcal O\_{X,x}) \leq 2$. Since $X$ is regular, this means $\dim\_x X \leq 2$. Since $X$ is integral and of finite type over a field, it is equidimensional, so $\dim\_x X = \dim X$ since $x$ is closed. $\square$


