Skip to content

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

@KislyjKisel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LakeLake related issueP-mediumWe may work on this issue if we find the timebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions