Skip to content

One-liners create out/tmp/with_runtime in the current directory (the project-link half is fixed) #2354

Closed

Description

@ehartford

Restated 2026-10-25. One-liners no longer link the enclosing project's C dependencies (they run inside a project with c.libxml2 in with.toml). What is left: every one-liner creates out/tmp/with_runtime in the current directory, inside a project or not.


Original report

Spec reference: §18.5b one-liners (with -e, -n, -p): a one-liner is a self-contained program over the standard library. CLAUDE.md teaches them as drop-in replacements for grep/sed/awk, which work in any directory.

Repro (at e4861e1, any project whose with.toml has a C dependency; here [deps] c.raylib = "6.0"):

cd spiral            # a project directory
with -e 'print("hi")'
echo x | with -n 'print(line)'

Actual: both fail to link with the project's libraries:

ld.lld: error: unable to find library -lGL
ld.lld: error: unable to find library -lX11
...
error: required link libraries are unavailable:

The same command one directory up prints hi. In a project whose deps do link, the one-liner silently links the project's C libraries into a text filter.

Expected: a one-liner's meaning does not depend on the current directory. It compiles and links as a standalone program and prints hi.

Where (traced by reading the code; not yet confirmed in lldb):

  • src/main.w:716 cli_one_liner_source_name names the synthetic source <cli -e #1>, a relative path.
  • Compilation.project_config_for_source → ProjectConfig.w:140 project_config_load_for_source absolutizes it against runtime_cwd() (ProjectConfig.w:762), then project_config_find_root walks up from the cwd. It finds the enclosing with.toml and adopts its deps and link libraries.
  • The one-liner has no source file, so it has no project. It should get project_config_default() explicitly rather than inferring a project from a path it doesn't have.

Same path, same root (no fixed location of its own):

  • src/main.w:822 cli_one_liner_bin_path is the relative out/tmp/with-cli-one-liner-<pid>-<nanos>, so every one-liner creates out/tmp/ in whatever directory it runs from (observed: out/tmp/ appeared in an arbitrary scratch dir, and in the project's own out/tmp).
  • run_one_liner_command returns at if built == "": return 1 before removing the object, so a failed link leaves out/tmp/with-cli-one-liner-*.o behind (observed in spiral/out/tmp/).

Workaround used: run one-liners from outside any project directory.

Activity

  1. changed the title [-]One-liners (with -e/-n/-p) adopt the enclosing project's with.toml: link its C deps, write out/tmp into the cwd[/-] [+]One-liners create out/tmp/with_runtime in the current directory (the project-link half is fixed)[/+] on Oct 25, 2026
  2. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced for the stray directory.

    $ mkdir plain && cd plain
    $ with -e 'print("hi")'
    hi
    $ ls -a
    .  ..  out
    $ # inside a project: out/tmp/with_runtime is recreated after it is moved away
    

    pre-release: a grep-like tool that leaves out/ in every directory it runs in; one-liners are a stated priority.

  3. ehartford commented on Oct 25, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by 2396bc9 (PR #2655, stack #2658; battery green on the stack top 48c1c72). The commit message names the root-cause line and the regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions