Skip to content

'--sandbox-config-file' changes where install looks for 'cabal.config' #1915

Closed

Description

@mietek

Specifying the --sandbox-config-file option with a cabal install changes where cabal looks for cabal.config.

When using this option, cabal no longer looks for cabal.config in the current working directory, but instead looks in the directory of the specified sandbox config file.

To reproduce, start with ghc-7.8.2 and cabal-install-1.20.0.2. First, the expected behaviour:

~ $ mkdir /tmp/yakshavers-inc

~ $ cd /tmp/yakshavers-inc

yakshavers-inc $ cat >cabal.config <<EOF
constraints: utf8-string ==0.3.7
EOF

yakshavers-inc $ cat >yakshavers-inc.cabal <<EOF
name:           yakshavers-inc
version:        0.0
build-type:     Simple
cabal-version:  >=1.2

executable yakshavers-inc
  build-depends:  base, utf8-string
EOF

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

yakshavers-inc $ cabal install --dry-run
Resolving dependencies...
In order, the following would be installed (use -v for more details):
utf8-string-0.3.7 (latest: 0.3.8)
yakshavers-inc-0.0

Now, the unexpected behaviour:

yakshavers-inc $ mkdir zoo

yakshavers-inc $ cd zoo

zoo $ cabal sandbox init
Writing a default package environment file to
/private/tmp/yakshavers-inc/zoo/cabal.sandbox.config
Creating a new sandbox at /private/tmp/yakshavers-inc/zoo/.cabal-sandbox

zoo $ cd ..

yakshavers-inc $ cabal --sandbox-config-file=zoo/cabal.sandbox.config install --dry-run
Resolving dependencies...
In order, the following would be installed (use -v for more details):
utf8-string-0.3.8
yakshavers-inc-0.0

Finally, to confirm:

yakshavers-inc $ cp cabal.config zoo

yakshavers-inc $ cabal --sandbox-config-file=zoo/cabal.sandbox.config install --dry-run
Resolving dependencies...
In order, the following would be installed (use -v for more details):
utf8-string-0.3.7 (latest: 0.3.8)
yakshavers-inc-0.0

Activity

  1. 23Skidoo commented on Jun 2, 2014

    @23Skidoo
    Member

    Yes, using the one in the current directory makes more sense.

  2. changed the title [-]--sandbox-config-file changes where install looks for cabal.config[/-] [+]'--sandbox-config-file' changes where install looks for 'cabal.config'[/+] on Jun 26, 2014
  3. benarmston commented on Dec 10, 2014

    @benarmston
    Contributor

    I'm commenting here instead of on #1629 as that is closed. The cabal freeze command loads the cabal.config file twice. Once in Main.hs via D.C.Sandbox.loadConfigOrSandboxConfig, in order to load the saved configure flags. D.C.Sandbox.loadConfigOrSandboxConfig looks for the cabal.config file in either the current directory or the directory specified by --sandbox-config-file if it is given.

    The second time that cabal.freeze loads cabal.config is when it writes out the constraints. It loads the cabal.config file in the current directory replaces any constraints with those calculated and writes the result back to the current directory.

    Obviously, the difference in behaviour between the two uses is not correct. However, I'm not sure what the correct (desired) behaviour is. I did write a commit which removed the inconsistency by updating the cabal.config file in the --sandbox-config-file directory. However that was reverted.

    I believe that every other command making use of cabal.config loads it through D.C.Sandbox.loadConfigOrSandboxConfig and so they all use the cabal.config in the --sandbox-config-file directory.

    Obviously, we want all uses of how to load cabal.config to be consistent, so we can either:

    1. Change D.C.Sandbox.loadConfigOrSandboxConfig to always use the cabal.config file in the current directory (if any).
    2. Change cabal.freeze to write to the cabal.config file in the --sandbox-config-file directory.

    What is the desired behaviour here?

  4. mietek commented on Dec 10, 2014

    @mietek
    ContributorAuthor

    We appear to be in agreement that the current behaviour of cabal --sandbox-config-file is surprising in general, and not just in the context of cabal freeze. Therefore, I suppose I am in favour of option 1.

  5. benarmston commented on Dec 11, 2014

    @benarmston
    Contributor

    @23Skidoo, @tibbe is changing existing behaviour in this way OK with you both?

  6. 23Skidoo commented on Dec 11, 2014

    @23Skidoo
    Member

    Yes, I think that --sandbox-config-file shouldn't affect the location of cabal.config.

  7. mietek commented on Jan 24, 2015

    @mietek
    ContributorAuthor

    Halcyon includes a workaround for this issue.

  8. added this to the milestone on Apr 24, 2015
  9. modified the milestones: cabal-install 1.24, on Feb 21, 2016
  10. modified the milestone: cabal-install 2.0 on Sep 6, 2016
  11. mietek commented on Jun 7, 2019

    @mietek
    ContributorAuthor

    Closing as obsolete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions