-
Notifications
You must be signed in to change notification settings - Fork 697
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
Fix default Nix configuration option in generated ~/.cabal/config file #8878
Conversation
Thank you! |
Just an observation from a non-maintainer: one thing that would make this patch more valuable than it already is would be to add some documentation to the test, and maybe clarify the comment on the implementation (why do we "need to return PP.empty from viewAsFieldDescr"). |
|
||
defaultConfigFile <- readFile (basedir </> "nix-config/default-config") | ||
True @=? isInfixOf "-- nix:\n" defaultConfigFile | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we generalize this test to ensure that essentially all options are commented out in the default config, not just nix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.e. the repo perhaps and a few other things should not be commented, but it would be much better to have a much more uniform test.
Could we move this forward? The world needs this PR. |
@mergify rebase |
✅ Branch has been successfully rebased |
Let me prod the CI... |
Failed again. Rerunning failed jobs... |
@cbclemmer: it seems, the new test started failing on Windows after updating to new GHC or after some changes of setup of the CI machines. Are you able to guess what's going on with this access denied problem? The path is looking funny, but I'm not sure what I'm looking at. |
@Mikolaj I added a test that will update |
Uhoh. Let's try to debug. Does anybody have any ideas? The error is
Printing both paths aligned:
shows they differ just by the |
@Mikolaj The file should be committed and present at that time, but I've also tried it with the file and it gives the same error. The test that fails writes the file to the folder, so it would override it. Now that I think of it, the nix flag test does the same thing in the test above it so it may not have closed the file handle properly. I've added a commit that will remove the reference to the default config in the nix test, that may help |
I guess that's progress?
|
@cbclemmer: Joking aside. is this test result now explainable? |
@Mikolaj Sorry, I've been super busy lately but recently I have had more time. The issue was that Windows used a different setting for that parameter than Linux. To fix this I first changed the test to compare the strings on the assertion rather than an auxiliary function, which let me see what the matching line said and allowed me to come to the explanation above. Then to fix it I just compared the string before the colon so that the system differences for the values (and the ones that included the user's home directory) would not be tested because that's not the point of this test anyway. Then I went through all of the default config values and ensured that they are all present and tested for whether they are commented or not. The only drawback to my approach is that it does not test whether specific options are under a heading, but it does test whether they are indented or not. Everything should be good to go now. |
Good sleuthing. Would you set the squash+merge_me label? |
@Mikolaj Done |
Thank you again! |
@mergify backport 3.10 |
✅ Backports have been created
|
#8878) * default to commented line for nix config * Fix whitespace * Remove vscode folder * Remove default config file for test * Remove test generated file * Add changelog * Add test for default config values * Remove config file * Remove parsing file * Add config file back for tests * Remove reference to default config to try to get the new test to pass * Rewrite test to be more verbose WIP * Stop testing for values and only test for whether it is commented or not * Fill out rest of tests WIP * Clean up --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 9bf415a)
Fix default Nix configuration option in generated ~/.cabal/config file (backport #8878)
haskell#8878) * default to commented line for nix config * Fix whitespace * Remove vscode folder * Remove default config file for test * Remove test generated file * Add changelog * Add test for default config values * Remove config file * Remove parsing file * Add config file back for tests * Remove reference to default config to try to get the new test to pass * Rewrite test to be more verbose WIP * Stop testing for values and only test for whether it is commented or not * Fill out rest of tests WIP * Clean up --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Please include the following checklist in your PR:
Please also shortly describe how you tested your change. Bonus points for added tests!
Should close #8864
In PR #8522, I did not test the default generated config, and made an incorrect assumption about its contents. This led to the Nix configuration option being uncommented in the ~/.cabal/config file when generated for a user for the first time.
In this PR, I have updated the default value of the Nix configuration option to be empty. This causes the pretty print function, which writes the default config, to comment out the Nix configuration option. This change ensures compatibility, allowing newer Cabal versions to generate configuration files suitable for older Cabal versions.