Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
andreasabel opened this issue Apr 9, 2022 · 7 comments · Fixed by #8498
Closed

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

andreasabel opened this issue Apr 9, 2022 · 7 comments · Fixed by #8498
Assignees
Labels
cabal-install: cmd/install re: --ignore-project Concerning flag `--ignore-project` re: project-file Concerning cabal.project files type: bug

Comments

@andreasabel
Copy link
Member

andreasabel commented Apr 9, 2022

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...

@andreasabel andreasabel added type: bug cabal-install: cmd/install re: project-file Concerning cabal.project files re: --ignore-project Concerning flag `--ignore-project` labels Apr 9, 2022
@andreasabel andreasabel 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 Apr 9, 2022
@jneira
Copy link
Member

jneira commented Apr 10, 2022

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

@andreasabel
Copy link
Member Author

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?

@jneira
Copy link
Member

jneira commented Apr 11, 2022

Related issues:

@cbclemmer
Copy link
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.

@gbaz
Copy link
Collaborator

gbaz commented Apr 12, 2022

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.

@cbclemmer
Copy link
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?

@gbaz
Copy link
Collaborator

gbaz commented Apr 12, 2022

That sounds correct to me.

@gbaz gbaz self-assigned this Sep 27, 2022
@mergify mergify bot closed this as completed in #8498 Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-install: cmd/install re: --ignore-project Concerning flag `--ignore-project` re: project-file Concerning cabal.project files type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants