Skip to content

Commit

Permalink
fix Assertion failed: pkgx: env is being duped when multiple unicod…
Browse files Browse the repository at this point in the history
…es in env

closes #988
  • Loading branch information
jhheider committed Mar 14, 2024
1 parent 104affb commit 1c893af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/prefab/construct-env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,15 @@ 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') },
]

await _internals.mkenv({ installations })
})
}})
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}`))
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
}

0 comments on commit 1c893af

Please sign in to comment.