`argv[0]` is not accessible to Lean
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
Please put an X between the brackets as you perform the following steps:
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. -
Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
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
execcan overrideargv[0]arbitrarily.
Context
Steps to Reproduce
- Create a lean binary
foo - 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:
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked EmitC.lean lines 173–182 and reproduce the issue by building the foo binary and running exec -a secret_name ./lake/build/bin/foo. Trace how the command-line arguments reach Lean’s main; done means the caller-supplied argv[0] is preserved in the first argument or exposed through an IO API.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend-api-design, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100