@@ -130,7 +130,7 @@ async function install(args: string[], basePath: string) {
130130 const pkgx_dir = Deno . env . get ( "PKGX_DIR" ) || `${ Deno . env . get ( "HOME" ) } /.pkgx` ;
131131 const needs_sudo = Deno . uid ( ) != 0 && basePath === "/usr/local" ;
132132
133- const runtime_env = expand_runtime_env ( json . runtime_env , basePath ) ;
133+ const runtime_env = expand_runtime_env ( json , basePath ) ;
134134
135135 args = [
136136 "pkgx" ,
@@ -142,7 +142,7 @@ async function install(args: string[], basePath: string) {
142142 self ,
143143 "sudo-install" ,
144144 pkgx_dir ,
145- runtime_env ,
145+ JSON . stringify ( runtime_env ) ,
146146 basePath ,
147147 ...pkg_prefixes ,
148148 ] ;
@@ -248,7 +248,18 @@ async function mirror_directory(dst: string, src: string, prefix: string) {
248248}
249249
250250async function symlink ( src : string , dst : string ) {
251- for ( const base of [ "bin" , "sbin" , "share" , "lib" , "libexec" , "var" , "etc" ] ) {
251+ for (
252+ const base of [
253+ "bin" ,
254+ "sbin" ,
255+ "share" ,
256+ "lib" ,
257+ "libexec" ,
258+ "var" ,
259+ "etc" ,
260+ "ssl" ,
261+ ]
262+ ) {
252263 const foo = join ( src , base ) ;
253264 if ( existsSync ( foo ) ) {
254265 await processEntry ( foo , join ( dst , base ) ) ;
@@ -311,19 +322,44 @@ async function create_v_symlinks(prefix: string) {
311322}
312323
313324function expand_runtime_env (
314- runtime_env : Record < string , Record < string , string > > ,
325+ // deno-lint-ignore no-explicit-any
326+ json : Record < string , any > ,
315327 basePath : string ,
316328) {
317- const expanded : Record < string , Record < string , string > > = { } ;
318- for ( const [ project , env ] of Object . entries ( runtime_env ) ) {
319- const expanded_env : Record < string , string > = { } ;
329+ const runtime_env = json . runtime_env as Record < string , string > ;
330+
331+ //FIXME this combines all runtime env which is strictly overkill
332+ // for transitive deps that may not need it
333+
334+ const expanded : Record < string , Set < string > > = { } ;
335+ for ( const [ _project , env ] of Object . entries ( runtime_env ) ) {
320336 for ( const [ key , value ] of Object . entries ( env ) ) {
337+ //TODO expand all moustaches
321338 const new_value = value . replaceAll ( / \$ ? { { .* p r e f i x } } / g, basePath ) ;
322- expanded_env [ key ] = new_value ;
339+ expanded [ key ] ??= new Set < string > ( ) ;
340+ expanded [ key ] . add ( new_value ) ;
323341 }
324- expanded [ project ] = expanded_env ;
325342 }
326- return JSON . stringify ( expanded ) ;
343+
344+ // fix https://github.com/pkgxdev/pkgm/pull/30#issuecomment-2678957666
345+ if ( Deno . build . os == "linux" ) {
346+ expanded [ "LD_LIBRARY_PATH" ] ??= new Set < string > ( ) ;
347+ expanded [ "LD_LIBRARY_PATH" ] . add ( `${ basePath } /lib` ) ;
348+ }
349+
350+ const rv : Record < string , string > = { } ;
351+ for ( const [ key , set ] of Object . entries ( expanded ) ) {
352+ rv [ key ] = [ ...set ] . join ( ":" ) ;
353+ }
354+
355+ // DUMB but easiest way to fix a bug
356+ // deno-lint-ignore no-explicit-any
357+ const rv2 : Record < string , any > = { } ;
358+ for ( const { project } of json . pkgs as Record < string , string > [ ] ) {
359+ rv2 [ project ] = rv ;
360+ }
361+
362+ return rv2 ;
327363}
328364
329365function symlink_with_overwrite ( src : string , dst : string ) {
0 commit comments