codex fails while parsing unrelated cabal file in parent directory
problem scenario
I tried using codex for https://github.com/tweag/ormolu/ and for some reason it tries to parse a completely unrelated project from a different directory:
$ codex update
codex: dieVerbatim: user error (codex: Failed parsing "../higgledy/higgledy.cabal".
details
- NixOS
- ghc 8.4.4
- codex version 0.5.2.0 (built from 48b2a4b94132b537943bcd966c3922cbf67a7409)
By default codex treats the parent directory as a workspace. This can only be disabled by setting the environmental variable CODEX_DISABLE_WORKSPACE to any value.
By default codex treats the parent directory as a workspace. This can only be disabled by setting the environmental variable CODEX_DISABLE_WORKSPACE to any value.
I am really struggling to understand this
`-- parent/
`-- bar/
`-- baz/
If I am in bar and that contains a valid .cabal file and I run codex update why would it parse a cabal file that it finds in baz? That makes no sense to me.
If codex update is run in either bar or baz and neither contained a cabal file it would make sense that it checks parent for a cabal file. But anything else seems very unexpected and I don't understand how this could be the default case.
Am I missing something?
FWIW, running codex with CODEX_DISABLE_WORKSPACE fixes the issue I described above. I still don't understand the motivation behind the behavior at all though.
@cydparser I guess you introduced this behavior in https://github.com/aloiscochard/codex/pull/76 - would be great if this could be documented in the README.
So if I have a cabal project with stack.yaml or cabal.project I must call codex with CODEX_DISABLE_WORKSPACE if I want codex to only create tags for my cabal project in the current directory?
I also find the default behavior confusing (which is why I added CODEX_DISABLE_WORKSPACE). I think that implicit workspaces should either be disabled entirely (now that we have cabal.project and stack.yaml files) or disabled by default.
@parsonsmatt What is your take on this? What do you think the behavior of codex update should be ideally?
If codex update is run in either bar or baz and neither contained a cabal file it would make sense that it checks parent for a cabal file. But anything else seems very unexpected and I don't understand how this could be the default case.
This seems reasonable. Especially now that cabal supports cabal.project files.
Yes the feature was introduced before those concepts existed (cabal.project or stack at all for that matter).
I think we should entirely remove the workspace mechanism, it does complexity the code base with no actual use as of today.
I'll try to do some cleaning and remove that part.