Skip to content

cabal v2-install --ignore-project crashes when project file is present #8094

Closed

Description

@andreasabel

Reproducer:

DIR=$(mktemp -d)
cd $DIR
${CABAL:-cabal} init -n --exe --application-dir=app
echo "optimization: False" > cabal.project.local
${CABAL:-cabal} install --ignore-project

This crashes with (current master):

...
Error: cabal: Invalid package ID: .
"<eitherParsec>" (line 1, column 2):
unexpected all digits or a dot in a portion of package name
expecting "-"

Same problem with cabal.project instead of cabal.project.local.

Behavior of previous versions of cabal-install:

cabal-3.0: unrecognized 'install' option `--ignore-project'
cabal-3.2: Invalid package ID: .

From 3.4 it is the same error as today.

What is my interest in cabal v2-install --ignore-project?

I'd like to develop with -O0 (via optimization: False in a project file), but deploy to my system with default optimization (-O1).
Originally, I would have expected that cabal v2-install ignores the project files by default, because it behaves as if it installs from the sdisted tarball, which does (in my case) not contain any cabal.project* files.
But this does not seem to be the case. There is a long discussion of the complex at:

In #7297 (comment) it is suggested to use --ignore-project to this end, but it does not work as expected...

Activity

  1. added
    re: project-file
    re: --ignore-project
    on Apr 9, 2022
  2. changed the title [-]`cabal v2-install --ignore-project` crashes when `cabal.project.local` is present[/-] [+]`cabal v2-install --ignore-project` crashes when project file is present[/+] on Apr 9, 2022
  3. jneira commented on Apr 10, 2022

    @jneira
    Member

    In #7297 (comment) it is suggested to use --ignore-project to this end, but it does not work as expected...

    sorry i did not make it clear in the comment but that was in the context of a hypothetical fix for the bug and that would be a feature to be added to allow opting out the behaviour that fix would set

  4. andreasabel commented on Apr 11, 2022

    @andreasabel
    MemberAuthor

    Maybe then the concrete fix would be to remove --ignore-project from the options of cabal install? Or does it have some use for remote installation?

  5. jneira commented on Apr 11, 2022

    @jneira
    Member

    Related issues:

  6. erinclemmer commented on Apr 12, 2022

    @erinclemmer
    Collaborator

    I was looking into what it would take to fix #7965 and make the --ignore-project flag in the v2-sdist command work as intended but I'm not sure what the intended functionality is and the code seems to contradict itself.

    It looks like there are two ideas competing against each other with the --ignore-project flag. Should the flag:
    A) Ignore the cabal.project file in the current directory and look for a project file in the parent directories.
    B) Ignore project files all together and create the project config from only the defaults and whatever is set from command line flags.

    I assume looking in the parent directories is what it means by "GlobalConfig" in the withProjectOrGlobalConfig function in ProjectConfig.hs but I'm not sure what the intended functionality actually is.

    I wasn't sure whether to add this comment to this issue or #7965 but this seemed more appropriate because it's being talked about and still has to do with the --ignore-project flag and the functionality seems to be the same whatever the given command is that supports it.

  7. gbaz commented on Apr 12, 2022

    @gbaz
    Collaborator

    the globalConfig is not a project file in parent directories -- that's still a "project" config, just one found in another directory. The global config referred to in that function is, as I understand it, the ~/.cabal/config file.

  8. erinclemmer commented on Apr 12, 2022

    @erinclemmer
    Collaborator

    @gbaz ok, the reason I said that is that it looks like if you run cabal sdist --ignore-project on a subdirectory of your project (such as the cabal-install directory of the cabal project) it will load the global config from ~/.cabal but if you do it on the same directory as the cabal.project file it will use that project file. That seems like a bug to me, and I assume the intended functionality is that it --ignore-project would always ignore the local cabal.project file and always use the global one, right?

  9. gbaz commented on Apr 12, 2022

    @gbaz
    Collaborator

    That sounds correct to me.

  10. self-assigned this
    on Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cabal-install: cmd/installre: --ignore-projectre: project-filetype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions