Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File "command line", line 1: Error: Unbound module Stdlib - OCaml version 4.11.1 #12854

Open
3 of 7 tasks
demosthenesk opened this issue Aug 27, 2022 · 4 comments
Open
3 of 7 tasks
Labels

Comments

@demosthenesk
Copy link

Description

I have just installed msys2 ocaml packages :
mingw32/mingw-w64-i686-ocaml 4.11.1-2 [installed]
mingw32/mingw-w64-i686-ocaml-compiler-libs 4.11.1-2 [installed]
mingw64/mingw-w64-x86_64-ocaml 4.11.1-2 [installed]
mingw64/mingw-w64-x86_64-ocaml-compiler-libs 4.11.1-2 [installed]

when i try to run from mingw64 or mingw32 the ocaml command i get the following error:
$ ocaml
OCaml version 4.11.1

File "command line", line 1:
Error: Unbound module Stdlib

Verification

Windows Version

Microsoft Windows [Version 10.0.22000.856]

MINGW environments affected

  • MINGW64
  • MINGW32
  • UCRT64
  • CLANG64
  • CLANG32
  • CLANGARM64

Expected behavior

to run ocaml without error

Actual behavior

$ ocaml
OCaml version 4.11.1

File "command line", line 1:
Error: Unbound module Stdlib

Repro steps

  1. Run MSYS2 MINGW32 or MSYS2 MINGW64
  2. Run command ocaml
  3. Get the error

Are you willing to submit a PR?

No response

@Biswa96
Copy link
Member

Biswa96 commented Aug 27, 2022

Thank you for reporting the issue. The mingw ocaml package is full of workarounds. I am thinking of updating the package and upstream the necessary changes. If things go well I will provide some news here.

@MehdiChinoune
Copy link
Collaborator

MehdiChinoune commented Aug 27, 2022

It looks like It is something related to permissions.
https://discuss.ocaml.org/t/unbound-module-stdllib/5133/14

After changing the permission of /mingw64/lib/ocaml/stdlib.cmi to 755

$ cd /mingw64/lib/ocaml
$ chmod 755 -v /mingw64/lib/ocaml/stdlib.cmi

ocaml runs but I couldn't get out (CTRL+C and CTRL+D don't work!).
The permissions reverts to 644 after I close the console!

@Biswa96
Copy link
Member

Biswa96 commented Aug 27, 2022

The issue seems to be related to path relocation. The workaround is to add the full ocaml standard library path with CAMLLIB or OCAMLLIB environment variable. This works in my case

$ CAMLLIB=$(cygpath -m $MINGW_PREFIX/lib/ocaml) ocaml

The logic can be found in caml_get_stdlib_location() function in runtime/dynlink.c file in ocaml repository. I thought about adding pathtools (like curl, openssl) in that function. But the function is used in different ocaml executable and libraries installed in different paths.

Is there any trick to add the variable when the package is installed (also undo it after uninstall) ?

@demosthenesk
Copy link
Author

In my home directory i created a Bin folder with a bash script with
CAMLLIB=/mingw64/lib/ocaml ocaml
and i run this with no problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants