If $ X$ is open in a normal projective variety, such a map exists iff $ X$ is quasi-affine, iff $ \mathcal O_X(1) \cong \mathcal O_X$ . I’d like to relax the normality hypothesis.
I can see this holds in a bit more generality. Suppose $ X$ is open in $ \overline X$ . If $ \overline X$ is projective and $ Z = \overline X \setminus X$ has a component $ Z_1$ of codimension 1, then $ \overline X \setminus Z_1$ is affine, so that $ X$ is quasi-affine. So let us instead suppose that $ \overline X$ is affine (resp. projective), and $ Z \subset \overline X$ has codimension $ \geq 2$ . Let $ S$ be the coordinate ring (resp. homogeneous coordinate ring) of $ \overline X$ , and let $ I(Z)$ be the ideal (resp. homogeneous ideal) of $ Z$ in $ S$ , which has height $ \geq 2$ . If $ I(Z)$ has depth $ \geq 2$ , then it’s not hard to show that the restriction map $ \Gamma(\overline X, \mathcal O_{\overline X}(n)) \to \Gamma(X, \mathcal O_X(n))$ is an isomorphism for all $ n \in \mathbb Z$ , from which the above statement follows.
So as sub-questions to the title question, let $ X$ be a quasi-projective variety:
-
Does there exist an open immersion $ X \to \overline X$ , where $ \overline X$ is affine or projective, such that the ideal or homogeneous ideal defining $ Z = \overline X \setminus X$ has depth $ \geq 2$ ?
-
Even if that is not the case, does there exist an open immersion $ X \to \overline X$ where $ \overline X$ is affine or projective, such that the restriction map $ \Gamma(\overline X, \mathcal O_{\overline X}(n)) \to \Gamma(X, \mathcal O_X(n))$ is an isomorphism for all $ n \in \mathbb Z$ ?