Skip to content

Make sure to import 'dirname' before using it#2781

Open
tyler-breisacher-zipline wants to merge 1 commit intoaspect-build:mainfrom
tyler-breisacher-zipline:patch-1
Open

Make sure to import 'dirname' before using it#2781
tyler-breisacher-zipline wants to merge 1 commit intoaspect-build:mainfrom
tyler-breisacher-zipline:patch-1

Conversation

@tyler-breisacher-zipline

I was following this example in our internal repo and Greptile caught this error -- we were using dirname without importing it.

Changes are visible to end-users: no

Test plan

  • Covered by existing test cases

@CLAassistant
Copy link

CLAassistant commented Mar 23, 2026

CLA assistant check
All committers have signed the CLA.

@aspect-workflows
Copy link

aspect-workflows bot commented Mar 23, 2026

Bazel 7 (Test)

All tests were cache hits

317 tests (100.0%) were fully cached saving 42s.


Bazel 8 (Test)

All tests were cache hits

275 tests (100.0%) were fully cached saving 35s.


Bazel 9 (Test)

All tests were cache hits

275 tests (100.0%) were fully cached saving 39s.


Bazel 7 (Test)

e2e/bzlmod

All tests were cache hits

7 tests (100.0%) were fully cached saving 664ms.


Bazel 8 (Test)

e2e/bzlmod

All tests were cache hits

7 tests (100.0%) were fully cached saving 642ms.


Bazel 9 (Test)

e2e/bzlmod

All tests were cache hits

7 tests (100.0%) were fully cached saving 596ms.


Bazel 7 (Test)

e2e/git_dep_metadata

All tests were cache hits

1 test (100.0%) was fully cached saving 30ms.


Bazel 8 (Test)

e2e/git_dep_metadata

All tests were cache hits

1 test (100.0%) was fully cached saving 26ms.


Bazel 9 (Test)

e2e/git_dep_metadata

All tests were cache hits

1 test (100.0%) was fully cached saving 30ms.


Bazel 7 (Test)

e2e/gyp_no_install_script

All tests were cache hits

2 tests (100.0%) were fully cached saving 112ms.


Bazel 8 (Test)

e2e/gyp_no_install_script

All tests were cache hits

1 test (100.0%) was fully cached saving 50ms.


Bazel 9 (Test)

e2e/gyp_no_install_script

All tests were cache hits

1 test (100.0%) was fully cached saving 46ms.


Bazel 7 (Test)

e2e/js_binary_workspace

All tests were cache hits

1 test (100.0%) was fully cached saving 44ms.


Bazel 8 (Test)

e2e/js_binary_workspace

All tests were cache hits

1 test (100.0%) was fully cached saving 30ms.


Bazel 9 (Test)

e2e/js_binary_workspace

All tests were cache hits

1 test (100.0%) was fully cached saving 35ms.


Bazel 7 (Test)

e2e/js_image_oci

All tests were cache hits

1 test (100.0%) was fully cached saving 3s.


Bazel 7 (Test)

e2e/npm_link_package

All tests were cache hits

2 tests (100.0%) were fully cached saving 172ms.


Bazel 8 (Test)

e2e/npm_link_package

All tests were cache hits

2 tests (100.0%) were fully cached saving 137ms.


Bazel 9 (Test)

e2e/npm_link_package

All tests were cache hits

2 tests (100.0%) were fully cached saving 170ms.


Bazel 7 (Test)

e2e/npm_link_package-esm

All tests were cache hits

2 tests (100.0%) were fully cached saving 189ms.


Bazel 8 (Test)

e2e/npm_link_package-esm

All tests were cache hits

2 tests (100.0%) were fully cached saving 138ms.


Bazel 9 (Test)

e2e/npm_link_package-esm

All tests were cache hits

2 tests (100.0%) were fully cached saving 173ms.


Bazel 7 (Test)

e2e/npm_link_package-rerooted

