A Non-quasi-affine scheme with quasi-affine irreducible components

Let $X$ be a scheme finite type over a field $k$ such that each of its irreducible components $X_i$ is quasi-affine. Is it true that $X$ is quasi-affine?

• No, that is not true. Let $X_1$ and $X_2$ be isomorphic to the deleted affine plane $\mathbb{A}^2\setminus\{(0,0)\}$. For $i=1,2,$ let $L_i$ be a deleted affine line through the origin in $X_i$. Thus, both $L_1$ and $L_2$ are isomorphic to $\text{Spec}\ k[t,t^{-1}]$. Let $f:L_1\xrightarrow{\cong} L_2$ be an isomorphism that maps the origin to $\infty$. Glue $X_1$ and $X_2$ according to this isomorphism. Then every global section of the structure sheaf of $X$ restricts on $L_1=L_2$ as a constant. – Jason Starr May 1 '18 at 13:32

I am just writing my comment as an answer. Probably this example has appeared before on MO. Let $\mathbb{P}^3_k$ denote the projective space $\text{Proj}\ k[s_1,s_2,t_1,t_2]$. Let $\overline{X}$ denote the closed, reduced subscheme $$\overline{X} =\text{Zero}(s_1s_2) = \overline{X}_1 \cup \overline{X}_2, \ \ \overline{X}_1 = \text{Zero}(s_2), \ \ \overline{X}_2 = \text{Zero}(s_1).$$ This is a union of two hyperplanes, $\overline{X}_1$ and $\overline{X}_2,$ whose intersection is a line, $$\overline{L} = \overline{X}_1\cap \overline{X}_2 = \text{Zero}(s_1,s_2) = \text{Proj} \ k[t_1,t_2].$$ Inside $\overline{X}_1$, define $C_1$ to be the closed subscheme that is a line, $$C_1 = \text{Zero}(s_2,t_1).$$ Inside $\overline{X}_2$, define $C_2$ to be the closed subscheme that is a line, $$C_2=\text{Zero}(s_1,t_2).$$ Note that $C_1\cap \overline{X}_2$ is the singleton set of $p_2=[0,0,0,1]$, and $C_2\cap \overline{X}_1$ is the singleton set of $p_1=[0,0,1,0].$ Define $C$ to be the closed union of $C_1$ and $C_2$ in $\overline{X}$.
Define $X$ to be the open complement in $\overline{X}$ of the closed subset $C$. By construction, $X$ is quasi-projective. Moreover, $X$ is the union of the two irreducible components, $$X_1 = \overline{X}_1\setminus(C_1\cup \{p_1\}), \ \ X_2 = \overline{X}_2 \setminus (C_2\cup \{p_2\}).$$
The intersection of the two irreducible components is $$L=\overline{L}\setminus\{p_1,p_2\}.$$
Each of the two irreducible components is isomorphic to a punctured affine plane. In particular, $\mathcal{O}_{X_1}(X_1)$ equals $k[s_1/t_1,t_2/t_1]$. Similarly, $\mathcal{O}_{X_2}(X_2)$ equals $k[s_2/t_2,t_1/t_2]$. Finally, the intersection $L$ is a twice-punctured projective line with coordinate ring $\mathcal{O}_L(L)$ equal to $k[t_2/t_1,t_1/t_2]$. The restriction map $\rho_1$, resp. $\rho_2$, to $\mathcal{O}_L(L)$ from $\mathcal{O}_{X_1}(X_1)$, resp. from $\mathcal{O}_{X_2}(X_2)$, is the $k$-algebra map that sends $s_1/t_1$ to $0$, resp. that sends $s_2/t_2$ to $0$, and that sends $t_2/t_1$ to itself, resp. that sends $t_1/t_2$ to itself. The fibre product of these restriction maps is the $k$-algebra $$\mathcal{O}_X(X) = \{(f_1,f_2)\in \mathcal{O}_{X_1}(X_1)\times \mathcal{O}_{X_2}(X_2) : \rho_1(f_1) = \rho_2(f_2)\}.$$ This is infinitely generated as a $k$-algebra by the following monomials, $$\frac{s_1}{t_1}, \ \frac{s_2}{t_2}, \ \left(\frac{s_1^mt_2}{t_1^{m+1}}\right)_{m\geq 1}, \left(\frac{s_2^nt_1}{t_2^{n+1}}\right)_{n\geq 1}.$$ In particular, the image in $\mathcal{O}_L(L)$ of $\mathcal{O}_X(X)$ equals the constant subfield $k$. Thus, $X$ is not quasi-affine.
• I discussed this example years ago with Ravi Vakil. I very much believe this example has appeared before on MathOverflow (maybe as an example of a quasi-projective $k$-scheme whose global sections $k$-algebra is not finitely generated). – Jason Starr May 1 '18 at 16:02