Esy: @opam/postgresql can't find pg_config

Created on 25 Aug 2018  路  4Comments  路  Source: esy/esy


esy version:
0.2.6

Operating System:
macOS Sierra

Issue:
I'm trying to recreate a dune project with esy. The project hangs up with the dependencies for ocaml-caqti when esy tries to install postgres-ocaml

Package.json

{
  "name": "esy-caqti",
  "version": "0.1.0",
  "description": "OCaml workflow with Esy",
  "author": "",
  "license": "MIT",
  "esy": {
    "build": [
      "refmterr dune build"
    ],
    "install": [
      "esy-installer"
    ],
    "buildsInSource": "_build"
  },
  "dependencies": {
    "@esy-ocaml/esy-installer": "^0.0.0",
    "@opam/dune": "*",
    "@opam/lambda-term": "*",
    "@opam/lwt": "*",
    "@opam/lwt_ppx": "*",
    "@opam/caqti": "*",
    "@opam/caqti-driver-postgresql": "*",
    "@opam/caqti-lwt": "*",
    "@esy-ocaml/reason": "*",
    "refmterr": "*"
  },
  "peerDependencies": {
    "ocaml": "~4.06.0"
  },
  "devDependencies": {
    "@esy-ocaml/merlin": "*",
    "ocaml": "~4.06.0"
  },
  "private": true
}

Actual behavior:
full error.md

PrisBook:esy-caqti$ esy build
info esy build 0.2.6
info found esy manifests: package.json
info Building @opam/[email protected]: starting
esy: error, exiting...
     build failed
       Building @opam/[email protected]
       Build log:
         # esy-build-package: building: @opam/[email protected]
         # esy-build-package: running: 'jbuilder' 'build' '-p' 'postgresql'
     '-j' '4'
             discover src/c_flags.sexp,src/c_library_flags.sexp (exit 2)
         (cd _build/default/src && config/discover.exe -ocamlc
     /Users/prisc_000/.esy/3_______________________________________________________________/i/ocaml-4.6.5-9ea2c05c/bin/ocamlc.opt)
         /bin/sh: pg_config: command not found
         run:
     /Users/prisc_000/.esy/3_______________________________________________________________/i/ocaml-4.6.5-9ea2c05c/bin/ocamlc.opt
     -config
         -> process exited with code 0

Expected behavior:
Successful build
Additional steps to reproduce:
git clone https://github.com/idkjs/esy-caqti.git
run esy install then esy build

Project runs using dune only. I wanted to get it into esy.
Thank you.

Most helpful comment

The proper esy way would be to create postgresql package for esy 馃殌 so that it can could be specified as a dependency in package.json and installed/built by esy.

All 4 comments

It can't find pg_config because postgresql isn't in the esy sandbox.

esy adds few dir by default into the sandbox's $PATH, like /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin and apparently your postgresql installation isn't there.

The current workaround would be to add a dir which has pg_config into the $PATH by configuring sandboxEnv.

Do

% which pg_config

in the terminal so you can find the directory pg_config executable resides in. Then in package.json:

"esy": {
  "sandboxEnv": {
    "PATH": "/path/to/dir/with_pg_config:$PATH"
  }
}

That should do the trick, though it won't reuse currently cached deps for this sandbox (b/c sandboxEnv busts the cache).

The proper esy way would be to create postgresql package for esy 馃殌 so that it can could be specified as a dependency in package.json and installed/built by esy.

This can be solved with #386 by the way. This will allow to have conf-postgresql package which will probe system for the PostgreSQL installation and bring it to the esy sandbox.

I wil look at that. Thanks @andreypopp

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bryphe picture bryphe  路  7Comments

jordwalke picture jordwalke  路  5Comments

bryphe picture bryphe  路  6Comments

maarekj picture maarekj  路  7Comments

miguelbermudez picture miguelbermudez  路  4Comments