All tests were cache hits

2 tests (100.0%) were fully cached saving 207ms.


Bazel 8 (Test)

e2e/npm_link_package-rerooted

All tests were cache hits

2 tests (100.0%) were fully cached saving 139ms.


Bazel 9 (Test)

e2e/npm_link_package-rerooted

All tests were cache hits

2 tests (100.0%) were fully cached saving 186ms.


Bazel 7 (Test)

e2e/npm_translate_lock

All tests were cache hits

3 tests (100.0%) were fully cached saving 383ms.


Bazel 8 (Test)

e2e/npm_translate_lock

All tests were cache hits

3 tests (100.0%) were fully cached saving 287ms.


Bazel 9 (Test)

e2e/npm_translate_lock

All tests were cache hits

3 tests (100.0%) were fully cached saving 289ms.


Bazel 7 (Test)

e2e/npm_translate_lock_disable_hooks

Buildkite build #12425 is running...


Bazel 8 (Test)

e2e/npm_translate_lock_disable_hooks

All tests were cache hits

1 test (100.0%) was fully cached saving 62ms.


Bazel 9 (Test)

e2e/npm_translate_lock_disable_hooks

All tests were cache hits

1 test (100.0%) was fully cached saving 32ms.


Bazel 7 (Test)

e2e/npm_translate_lock_empty

All tests were cache hits

2 tests (100.0%) were fully cached saving 132ms.


Bazel 8 (Test)

e2e/npm_translate_lock_empty

All tests were cache hits

2 tests (100.0%) were fully cached saving 114ms.


Bazel 9 (Test)

e2e/npm_translate_lock_empty

All tests were cache hits

2 tests (100.0%) were fully cached saving 105ms.


Bazel 7 (Test)

e2e/npm_translate_lock_exclude_package_contents

All tests were cache hits

1 test (100.0%) was fully cached saving 33ms.


Bazel 8 (Test)

e2e/npm_translate_lock_exclude_package_contents

All tests were cache hits

1 test (100.0%) was fully cached saving 21ms.


Bazel 9 (Test)

e2e/npm_translate_lock_exclude_package_contents

All tests were cache hits

1 test (100.0%) was fully cached saving 86ms.


Bazel 7 (Test)

e2e/npm_translate_lock_multi

All tests were cache hits

2 tests (100.0%) were fully cached saving 106ms.


Bazel 8 (Test)

e2e/npm_translate_lock_multi

All tests were cache hits

2 tests (100.0%) were fully cached saving 54ms.


Bazel 9 (Test)

e2e/npm_translate_lock_multi

All tests were cache hits

2 tests (100.0%) were fully cached saving 113ms.


Bazel 7 (Test)

e2e/npm_translate_lock_partial_clone

All tests were cache hits

1 test (100.0%) was fully cached saving 26ms.


Bazel 8 (Test)

e2e/npm_translate_lock_partial_clone

All tests were cache hits

1 test (100.0%) was fully cached saving 30ms.


Bazel 9 (Test)

e2e/npm_translate_lock_partial_clone

All tests were cache hits

1 test (100.0%) was fully cached saving 38ms.


Bazel 7 (Test)

e2e/npm_translate_lock_replace_packages

All tests were cache hits

4 tests (100.0%) were fully cached saving 321ms.


Bazel 8 (Test)

e2e/npm_translate_lock_replace_packages

All tests were cache hits

4 tests (100.0%) were fully cached saving 249ms.


Bazel 9 (Test)

e2e/npm_translate_lock_replace_packages

All tests were cache hits

4 tests (100.0%) were fully cached saving 320ms.


Bazel 7 (Test)

e2e/npm_translate_lock_subdir_patch

Buildkite build #12425 is running...


Bazel 8 (Test)

e2e/npm_translate_lock_subdir_patch

All tests were cache hits

1 test (100.0%) was fully cached saving 67ms.


Bazel 9 (Test)

