astrada / ppx_bs_css

A ppx rewriter for CSS expressions.
MIT License
98 stars 7 forks source link

Installing ppx_bs_css as dependency fails with OCaml 4.2.3 #3

Closed jchavarri closed 6 years ago

jchavarri commented 6 years ago

When installing ppx_bs_css through esy inside a project where it's been added as a dependency, the installation fails with:

Error: ppx_bs_css > @opam/sedlex > @opam/gen > @opam/odoc > @opam/doc-ock-html > @opam/doc-ock@=1.0.0: no version found for the current OCaml version 4.2.3004.

The problem can be reproduced by removing esy.lock from the root folder of the project and calling esy install again.

I tried to pin sedlex to v1.99.2 which doesn't seem to depend on gen and thus breaks the dependency chain, but it's a release from 2014 and it seems to break something:

File "src/css_lexer.ml", line 81, characters 16-29:
Uninterpreted extension 'sedlex.regexp'.

cc @andreypopp as you mentioned to be tagged on the issue, although I think it's totally unrelated to esy and more of a dependencies headache :)

jchavarri commented 6 years ago

I'm just realizing now this is the problem mentioned by @astrada in https://github.com/astrada/ppx_bs_css/issues/1#issuecomment-367984828 😅 but in this case, the esy.lock solution doesn't apply because it's ignored when installing the package as a dependency.

astrada commented 6 years ago

Yes, we should probably open an issue on opam-repository. I'm setting up a reminder to do it :)

andreypopp commented 6 years ago

@astrada esy now has a very poor dependency solver so this can be a problem with it rather than we opam-repository (unless things start to drop support for 4.02.3 there but then it's a problem with bs supporting an old OCaml version only).

astrada commented 6 years ago

I will check again, but as far as I know it's a problem of a missing constraint on an opam package.

astrada commented 6 years ago

@jchavarri: I've found a workaround. You should add a resolutions section to your packages.json:

"resolutions": {
    "@opam/gen": "0.5.0"
  }

The problems seems caused by esy-opam that is treating doc dependencies like standard/build dependencies.

@andreypopp: Should I open an issue on esy-opam? (I tried to see if I could fix the filter, but it seems correct, I don't know why it's not working as expected).

andreypopp commented 6 years ago

@astrada I've added this failure to the collection of failing packages w ehave with esy install.

jchavarri commented 6 years ago

Thanks @astrada ! With that fix, the error disappears 🎉

I think i'm just one step away from being able to use the ppx from my consumer. The last issue I'm finding is that the ppx_bs_css executable gets added to the following folder:

/Users/javi/.esy/3__________/i/ppx___bs___css-0.1.0-d804b72e/lib/ppx_bs_css/ppx.exe

But it seems this folder is not added to PATH by esy? Only

/Users/javi/.esy/3__________/i/ppx___bs___css-0.1.0-d804b72e/bin

@andreypopp is there a specific folder organization that ppx_bs_css should follow in order to make ppx.exe available from esy?

andreypopp commented 6 years ago

The simplest thing would be to make an installable executable for this ppx.

The gist is:

  1. Add bs_ppx_css.ml:
    let () = Ppx_driver.standalone ()
  2. Add (executable ...) stanza like this:
    (executable
    ((name bs_ppx_css)
    (public_name bs-ppx-css)
    (modules (bs_ppx_css))
    (libraries (ppx_css ppxlib))))

    then bs-ppx-css should appear on $PATH inside esy.

(info from http://rgrinberg.com/posts/extension-points-3-years-later/)

astrada commented 6 years ago

Thanks, @andreypopp!

@jchavarri: I implemented Andrey's suggestion on branch issue3. Let me know if it solves the issue (remember to update bsconfig.json to use bs-ppx-css instead of ppx_bs_css).

jchavarri commented 6 years ago

@astrada Thank you!

I'm trying to install the latest version but there seems to be something wrong when running esy build:

The error below is likely a bug in Esy itself, please report it.

  Error: Command failed.
Exit code: 1
Command: /Users/javi/.nvm/versions/node/v8.11.1/lib/node_modules/esy/node_modules/@esy-ocaml/ocamlrun/install/bin/ocamlrun
Arguments: /Users/javi/.nvm/versions/node/v8.11.1/lib/node_modules/esy/bin/esyBuildPackage -B -
Directory: /Users/javi/Development/github/rebind.github.io
Output:
# esy-build-package: running: 'jbuilder' 'subst' '-n' 'alcotest'
# esy-build-package: running: 'jbuilder' 'build' '-p' 'alcotest' '-j' '4'
File "src/jbuild", line 8, characters 40-47:
Error: Library "fmt.tty" in /Users/javi/.esy/3____________________________________________________________________/i/opam__slash__fmt-0.8.5-1ad02d88/lib/fmt is hidden (unsatisfied 'exist_if').
Hint: try: jbuilder external-lib-deps --missing -p alcotest @install
esy-build-package: run ['sandbox-exec' '-f'

                   '/var/folders/ss/97gmv_jn031f29dsvb600f280000gn/T/2afe57'

                   '/Users/javi/.esy/3____________________________________________________________________/i/opam__slash__jbuilder-1.0.0-beta20-907a0beb/bin/jbuilder'
                        'build' '-p' 'alcotest' '-j' '4']: exited with 1
    at ChildProcess.<anonymous> (/Users/javi/.nvm/versions/node/v8.11.1/lib/node_modules/esy/bin/esy.js:39224:15)
    at emitTwo (events.js:126:13)

My package.json looks like:

  "dependencies": {
    "bs-typed-glamor": "github:glennsl/bs-typed-glamor",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "reason-react": ">=0.4.0",
    "vrroom": "github:glennsl/vrroom",
    "ppx_bs_css": "github:astrada/ppx_bs_css"
  },
  "devDependencies": {
    "bs-platform": "^3.1.5",
    "webpack": "^4.0.1",
    "webpack-cli": "^2.0.10",
    "ocaml": "~4.2.3000"
  },
  "peerDependencies": {
    "ocaml": "~4.2.3000"
  },
  "resolutions": {
    "@opam/gen": "0.5.0"
  }
jchavarri commented 6 years ago

oh wait, it works! i was doing some tests removing merlin from the dependencies and that made things go wrong. But now I can run esy bs-ppx-css and it seems to be finding the binary 🎉

Now I think I'm having a more general issue with my local installation of esy that prevents me to finalize the tests for the ppx. Every time I call esy <whatever> I get:

$ esy bs-ppx-css
/Users/javi/.nvm/versions/node/v8.11.1/bin/esy: line 273: /Users/javi/.esy/3____________________________________________________________________/i/ppx___bs___css-0.1.0-113e9c89/bin/bs-ppx-css: Argument list too long
$ esy which bs-ppx-css
/Users/javi/.nvm/versions/node/v8.11.1/bin/esy: line 273: /Users/javi/.config/yarn/global/node_modules/.bin/which: Argument list too long

@andreypopp Do you have any hint what might be going on? I've tried reinstalling esy globally, but the problem doesn't go away.

jchavarri commented 6 years ago

I realized esy was having issues only in the specific project where I was using the ppx, so I managed to track down the exact package giving problems. It's:

"webpack-cli": "^2.0.10",

If I remove that dependency, esy <command> starts working again.

I tried installing webpack-command which is similar to webpack-cli and I get the same error Argument list too long.

@andreypopp Let me know if you'd like me to open an issue in the esy repo or clarify repro steps.

Otherwise, the new build added in branch issue3 and the symlink trick work perfectly. Thanks to both of you for your help!

jchavarri commented 6 years ago

I created https://github.com/esy/esy/issues/203.