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

fix Assertion failed: pkgx: env is being duped when multiple unicodes in env #989

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/prefab/construct-env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,20 @@ async fn(runner) {
await _internals.runtime_env(pkg, [])
}
})

await runner.step("multiple versions", async () => {
const tmp = Path.mktemp()

const installations = [
{ pkg: {project: "unicode.org", version: new SemVer("71.0.0")}, path: tmp.join("unicode.org/v71.0.0").mkdir('p') },
{ pkg: {project: "unicode.org", version: new SemVer("73.0.0")}, path: tmp.join("unicode.org/v73.0.0").mkdir('p') },
]
const stub3 = mock.stub(_internals, "runtime_env", async () => ({}))
try {
await _internals.mkenv({ installations })
} finally {
stub3.restore()
tmp.rm({recursive: true})
}
})
}})
5 changes: 3 additions & 2 deletions src/prefab/construct-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default async function(pkgenv: { installations: Installation[] }) {

///////////////////////// reworked from useShellEnv needs porting back to libpkgx
async function mkenv({installations}: {installations: Installation[]}) {
const projects = new Set(installations.map(x => x.pkg.project))
const projects = new Set(installations.map(x => `${x.pkg.project}@${x.pkg.version}`))
Copy link
Member

Choose a reason for hiding this comment

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

Can't remember why we added this anyway.

Copy link
Contributor Author

@jhheider jhheider Sep 5, 2024

Choose a reason for hiding this comment

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

it's been a while, but i believe it's because we can allow multiple unicode lib versions in the env simultaneously, and this check trips if there are two or more (since they map to the same name).

unless you mean the dupe-check; in which case, i'm sure it's sanity checking. definitely a good idea with how complex the env can get.

Copy link
Member

Choose a reason for hiding this comment

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

I seem to recall there was an issue if an env had multiple of the same exact thing but can't remember.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i do recall at one point early on we would sometimes get the pkg@ver duplicated; perhaps this was to ensure that bug never returned.

console.assert(projects.size == installations.length, "pkgx: env is being duped")

const common_vars: Record<string, OrderedSet<string>> = {}
Expand Down Expand Up @@ -160,5 +160,6 @@ class OrderedSet<T> {

////////////////////////////////////////////////////////////////////// internals
export const _internals = {
runtime_env: (pkg: Package, installations: Installation[]) => usePantry().project(pkg.project).runtime.env(pkg.version, installations)
runtime_env: (pkg: Package, installations: Installation[]) => usePantry().project(pkg.project).runtime.env(pkg.version, installations),
mkenv
}