Canonical bundle of compactifications Let $X$ be a quasi-projective variety.  Suppose that we (perhaps partially, if either enough is known) compactify to $\bar{X}$ with $\bar{X}\setminus X=D$ is a divisor.  Say that we know the canonical bundle $K_X$.  Then $K_{\bar{X}}=K_X+nD$ for some $n$.


*

*Is $n$ always negative? The examples I'm thinking of are for $X=\mathcal{M}_g,\mathcal{A}_g$

*Is there a good method for computing this $n$?


In both cases, I'm particularly interested in finite covers of $\mathcal{M}_g,\mathcal{A}_g$ and other moduli spaces, if that helps to know how the variety is given.
 A: perhaps I am misunderstanding what you ask, but the answer is no to both questions. Take an arbitrary projective variety $\overline X$, actually for simplicity let $\overline X$ be normal. Then it has a canonical divisor, say $K_{\overline X}$ and choose an actual representative, $K=\sum_i a_i K_i$ where the $a_i$ may be negative or positive. Now let $X=\overline X\setminus ({\rm Supp}\, K)$. Then $K_X$ is trivial and there is no way you can tell the $a_i$ just from knowing $K_X$. Of course, if you know something else, that's a whole different question.
In any case, this at least shows that your $n$ is not always negative. If you know things like $X$ is covered by rational curves (or does not contain any) that could help, but as the above example shows, you need more information.
Some vaguely related thoughts on the canonical divisor are available at this answer to another MO question.
A: To supplement Sandor's answer, let me note that any curve of positive genus is a counterexample to this claim.  
For example, remove any number of points from an elliptic curve, and you will get an example where n=0.  
If $g>1$, then the canonical divisor has positive degree, and so when written as a sum of points must have some positive coefficients.  Removing one of those points gives a counter-example where $n>0$.
A: Why should $K_{\bar{X}}=K_X+nD$? Consider the following counterexample.
Let $E$ be an elliptic curve and let $\bar{X}=E\times \mathbb{P}^1$. Then $K_{\bar{X}}=-2E\times 0$. Let $X$ be the open subset $\bar{X}\setminus (e\times \mathbb{P}^1\cup E\times 0)$. Then $K_X$ is trivial as we have deleted $E\times 0$. So if $K_{\bar{X}}=K_X+n(e\times \mathbb{P}^1\cup E\times 0)$, then we would have that $(-n-2)(E\times 0)$ is rationally equivalent to $n(e\times \mathbb{P}^1)$, which is not correct as the picard group of $E\times \mathbb{P}^1$ is isomorphic to $Pic(E)\oplus\mathbb{Z}\cdot p_2^*\mathscr{O}(1)$.