e2e/npm_translate_lock_subdir_patch

All tests were cache hits

1 test (100.0%) was fully cached saving 50ms.


Bazel 7 (Test)

e2e/npm_translate_package_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 25ms.


Bazel 8 (Test)

e2e/npm_translate_package_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 62ms.


Bazel 9 (Test)

e2e/npm_translate_package_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 32ms.


Bazel 7 (Test)

e2e/npm_translate_yarn_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 25ms.


Bazel 8 (Test)

e2e/npm_translate_yarn_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 62ms.


Bazel 9 (Test)

e2e/npm_translate_yarn_lock

All tests were cache hits

1 test (100.0%) was fully cached saving 32ms.


Bazel 7 (Test)

e2e/output_paths

All tests were cache hits

2 tests (100.0%) were fully cached saving 213ms.


Bazel 8 (Test)

e2e/output_paths

All tests were cache hits

2 tests (100.0%) were fully cached saving 252ms.


Bazel 9 (Test)

e2e/output_paths

All tests were cache hits

2 tests (100.0%) were fully cached saving 171ms.


Bazel 7 (Test)

e2e/package_json_module

All tests were cache hits

1 test (100.0%) was fully cached saving 195ms.


Bazel 8 (Test)

e2e/package_json_module

All tests were cache hits

1 test (100.0%) was fully cached saving 192ms.


Bazel 9 (Test)

e2e/package_json_module

All tests were cache hits

1 test (100.0%) was fully cached saving 190ms.


Bazel 7 (Test)

e2e/patch_from_repo

All tests were cache hits

1 test (100.0%) was fully cached saving 25ms.


Bazel 7 (Test)

e2e/pnpm_lockfiles

All tests were cache hits

41 tests (100.0%) were fully cached saving 4s.


Bazel 8 (Test)

e2e/pnpm_lockfiles

All tests were cache hits

13 tests (100.0%) were fully cached saving 1s.


Bazel 9 (Test)

e2e/pnpm_lockfiles

All tests were cache hits

13 tests (100.0%) were fully cached saving 955ms.


Bazel 7 (Test)

e2e/pnpm_repo_install

All tests were cache hits

1 test (100.0%) was fully cached saving 746ms.


Bazel 8 (Test)

e2e/pnpm_repo_install

All tests were cache hits

1 test (100.0%) was fully cached saving 772ms.


Bazel 9 (Test)

e2e/pnpm_repo_install

All tests were cache hits

1 test (100.0%) was fully cached saving 738ms.


Bazel 7 (Test)

e2e/pnpm_version

Buildkite build #12425 is running...


Bazel 8 (Test)

e2e/pnpm_version

Buildkite build #12425 is running...


Bazel 9 (Test)

e2e/pnpm_version

All tests were cache hits

1 test (100.0%) was fully cached saving 42ms.


Bazel 7 (Test)

e2e/pnpm_workspace

All tests were cache hits

15 tests (100.0%) were fully cached saving 2s.


Bazel 8 (Test)

e2e/pnpm_workspace

All tests were cache hits

14 tests (100.0%) were fully cached saving 2s.


Bazel 9 (Test)

e2e/pnpm_workspace

Buildkite build #12425 is running...


Bazel 7 (Test)

e2e/pnpm_workspace_deps

All tests were cache hits

3 tests (100.0%) were fully cached saving 212ms.


Bazel 8 (Test)

e2e/pnpm_workspace_deps

All tests were cache hits

3 tests (100.0%) were fully cached saving 278ms.


Bazel 9 (Test)

e2e/pnpm_workspace_deps

All tests were cache hits

3 tests (100.0%) were fully cached saving 237ms.


Bazel 7 (Test)

e2e/pnpm_workspace_rerooted

All tests were cache hits

15 tests (100.0%) were fully cached saving 2s.


Bazel 8 (Test)

e2e/pnpm_workspace_rerooted

All tests were cache hits

