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
From what you say, it can be useful if cabal sdist takes --ignore-project into account? Because if not, it's cheaper to just remove the mention of the option (and broken code handling it, if any).
To give a bit of context, I am writing a script to make sdists from a bunch of github repos. Given the repos might have their own cabal.project, cabal ends up pulling all the source-repository-packages. I find this undesiderable.
Does cabal actually need the source-repository-packages to make an sdist? I guess in case if a custom setup relies on those specific versions?
You can always override those project files with a flag that sets the project file to a default one.
I think that we can't actually make --ignore-project work as designed for this command. It gets ignored on initial read of the project. But then to get the packages to sdist, we have to call establishProjectBaseContextWithRoot which in turn must call rebuildProjectConfig which needs a project file!
So 90% of commands can't take this flag as is, and have it stripped. I think there are very few use cases for this flag, and they can all be resolved by passing in another project file explicitly. If that workaround suffices, I vote we deprecate and then remove it.
(There is of course a way to make it work, but it would require substantial rearchitecting, and I question its utility).
It includes "configure, build, exec, outdated". That's a pretty big list already, and I bet it works poorly and is possibly broken elsewhere that supports it, which is only "update, install, list-bin, run, repl" (and sdist, which we already know is broken).
Hrm. there is also a feature request for using ignore-project more widely: #7057
The argument there (which is good) is that this can bypass the behavior of searching ever upwards for a project file. So that makes a case that we should actually push through the more irritating change uniformly and make --ignore-project actually work for everything. 🤔
@gbaz I don't think passing --project-file works either. I tried cabal sdist --project-file=/dev/null and touch cabal.project.null && cabal sdist --project-file=cabal.project.null and the top level project still gets read.
I think this may come down to the readProjectConfig function in ProjectConfig.hs. It looks like no matter if the --ignore-project flag is set or not, the rebuildProjectConfig function in run ProjectPlanning.hs is run with only the DistDirLayout object different based on the projectRoot parameter to the establishProjectBaseContextWithRoot function (this is based on the current dirctory if the flag is true and the current or parent directories if the flag is false). It looks like the readProjectConfig function always reads the local cabal.project file no matter how the flag is set and the project settings are merged with the defaults to have the effect of using the settings in the local cabal.project no matter what. What I can't figure out at the moment is whether readProjectConfig reads the cabal.project file and the foo.cabal file or just the cabal.project file.
I say this because I added a branching path based on whether the flag was set in the readProjectConfig function and the program acted like it couldn't find the foo.cabal file for some reason. I'll dig around more tomorrow but that's what I found today. New code: Before code change: After code change:
@Colton-Clemmer good investigation, I guess that's because the cabal packages to build are defined in the local cabal project file (in packages:). That must be why the function is actually called readProjectLocalConfigOrDefault. I think we need to replace local with a default one.
Activity
Mikolaj commentedon Feb 10, 2022
From what you say, it can be useful if
cabal sdisttakes--ignore-projectinto account? Because if not, it's cheaper to just remove the mention of the option (and broken code handling it, if any).phadej commentedon Feb 10, 2022
It is occasionally useful. It seems to be broken though. I can reproduce.
https://github.com/haskell/cabal/blob/master/cabal-install/src/Distribution/Client/CmdSdist.hs#L141-L214
The
withoutProjectdoes something it shouldn't do.Mikolaj commentedon Feb 10, 2022
Thanks. PR welcome.
andreabedini commentedon Feb 10, 2022
To give a bit of context, I am writing a script to make sdists from a bunch of github repos. Given the repos might have their own
cabal.project, cabal ends up pulling all the source-repository-packages. I find this undesiderable.Does cabal actually need the source-repository-packages to make an sdist? I guess in case if a custom setup relies on those specific versions?
gbaz commentedon Feb 10, 2022
You can always override those project files with a flag that sets the project file to a default one.
I think that we can't actually make --ignore-project work as designed for this command. It gets ignored on initial read of the project. But then to get the packages to sdist, we have to call
establishProjectBaseContextWithRootwhich in turn must callrebuildProjectConfigwhich needs a project file!So 90% of commands can't take this flag as is, and have it stripped. I think there are very few use cases for this flag, and they can all be resolved by passing in another project file explicitly. If that workaround suffices, I vote we deprecate and then remove it.
(There is of course a way to make it work, but it would require substantial rearchitecting, and I question its utility).
gbaz commentedon Feb 10, 2022
Here is the commands that cannot use the ignore project option already: https://github.com/haskell/cabal/search?q=removeIgnoreProjectOption
It includes "configure, build, exec, outdated". That's a pretty big list already, and I bet it works poorly and is possibly broken elsewhere that supports it, which is only "update, install, list-bin, run, repl" (and sdist, which we already know is broken).
andreabedini commentedon Feb 11, 2022
Thanks for the analysis and the suggested workaround @gbaz
gbaz commentedon Feb 11, 2022
Hrm. there is also a feature request for using ignore-project more widely: #7057
The argument there (which is good) is that this can bypass the behavior of searching ever upwards for a project file. So that makes a case that we should actually push through the more irritating change uniformly and make --ignore-project actually work for everything. 🤔
andreabedini commentedon Feb 14, 2022
@gbaz I don't think passing
--project-fileworks either. I triedcabal sdist --project-file=/dev/nullandtouch cabal.project.null && cabal sdist --project-file=cabal.project.nulland the top level project still gets read.A quick
straceconfirms.gbaz commentedon Apr 12, 2022
In that case the issue I guess is that not all commands can take a --project-file flag properly, and I think we definitely should fix that.
erinclemmer commentedon Apr 13, 2022
I think this may come down to the



readProjectConfigfunction inProjectConfig.hs. It looks like no matter if the--ignore-projectflag is set or not, therebuildProjectConfigfunction in runProjectPlanning.hsis run with only theDistDirLayoutobject different based on theprojectRootparameter to theestablishProjectBaseContextWithRootfunction (this is based on the current dirctory if the flag is true and the current or parent directories if the flag is false). It looks like thereadProjectConfigfunction always reads the localcabal.projectfile no matter how the flag is set and the project settings are merged with the defaults to have the effect of using the settings in the localcabal.projectno matter what. What I can't figure out at the moment is whetherreadProjectConfigreads thecabal.projectfile and thefoo.cabalfile or just thecabal.projectfile.I say this because I added a branching path based on whether the flag was set in the
readProjectConfigfunction and the program acted like it couldn't find thefoo.cabalfile for some reason. I'll dig around more tomorrow but that's what I found today.New code:
Before code change:
After code change:
andreabedini commentedon Apr 13, 2022
@Colton-Clemmer good investigation, I guess that's because the cabal packages to build are defined in the local cabal project file (in
packages:). That must be why the function is actually calledreadProjectLocalConfigOrDefault. I think we need to replacelocalwith a default one.erinclemmer commentedon Apr 23, 2022
I put up a pr for this issue that should hopefully resolve this problem #8109
Merge branch 'master' into cc/haskell#7965-pr
Merge branch 'master' into cc/haskell#7965-pr
Merge pull request #8109 from Colton-Clemmer/cc/#7965-pr
andreasabel commentedon Aug 21, 2022
With a PR merged, can this issue be closed?
phadej commentedon Aug 21, 2022
Except now
v2-sdistis broken as this change made it always requireghc, even with--ignore-project.andreasabel commentedon Aug 21, 2022
Is this taken care of by the following PR?
jneira commentedon Aug 21, 2022
... and #8325 as issue. I suppose is good to link them here, thanks!