dream icon indicating copy to clipboard operation
dream copied to clipboard

example doesn't compile

Open martinsk opened this issue 2 years ago • 4 comments

In the example https://github.com/aantron/dream/tree/master/example/i-graphql

the instructions state:

$ cd example/i-graphql
$ npm install esy && npx esy
$ npx esy start

When doing the second step I get the following:

$ npm install esy && npx esy

up to date, audited 2 packages in 349ms

found 0 vulnerabilities
info esy 0.6.12 (using esy.json)
info building @opam/conf-libssl@opam:4@f8a1c73f
error: build failed with exit code: 1
  build log:
    # esy-build-package: building: @opam/conf-libssl@opam:4
    # esy-build-package: pwd: /Users/msk/.esy/3/b/opam__s__conf_libssl-opam__c__4-3061294c
    # esy-build-package: running: 'pkg-config' '--print-errors' '--exists' 'openssl'
    Package openssl was not found in the pkg-config search path.
    Perhaps you should add the directory containing `openssl.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'openssl' found
    error: command failed: 'pkg-config' '--print-errors' '--exists' 'openssl' (exited with 1)
    esy-build-package: exiting with errors above...

  building @opam/conf-libssl@opam:4
esy: exiting due to errors above

despite:

$ env  | tail -n2
PKG_CONFIG_PATH=/Users/msk/.opam/4.12.0/lib/pkgconfig:/usr/local/opt/openssl@3/lib/pkgconfig
_=/usr/bin/env

and

$ls /usr/local/opt/openssl@3/lib/pkgconfig
libcrypto.pc libssl.pc    openssl.pc

martinsk avatar May 07 '22 21:05 martinsk

i see the same thing. In terms of the environment, I think esy creates a fresh separate environment for the build (looking at the documentation). This seems to put the onus on the dependency to export the environment.

esy is trying to build @opam/conf-libssl@opam:4 and I'm not sure how the dependency resolver works because it presumably has to figure out that this depends on esy-openssl.

v-ahuja avatar May 12 '22 08:05 v-ahuja

If you use @opam/conf-libssl@opam:3 instead it should work since that has a override tat points to esy-openssl as @v-ahuja points out.

ulrikstrid avatar May 12 '22 11:05 ulrikstrid

I tried to set PKG_CONFIG_PATH path in the esy.json exportedEnv and sandboxEnv params but with no luck.

On macos it's possible to run the example by copying the example dir somewhere and then run

cp -r 2-middleware ~/code/

brew install opam
opam init

export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
opam install dream
cd ~/code/2-middleware
dune exec ./middleware.exe

bio avatar May 23 '22 22:05 bio

If you use @opam/conf-libssl@opam:3 instead it should work since that has a override tat points to esy-openssl as @v-ahuja points out.

This is what it looks like in your esy.json for esy to find it.

"@opam/conf-libssl": "3"

This worked. Thank you.

idkjs avatar May 31 '22 12:05 idkjs

Thanks @ulrikstrid for the fix, @idkjs for the PR. I've propagated the fix to all examples and they should build immediately now.

This seems like a problem upstream in esy, however. We are just working around it in Dream. Does anyone know anything about this? @ManasJayanth?

aantron avatar Mar 02 '23 10:03 aantron