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
{{ message }}
Repository navigation
cabal v2-test fails when opening shared object file #8580
I'm trying to add Cabal to my CI matrix, but running cabal exec -- cabal v2-test fails in CI with
libHS-tasty-autocollect-0.3.1.0-inplace-ghc9.4.2.so: cannot open shared object file: No such file or directory
The mentioned file is the same library I'm building; the tricky thing about this library is that the library defines a compiler plugin, and the test suite uses the plugin itself.
It works with Stack in CI and locally, and cabal exec -- cabal v2-test works locally.
The confusing thing here is that you say it works locally. So the question is -- what is the CI script doing that the local build is not? My hunch is that it must be doing something different, and I suspect it may be some sort of cleaning between the actions? Would a workaround be to actually install the plugin (or at least v2-install it) and then make use of the installed plugin, or is that not possible due to the way cabal sets things up?
Alternately -- create a cabal project, and have one the test package depend on the main one?
"Why would Stack build the test suite fine, but Cabal not?"
But cabal does build the test suite fine, you observed! It just doesn't build it in the particular CI setup on ubuntu! That's the question you need to ask. Since I only have a mac, I can't replicate this in a way that's meaningful, and I also suspect that it'll work fine from the command line on ubuntu as well, since cabal behaves almost the same on both systems -- its going to have to be something specific to CI, and I honestly can't tell you what. Perhaps its the interaction with the freeze or cache stuff?
Interestingly, changing the cabal exec -- cabal v2-test to cabal test allows it to run without issues. Here's the run, and here is the yaml file. Some of the tests fail though, presumably the ones that needed cabal exec in the first place.
Your failing test logs mentions this at one point:
Loaded package environment from /home/runner/work/tasty-autocollect/tasty-autocollect/dist-newstyle/tmp/environment.-3614/.ghc.environment.x86_64-linux-9.4.2
Maybe that's right, but my experience is to be wary of .ghc.environment.* files. Unfortunately, --write-ghc-environment-files does not seem to have any effect.
i.e. build the test outside of the cabal exec environment, then run the tests inside it.
This still seems like a Cabal bug; conceptually, I would think that cabal exec -- v2-build --enable-tests should always work (i.e. cabal exec shouldn't affect the build). It seems like there might be some edge case around Ubuntu + writing a compiler plugin + cabal exec. But I recognize this is probably a very rare edge case, so feel free to close until another incident comes up. At the very least, this is now documented
Activity
gbaz commentedon Nov 9, 2022
The confusing thing here is that you say it works locally. So the question is -- what is the CI script doing that the local build is not? My hunch is that it must be doing something different, and I suspect it may be some sort of cleaning between the actions? Would a workaround be to actually install the plugin (or at least v2-install it) and then make use of the installed plugin, or is that not possible due to the way cabal sets things up?
Alternately -- create a cabal project, and have one the test package depend on the main one?
brandonchinn178 commentedon Nov 9, 2022
I mean the obvious difference is I'm on Mac and CI is on Ubuntu. But there's no cleaning, the CI action is literally
I would prefer to avoid adding extra layers of indirection, since it works as-is with Stack. Why would Stack build the test suite fine, but Cabal not?
gbaz commentedon Nov 9, 2022
"Why would Stack build the test suite fine, but Cabal not?"
But cabal does build the test suite fine, you observed! It just doesn't build it in the particular CI setup on ubuntu! That's the question you need to ask. Since I only have a mac, I can't replicate this in a way that's meaningful, and I also suspect that it'll work fine from the command line on ubuntu as well, since cabal behaves almost the same on both systems -- its going to have to be something specific to CI, and I honestly can't tell you what. Perhaps its the interaction with the freeze or cache stuff?
brandonchinn178 commentedon Nov 9, 2022
Ok this is interesting. I changed CI to run just
and now it's failing on: (link)
I can also reproduce with this Dockerfile:
Docker repro
Since I can repro locally via Docker, it seems like it's not specific to my CI setup.
If I comment out the last
cabal v2-testline and start a shell in the Docker container withdocker run, I can debug a bit further.Debug info
So GHC is loading the correct
package.conf.d, which points to the directory containing the.sofile??tbidne commentedon Nov 10, 2022
Interestingly, changing the
cabal exec -- cabal v2-testtocabal testallows it to run without issues. Here's the run, and here is the yaml file. Some of the tests fail though, presumably the ones that neededcabal execin the first place.Your failing test logs mentions this at one point:
Maybe that's right, but my experience is to be wary of
.ghc.environment.*files. Unfortunately,--write-ghc-environment-filesdoes not seem to have any effect.brandonchinn178 commentedon Nov 12, 2022
Ah yes, I did know that, but that did give me one final idea that got it working! I was able to do
cabal configure --enable-tests cabal v2-build cabal exec -- v2-testi.e. build the test outside of the
cabal execenvironment, then run the tests inside it.This still seems like a Cabal bug; conceptually, I would think that
cabal exec -- v2-build --enable-testsshould always work (i.e.cabal execshouldn't affect the build). It seems like there might be some edge case around Ubuntu + writing a compiler plugin +cabal exec. But I recognize this is probably a very rare edge case, so feel free to close until another incident comes up. At the very least, this is now documentedMikolaj commentedon Dec 5, 2022
Thank you for documenting this. Let's remember to compare once we have new data points. Closing.