You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
'--sandbox-config-file' changes where install looks for 'cabal.config' #1915
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
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
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:
Change D.C.Sandbox.loadConfigOrSandboxConfig to always use the cabal.config file in the current directory (if any).
Change cabal.freeze to write to the cabal.config file in the --sandbox-config-file directory.
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.
Activity
23Skidoo commentedon Jun 2, 2014
Yes, using the one in the current directory makes more sense.
[-]--sandbox-config-file changes where install looks for cabal.config[/-][+]'--sandbox-config-file' changes where install looks for 'cabal.config'[/+]benarmston commentedon Dec 10, 2014
I'm commenting here instead of on #1629 as that is closed. The
cabal freezecommand loads thecabal.configfile twice. Once inMain.hsviaD.C.Sandbox.loadConfigOrSandboxConfig, in order to load the saved configure flags.D.C.Sandbox.loadConfigOrSandboxConfiglooks for thecabal.configfile in either the current directory or the directory specified by--sandbox-config-fileif it is given.The second time that
cabal.freezeloadscabal.configis when it writes out the constraints. It loads thecabal.configfile 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.configfile in the--sandbox-config-filedirectory. However that was reverted.I believe that every other command making use of
cabal.configloads it throughD.C.Sandbox.loadConfigOrSandboxConfigand so they all use thecabal.configin the--sandbox-config-filedirectory.Obviously, we want all uses of how to load
cabal.configto be consistent, so we can either:D.C.Sandbox.loadConfigOrSandboxConfigto always use thecabal.configfile in the current directory (if any).cabal.freezeto write to thecabal.configfile in the--sandbox-config-filedirectory.What is the desired behaviour here?
mietek commentedon Dec 10, 2014
We appear to be in agreement that the current behaviour of
cabal --sandbox-config-fileis surprising in general, and not just in the context ofcabal freeze. Therefore, I suppose I am in favour of option 1.benarmston commentedon Dec 11, 2014
@23Skidoo, @tibbe is changing existing behaviour in this way OK with you both?
23Skidoo commentedon Dec 11, 2014
Yes, I think that
--sandbox-config-fileshouldn't affect the location ofcabal.config.mietek commentedon Jan 24, 2015
Halcyon includes a workaround for this issue.
mietek commentedon Jun 7, 2019
Closing as obsolete.