14 tests (100.0%) were fully cached saving 1s.


Bazel 9 (Test)

e2e/pnpm_workspace_rerooted

All tests were cache hits

14 tests (100.0%) were fully cached saving 2s.


Bazel 7 (Test)

e2e/repo_mapping

Buildkite build #12425 is running...


Bazel 8 (Test)

e2e/repo_mapping

Buildkite build #12425 is running...


Bazel 9 (Test)

e2e/repo_mapping

All tests were cache hits

3 tests (100.0%) were fully cached saving 308ms.


Bazel 7 (Test)

e2e/runfiles

Buildkite build #12425 is running...


Bazel 8 (Test)

e2e/runfiles

Buildkite build #12425 is running...


Bazel 9 (Test)

e2e/runfiles

Buildkite build #12425 is running...


Bazel 7 (Test)

e2e/stamped_package_json

Buildkite build #12425 is running...


Bazel 8 (Test)

e2e/stamped_package_json

All tests were cache hits

1 test (100.0%) was fully cached saving 24ms.


Bazel 9 (Test)

e2e/stamped_package_json

All tests were cache hits

1 test (100.0%) was fully cached saving 130ms.


Bazel 7 (Test)

e2e/vendored_node

Buildkite build #12425 is running...


Bazel 8 (Test)

e2e/vendored_node

All tests were cache hits

1 test (100.0%) was fully cached saving 57ms.


Bazel 9 (Test)

e2e/vendored_node

All tests were cache hits

1 test (100.0%) was fully cached saving 57ms.


Bazel 7 (Test)

e2e/vendored_tarfile

Buildkite build #12425 is running...


Bazel 8 (Test)

e2e/vendored_tarfile

Buildkite build #12425 is running...


Bazel 9 (Test)

e2e/vendored_tarfile

All tests were cache hits

1 test (100.0%) was fully cached saving 32ms.


Bazel 7 (Test)

e2e/verify_patches

Buildkite build #12425 is running...


Bazel 8 (Test)

e2e/verify_patches

Buildkite build #12425 is running...


Bazel 9 (Test)

e2e/verify_patches

Buildkite build #12425 is running...


Bazel 7 (Test)

e2e/worker

All tests were cache hits

1 test (100.0%) was fully cached saving 75ms.


Bazel 8 (Test)

e2e/worker

Buildkite build #12425 is running...


Bazel 9 (Test)

e2e/worker

Buildkite build #12425 is running...


Bazel 7 (Test)

examples/proto

All tests were cache hits

1 test (100.0%) was fully cached saving 120ms.


Bazel 8 (Test)

examples/proto

All tests were cache hits

1 test (100.0%) was fully cached saving 132ms.


Bazel 9 (Test)

examples/proto

Buildkite build #12425 is running...


Buildifier      Format

@tyler-breisacher-zipline
Copy link
Author

import.meta.dirname should be available on Node 20+ so I guess to really test this thoroughly we'd need to test on Node 19 which has been EOL for a couple years now.

import { join } from 'node:path'
import { dirname, join } from 'node:path'

const appDir = import.meta.dirname || dirname(fileURLToPath(import.meta.url))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const appDir = import.meta.dirname || dirname(fileURLToPath(import.meta.url))
const appDir = import.meta.dirname

or, would you rather just do this?

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a52955bd24

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@@ -1,4 +1,4 @@
import { join } from 'node:path'
import { dirname, join } from 'node:path'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Import fileURLToPath alongside the new dirname fallback

In runtimes where import.meta.dirname is undefined, this file still evaluates dirname(fileURLToPath(import.meta.url)), but fileURLToPath is never imported. That means the example continues to fail with ReferenceError: fileURLToPath is not defined on those Node versions, so this change does not actually fix the portability problem it is trying to address.

Useful? React with 👍 / 👎.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok same question, should we import fileURLToPath or should we just get rid of the stuff after the ||?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants