Skip to content

lake: __dir__ contains relative path, that is cached and becomes wrong when using -d=.. flag #7498

Closed

Description

@KislyjKisel

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

__dir__ provided by lake when running from the package's root is ./.. When running from a subdirectory using -d=.., __dir__ is ../.. If running again without changing lakefile and without -R, __dir__ doesn't change regardless of cwd or -d=. As I understand, this is because it is stored in lakefile.olean.

Context

Steps to Reproduce

  1. Create a project
  2. To lakefile add:
script myScript do
  IO.println __dir__
  return 0
  1. From the package's root, run: lake run myScript
  2. From a subdirectory run lake run -d=.. myScript
  3. From the same subdirectory run lake run -R -d=.. myScript

Expected behavior:
Output contains paths to the package's directory.

Actual behavior:
Second path is invalid (it is a relative path, that is correct only when starting from the package's root).
Third path is valid, because -R triggers re-elaboration.

Versions

"4.18.0-rc1"
Linux 6.12.6-100.fc40.x86_64

Additional Information

I think it can be fixed by using IO.FS.realPath in Lake.DSL.elabDirConst.

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Activity

  1. added
    bug
    on Mar 15, 2025
  2. added
    Lake
    on Mar 17, 2025
  3. added
    P-medium
    on Mar 19, 2025
  4. added a commit that references this issue on Apr 5, 2025
    34385b8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    LakeP-mediumbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions