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

argv[0] is not accessible to Lean #5819

Open
2 of 3 tasks
eric-wieser opened this issue Oct 23, 2024 · 0 comments · May be fixed by #5820
Open
2 of 3 tasks

argv[0] is not accessible to Lean #5819

eric-wieser opened this issue Oct 23, 2024 · 0 comments · May be fixed by #5820
Labels
bug Something isn't working P-high We will work on this issue

Comments

@eric-wieser
Copy link
Contributor

eric-wieser commented Oct 23, 2024

Prerequisites

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

Description

The lean def main is passed arg[1] to argv[argc - 1].

This is consistent with the behavior of Haskell's getArgs, but Lean does not provide haskell's getProgName.

IO.appPath is not a substitute for argv[0], as:

  • argv[0] contains the pre-resolved symlinks
  • The caller of exec can override argv[0] arbitrarily.

Context

Zulip thread

Steps to Reproduce

  1. Create a lean binary foo
  2. Run (exec -a secret_name ./lake/build/bin/foo)

Expected behavior: secret_name should either be in the first entry of args, or accessible via some IO API

Actual behavior: secret_name is lost forever:

if xs.size == 2 then
emitLns ["in = lean_box(0);",
"int i = argc;",
"while (i > 1) {",
" lean_object* n;",
" i--;",
" n = lean_alloc_ctor(1,2,0); lean_ctor_set(n, 0, lean_mk_string(argv[i])); lean_ctor_set(n, 1, in);",
" in = n;",
"}"]
emitLn ("res = " ++ leanMainFn ++ "(in, lean_io_mk_world());")

Versions

[Output of #eval Lean.versionString]
[OS version, if not using live.lean-lang.org.]

Additional Information

[Additional information, configuration or data that might be necessary to reproduce the issue]

Impact

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

@eric-wieser eric-wieser added the bug Something isn't working label Oct 23, 2024
@eric-wieser eric-wieser linked a pull request Oct 23, 2024 that will close this issue
@leanprover-bot leanprover-bot added the P-high We will work on this issue label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-high We will work on this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants