Skip to content
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

Enso_Project.enso_project does not work as advertised #9845

Open
radeusgd opened this issue May 2, 2024 · 1 comment
Open

Enso_Project.enso_project does not work as advertised #9845

radeusgd opened this issue May 2, 2024 · 1 comment
Assignees
Labels

Comments

@radeusgd
Copy link
Member

radeusgd commented May 2, 2024

The documentation says that it

Returns the Enso project description for the project that the engine was
executed with, i.e., the project that contains the `main` method

however in practice, which can be easily confirmed by checking the code - it returns the project associated with the immediate call site.

That means that if I call Enso_Project.enso_project from within the Standard.Base library, it will actually return the project for Base, not the project that is currently running and only calling into Base.

Moreover, the result is cached, so the behaviour of this method depends on where it was called first, for example:

  1. Create the following file in Base/0.0.0-dev/src/My_Test.enso:
    import project.Meta.Enso_Project
    
    foo = Enso_Project.enso_project
    
  2. Rebuild the engine and run a project with following Main.enso method:
    from Standard.Base import all
    import Standard.Base.Meta.Enso_Project
    import Standard.Base.My_Test
    
    main = 
        IO.println My_Test.foo.name
        IO.println Enso_Project.enso_project.name
    
  3. Then run it again swapping the last 2 lines:
        IO.println Enso_Project.enso_project.name
        IO.println My_Test.foo.name
    

The first run yields:

Base
Base

and the second run yields:

testproject1
testproject1

The result depends only on the place where Enso_Project.enso_project was called first.

@radeusgd
Copy link
Member Author

radeusgd commented May 2, 2024

Moreover, the Enso_Project.enso_project call fails if the first time we are calling it outside of Enso:

Assertion_Error.Error 'Should not reach here: callRootNode = org.graalvm.polyglot.Value<Function>.execute. Probably not called from Enso?'
        at <enso> Enso_Project.enso_project(X:\NBO\enso\built-distribution\enso-engine-0.0.0-dev-windows-amd64\enso-0.0.0-dev\lib\Standard\Base\0.0.0-dev\src\Meta\Enso_Project.enso:105:5-52)
        at <java> org.graalvm.polyglot.Value<Function>.execute(Internal)
        at <Unknown Location> related to com.oracle.truffle.host.HostObject.doInvoke
        at <enso> case_branch(X:\NBO\enso\built-distribution\enso-engine-0.0.0-dev-windows-amd64\enso-0.0.0-dev\lib\Standard\Base\0.0.0-dev\src\Enso_Cloud\Internal\Audit_Log.enso:36:25-81)

This is problematic for my use-case as I need to report some audit logs directly from the Java helper libraries. Can we maybe initialize the project info somewhere during Context initialization to ensure that we can guarantee it is also accessible to Java code?

radeusgd added a commit that referenced this issue May 2, 2024
radeusgd added a commit that referenced this issue May 2, 2024
radeusgd added a commit that referenced this issue May 6, 2024
radeusgd added a commit that referenced this issue May 6, 2024
radeusgd added a commit that referenced this issue May 7, 2024
radeusgd added a commit that referenced this issue May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 📤 Backlog
Development

No branches or pull requests

2 participants