-
Notifications
You must be signed in to change notification settings - Fork 704
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
Wrong current path with custom build-type #5934
Comments
This issue could be solved if there is a way to get the project's root directory programmatically. Then that could be passed as a parameter to the process getting the git info. However, I could not find this in the documentation. Any pointers would help a lot. |
I suggest looking into I'm surprised if |
Ok. now I looked more closely: |
hrm could one add |
@gbaz it's not so easy, you'll need to chase pointers; ~/mess/Ampersand development % cat .git/HEAD
ref: refs/heads/development
~/mess/Ampersand development % cat .git/refs/heads/development
580b0f2ede9f19f33472290516f576c99833c1b6 And we have the limitation https://cabal.readthedocs.io/en/latest/developing-packages.html#pkg-field-data-files
|
right, which is why I suggested |
This is probably related with issue #5001 |
@hanjoosten not necessarily; based on @phadej's observation this is an intentional effect of In general, inferring the Git hash & tags during package builds is a terribly fragile thing to do and personally I've given up 10 years ago fighting with cabal (doing such Git-hackery was the very first thing I ever did with custom Setup.hs scripts and it quickly became very complex as I had to rewrite the .cabal file and Setup.hs when doing a |
My usecase is all about tracability. When I build foo.exe, I want to be able to know the exact codebase that was used to build it. So if the executable is called like |
@hanjoosten Yours is the very use-case I had 10 years ago and still have to this day! I need to be able in principle to exactly reproduce the state of the source tree and build-plan was in of a given executable artifact. And this is also the problem I'm currently solving via use of external scripts that produce the metadata, instead of having cabal drive the process. I.e. I have a script to make a deliverable artifact, which takes care of making sure the source tree is not dirty and that everything is in fact properly identifiable by the commit hash (which also covers the cabal freeze file, so the git commit hash also implicitly identifies the version of dependencies that went into the build). This is even easier to do combined with a CI/CD buildbot ideally sealed off from the internet which produces the artifacts, which ensures that each build starts from a clean state. All I'm trying to say here is that you don't need to do this inside the cabal layer; you can do this quite easily externally before cabal takes over. |
@hvr Hmm. I see what you mean. This could indeed be done by doing some preprocessing before calling cabal. I didn't want to go that way because you made a point last week about not using preprocessing. |
@hanjoosten that's not necessarily a contradiction :-) In fact, the arguments I brought up there apply here as well: if you need the ability to use the remote git repo deps (which is typically more relevant for libraries than for executables; and the executables are the ones you'd typically want to embed git hashes into), as you'd want for public OSS projects, then pre-processing like what I suggest needs to make sure the project still builds in a reasonable possibly gracefully degraded way (i.e. w/o Git metadata). In fact, it's desirable to have this also for local development (and while I didn't mention this, this is actually something I sometimes do as well for inhouse projects), as you certainly don't want a git hash change to invalidate/thrash your local build everytime it changes. |
@hanjoosten when #4746 is fixed you can use the (see #5866) [0] https://hackage.haskell.org/package/gitrev-1.3.1/docs/Development-GitRev.html |
My project has a custom build-type. After setup.hs is built, the resulting setup.exe is executed. In the past, it got executed in the project directory (the directory where the .cabal file resides). That is also the root directory of git.
One of the tasks of the custom setup is to fetch the commit id of git. However, this cannot be found now. Is this a bug, or is this a change on purpose? If the latter, is this documented somewhere?
NB: A build of the same code with stack works fine
The text was updated successfully, but these errors were encountered: