Repository: conda/conda

Issue:
--use-local flag not working in 4.4.0
For some time I've been doing this:
```
conda build --old-build-string --python 2.7
conda install taxcalc=0.0.0 --use-local --yes
```
But that `conda install` command now fails under conda 4.4.0 and 4.4.1.

I have been able to work around this problem by doing this:
```
conda build --old-build-string --python 2.7
conda install --offline ~/anaconda/conda-bld/osx-64/taxcalc-0.0.0-py27_0.tar.bz2
```
Why does my old code fail under conda 4.4.0 and conda 4.4.1?

The failure is that it says it cannot find the package, but it is where it has always been built:
`~/anaconda/conda-bld/osx-64/taxcalc-0.0.0-py27_0.tar.bz2`




Discussion:
Does this work?

    conda install -c local taxcalc=0.0.0



@kalefranz asked:
> Does this work?
>
> `conda install -c local taxcalc=0.0.0`

Thanks for the suggestion.  I'm going to try it now.

It's still a bug either way.  If that works for you though, it'll at least help narrow down the problem.
After doing `conda build`, I tried the `conda install` command suggested by @kalefranz and that worked although the "solving environment" step took quite a while.  Also, to put this command in a bash script it seems as if you need to quiet the progress "spinner".   Here is what happened in my test:
```
iMac:conda.recipe$ date ; conda install -c local taxcalc=0.0.0 --quiet --yes ; date
Thu Dec 21 22:44:21 EST 2017
Solving environment: ...working... done

## Package Plan ##

  environment location: /Users/mrh/anaconda

  added / updated specs: 
    - taxcalc=0.0.0


The following NEW packages will be INSTALLED:

    taxcalc: 0.0.0-py27_0 local

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Thu Dec 21 22:44:57 EST 2017

iMac:conda.recipe$ conda list taxcalc
# packages in environment at /Users/mrh/anaconda:
#
taxcalc                   0.0.0                    py27_0    local
iMac2:conda.recipe mrh$ 
```
Thanks for the quick advice @kalefranz.
There's still probably some tuning to be done on the solver behavior, making sure it's not slower than 4.3.

What was the behavior you saw that forced use of the `--quiet` flag in your script?  Just curious if there's something that can be done there...
@kalefranz asked:
> What was the behavior you saw that forced use of the --quiet flag in your script? Just curious if there's something that can be done there...

Oh, now that I think about it maybe I just forgot the `--yes` option.
I'll test again without the `--quiet` option.


Resolving patch:
diff --git a/conda/base/context.py b/conda/base/context.py
--- a/conda/base/context.py
+++ b/conda/base/context.py
@@ -160,6 +160,7 @@ class Context(Configuration):
     migrated_custom_channels = MapParameter(string_types)  # TODO: also take a list of strings
     override_channels_enabled = PrimitiveParameter(True)
     show_channel_urls = PrimitiveParameter(None, element_type=(bool, NoneType))
+    use_local = PrimitiveParameter(False)
     whitelist_channels = SequenceParameter(string_types)
 
     always_softlink = PrimitiveParameter(False, aliases=('softlink',))
@@ -532,6 +533,7 @@ def custom_channels(self):
 
     @property
     def channels(self):
+        local_add = ('local',) if self.use_local else ()
         if (self._argparse_args and 'override_channels' in self._argparse_args
                 and self._argparse_args['override_channels']):
             if not self.override_channels_enabled:
@@ -546,15 +548,16 @@ def channels(self):
                 At least one -c / --channel flag must be supplied when using --override-channels.
                 """))
             else:
-                return self._argparse_args['channel']
+                return tuple(IndexedSet(concatv(local_add, self._argparse_args['channel'])))
 
         # add 'defaults' channel when necessary if --channel is given via the command line
         if self._argparse_args and 'channel' in self._argparse_args:
             # TODO: it's args.channel right now, not channels
             argparse_channels = tuple(self._argparse_args['channel'] or ())
             if argparse_channels and argparse_channels == self._channels:
-                return argparse_channels + (DEFAULTS_CHANNEL_NAME,)
-        return self._channels or ()
+                return tuple(IndexedSet(concatv(local_add, argparse_channels,
+                                                (DEFAULTS_CHANNEL_NAME,))))
+        return tuple(IndexedSet(concatv(local_add, self._channels)))
 
     def get_descriptions(self):
         return get_help_dict()
@@ -582,6 +585,7 @@ def list_parameters(self):
 # I don't think this documentation is correct any longer. # NOQA
             'target_prefix_override',  # used to override prefix rewriting, for e.g. building docker containers or RPMs  # NOQA
             'update_dependencies',
+            'use_local',
         )
         return tuple(p for p in super(Context, self).list_parameters()
                      if p not in UNLISTED_PARAMETERS)
diff --git a/conda/cli/conda_argparse.py b/conda/cli/conda_argparse.py
--- a/conda/cli/conda_argparse.py
+++ b/conda/cli/conda_argparse.py
@@ -1083,7 +1083,7 @@ def add_parser_use_local(p):
     p.add_argument(
         "--use-local",
         action="store_true",
-        default=False,
+        default=NULL,
         help="Use locally built packages.",
     )
 


Test patch: