Skip to content

plan.json doesn't include compiler id. #10726

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

Open
phadej opened this issue Jan 8, 2025 · 5 comments
Open

plan.json doesn't include compiler id. #10726

phadej opened this issue Jan 8, 2025 · 5 comments
Labels
re: cabal-plan Concerning functionality offered by `cabal-plan` type: bug

Comments

@phadej
Copy link
Collaborator

phadej commented Jan 8, 2025

Since some version of cabal-install, the locations of ghc-specific store take "project unit id" (e.g. ,("Project Unit Id","ghc-9.10.1-69c3")) into account. So it's not store/ghc-9.10.1 but store/ghc-9.10.1-69c3). However this information is absent from plan.json. plan.json contains just a version as compiler-id:

% python3 -m json.tool dist-newstyle/cache/plan.json|less
{
    "cabal-version": "3.14.1.1",
    "cabal-lib-version": "3.14.1.1",
    "compiler-id": "ghc-9.10.1",
    "os": "linux",
    "arch": "x86_64",
    "install-plan": [
...

Therefore tools (e.g. cabal-plan) which traverse the plan.json but also information in the store (e.g. license files), cannot do this anymore without also somehow finding the corresponding GHC (which can be anywhere, that's the point of an additional few bits - to disambiguate different GHC builds even with the same main version).

@mpickering
Copy link
Collaborator

In general it doesn't seem correct to assume that a package in the build plan comes from the store. It may also come from a package database given by package-db or the global package database.

Perhaps it would be better in future to store the LICENSE information in the plan.json directly, if this becomes a problem.

For now I will just expose the store-dir from the plan.json.

mpickering added a commit that referenced this issue Mar 21, 2025
The plan.json file was missing crucial information needed to locate
packages in the store directory structure. When cabal-install stores
packages, it uses a full compiler identifier including an ABI tag (e.g.,
"ghc-9.10.1-69c3") but plan.json only included the basic compiler ID
("ghc-9.10.1"). This made it impossible for external tools like
cabal-plan to correctly locate packages and their files in the store.

This commit adds:

1. A new "compiler-abi" field with the ABI tag string
2. A "store-dir" section containing:
   - The complete store directory path (with full compiler ID)
   - The store package database path
   - The store incoming directory path

These additions allow tools to accurately locate packages in the store
without having to guess or reconstruct the paths themselves. The
StoreDirLayout is now passed to the JSON encoder, making all
store-related paths available in plan.json.

The issue reported in the original ticket seems to be about the location
of LICENSE files, but the plan.json may still lack sufficient
information to locate all license files since the packages may not be
located in the store, but in different package databases given by
the --package-db flag.  This will do for now.

Fixes #10726
@mpickering
Copy link
Collaborator

@phadej Please let me know if this patch will solve your problem. #10845

@phadej
Copy link
Collaborator Author

phadej commented Mar 21, 2025

@mpickering i think it does, but I also think it does too much as I told in private.

@phadej
Copy link
Collaborator Author

phadej commented Mar 23, 2025

In general it doesn't seem correct to assume that a package in the build plan comes from the store. It may also come from a package database given by package-db or the global package database.

plan.json specifies when package in the plan comes from global db.
--package-db is undefined behavior in v2-build; even if it does something, it would break store's consistency.

Perhaps it would be better in future to store the LICENSE information in the plan.json directly, if this becomes a problem.

Please no, plan.json is just a plan, not contents.

For now I will just expose the store-dir from the plan.json.

Store directory is not plan. It also is directly in conflict with any effort making store relocatable.

@mpickering
Copy link
Collaborator

I think you are referring to the assumption that the global db (and any package databases specified with --package-db) are immutable. That isn't kept track of very well at the moment but perhaps you could record a hash of each package database you are using rather than just the path to it. If you start mutating the global package database then yes you will corrupt the store.

For now I will expose the "abi" field of the compiler into the plan.json and not address this other issue with attempting to recreate store paths from the plan.json file. It's noted on this ticket that use-case is not robust in all situations.

mpickering added a commit that referenced this issue Mar 24, 2025
The plan.json file was missing crucial information needed to locate
packages in the store directory structure. When cabal-install stores
packages, it uses a full compiler identifier including an ABI tag (e.g.,
"ghc-9.10.1-69c3") but plan.json only included the basic compiler ID
("ghc-9.10.1"). This made it impossible for external tools like
cabal-plan to correctly locate packages and their files in the store.

This commit adds a new "compiler-abi" field with the ABI tag string

The issue reported in the original ticket seems to be about the location
of LICENSE files, but the plan.json may still lack sufficient
information to locate all license files since the packages may not be
located in the store, but in different package databases given by
the --package-db flag.  This will do for now.

Fixes #10726
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
re: cabal-plan Concerning functionality offered by `cabal-plan` type: bug
Projects
None yet
Development

No branches or pull requests

3 participants