Cabal install sandbox can't reinstall base or any other dependencies
<h1>EDIT FOR FUTURE SOULS STUMBLING ONTO THIS:</h1>

<p>It would be unwise to copy any of my commands below, do not execute them.  Just check out Zeta's answer for why I was approaching this incorrectly.</p>

<h1>ORIGINAL QUESTION</h1>

<p>My sandbox seems to be getting caught on a global version of some packages rather than using the sandbox versions.  I've looked around on SO for answers to this, and many of the questions are answered without specific instructions to resolve this, or were slightly different, so I can't seem to get my setup running.  Here's what I have:</p>

<pre><code>1. Version of cabal is old:

$ cabal --v
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library 
</code></pre>

<p>Oh dear, this is old and won't run sandbox.</p>

<pre><code>2. Install cabal with cabal
$ cabal install cabal
Resolving dependencies...
Downloading Cabal-1.22.6.0...

...lots of stuf...

Registering Cabal-1.22.6.0...
Installed Cabal-1.22.6.0
</code></pre>

<p>Looks good.</p>

<pre><code>3. Try it out:
$ cabal sandbox init
cabal: unrecognised command: sandbox (try --help)
</code></pre>

<p>Hmm.</p>

<pre><code>$ which cabal
/usr/bin/cabal
</code></pre>

<p>Ahh.</p>

<pre><code>$ ${HOME}/.cabal/bin/cabal --version
cabal-install version 1.22.2.0
using version 1.22.2.0 of the Cabal library 
</code></pre>

<p>Aha.</p>

<pre><code>$ export PATH="${HOME}/.cabal/bin/:$PATH"
$ export PATH="${HOME}/.cabal/libs/:$PATH"

$ cabal --v
cabal-install version 1.22.2.0
</code></pre>

<p>Great.</p>

<pre><code>4. Try it out again:
$ cabal sandbox init
Writing a default package environment file to
.../cabal.sandbox.config
Creating a new sandbox at .../.cabal-sandbox

$ cabal install Frames
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: Frames-0.1.2.1 (user goal)
next goal: base (dependency of Frames-0.1.2.1)
rejecting: base-4.6.0.1/installed-8aa... (conflict: Frames =&gt; base&gt;=4.7 &amp;&amp;
&lt;4.9)
rejecting: base-4.8.2.0, 4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0, 4.6.0.1,
4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2,
4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0, 3.0.3.2, 3.0.3.1 (global constraint
requires installed instance)
Dependency tree exhaustively searched.

Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
</code></pre>

<p>Huh, so base is not compatible, OK.</p>

<pre><code>$ cabal install base --reinstall
Resolving dependencies...
cabal: Could not resolve dependencies:
next goal: base (user goal)
rejecting: base-4.8.2.0, 4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0, 4.6.0.1,
4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0, 4.3.0.0, 4.2.0.2,
4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0 (only already installed instances can be
used)
rejecting: base-3.0.3.2 (conflict: base =&gt; base&gt;=4.0 &amp;&amp; &lt;4.3)
rejecting: base-3.0.3.1 (conflict: base =&gt; base&gt;=4.0 &amp;&amp; &lt;4.2)
Dependency tree exhaustively searched.

Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
</code></pre>

<p>Huh, what about all dependencies?</p>

<pre><code>$ cabal install --upgrade-dependencies
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: Frames-0.1.2.1 (user goal)
next goal: base (dependency of Frames-0.1.2.1)
rejecting: base-4.8.2.0, 4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0 (global
constraint requires installed instance)
rejecting: base-4.6.0.1/installed-8aa... (conflict: Frames =&gt; base&gt;=4.7 &amp;&amp;
&lt;4.9)
rejecting: base-4.6.0.1, 4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0,
4.3.0.0, 4.2.0.2, 4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0, 3.0.3.2, 3.0.3.1 (global
constraint requires installed instance)
Dependency tree exhaustively searched.

Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
</code></pre>

<p>Seems I cannot reinstall/unregister the offending packages.  I wish the error message would give me a little more on how to do this, because the "--reinstall" flag was my best shot.</p>

<p>Well, it offered 2 solutions, so let's try the other, to recreate the sandbox.</p>

<pre><code>$ cabal sandbox delete
Deleting the sandbox located at .../.cabal-sandbox

$ cabal sandbox init
Writing a default package environment file to
.../cabal.sandbox.config
Creating a new sandbox at .../.cabal-sandbox

$ cabal install --upgrade-dependencies
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: Frames-0.1.2.1 (user goal)
next goal: base (dependency of Frames-0.1.2.1)
rejecting: base-4.8.2.0, 4.8.1.0, 4.8.0.0, 4.7.0.2, 4.7.0.1, 4.7.0.0 (global
constraint requires installed instance)
rejecting: base-4.6.0.1/installed-8aa... (conflict: Frames =&gt; base&gt;=4.7 &amp;&amp;
&lt;4.9)
rejecting: base-4.6.0.1, 4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0,
4.3.0.0, 4.2.0.2, 4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0, 3.0.3.2, 3.0.3.1 (global
constraint requires installed instance)
Dependency tree exhaustively searched.

Note: when using a sandbox, all packages are required to have consistent
dependencies. Try reinstalling/unregistering the offending packages or
recreating the sandbox.
</code></pre>

<p>This also did not help.  Fresh out of ideas.  How do I use sandbox?  My read here is there is a global something that is causing a problem.  A sandbox should not be bothered by that by design of sandboxing, right?</p>

<p>If it helps context, I'm just trying to run the demo for Frames:</p>

<p><a href="https://github.com/acowley/Frames" rel="noreferrer">https://github.com/acowley/Frames</a></p>

<p>...which is:</p>

<pre><code>$ cabal sandbox init
$ cabal install --dependencies-only -f demos # &lt;-- here
</code></pre>

<p>I see there's a <a href="https://github.com/acowley/Frames/issues/23" rel="noreferrer">closed issue</a> on this step, but that seems like a different issue.</p>