# Get the absolute path to the current entrypoint (/docs/guides/util/main)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 231 · updated: 2026-07-28 -->
Related: [Upgrade Bun to the latest version](/docs/guides/util/upgrade.md), [Detect when code is executed with Bun](/docs/guides/util/detect-bun.md), [Get the current Bun version](/docs/guides/util/version.md), [Hash a password](/docs/guides/util/hash-a-password.md), [Generate a UUID](/docs/guides/util/javascript-uuid.md), [Encode and decode base64 data](/docs/guides/util/base64.md)

The `Bun.main` property contains the absolute path to the current entrypoint.

<CodeGroup>
  <CodeBlockTabs defaultValue="foo.ts">
    <CodeBlockTabsList>
      <CodeBlockTabsTrigger value="foo.ts">
        foo.ts
      </CodeBlockTabsTrigger>

      <CodeBlockTabsTrigger value="index.ts">
        index.ts
      </CodeBlockTabsTrigger>
    </CodeBlockTabsList>

    <CodeBlockTab value="foo.ts">
      ```ts icon="/icons/typescript.svg" 
      console.log(Bun.main);
      ```
    </CodeBlockTab>

    <CodeBlockTab value="index.ts">
      ```ts icon="/icons/typescript.svg" 
      import "./foo.ts";
      ```
    </CodeBlockTab>
  </CodeBlockTabs>
</CodeGroup>

***

The printed path is the file executed with `bun run`.

```sh terminal icon="terminal"
bun run index.ts
```

```txt
/path/to/index.ts
```

```sh terminal icon="terminal"
bun run foo.ts
```

```txt
/path/to/foo.ts
```

***

See [Utils](/runtime/utils).
