0

My question is similar to this post:

OCaml: Can't run utop after installing it

I try to open the core library, and end up with the same problem:

$ open Core.Std
Couldn't get a file descriptor referring to the console

I have tried the following command with correct quote mark:

eval `opam config env`

But nothing happens and the problem persists despite I have installed core. I also tried to follow installation instructions on this webpage (https://github.com/realworldocaml/book/wiki/Installation-Instructions), but it does not mention this strange problem.

I am using Ubuntu 24 in virtual machine by Hyper-V on windows 8. Another question I want to ask is many webpages like (http://kwangyulseo.com/2014/03/04/installing-ocamlopamutopcore-library-on-ubuntu-saucy/) suggested to compile certain lines of command in ".ocamlinit file". But I do not know where to find this file and how to modify it in linux. I have been an windows user for most of the time in my life.

Sorry if the question's level is too low.

Community
  • 1
  • 1
Bombyx mori
  • 288
  • 1
  • 3
  • 15

1 Answers1

2

Oh, man. open Core.Std is not a bash command. You need to open OCaml toplevel (i.e. to execute utop or ocaml) and execute this command there. Probably it is not written explicitly in manual. If you see

#use "topfind";;
#thread;;
#camlp4o;;
#require "core.top";;
#require "core.syntax";;

It means that you should enter (or add to .ocamlinit) this by hand. I mean that you should enter # too. So, if you will use ocaml you will see two #. It's normal.

About OCaml init file. As you see they refer to it as ~/.ocamlinit. Character ~ means home directory in POSIX systems. So you will probably need some GUI text editor (gedit or kwrite, for example), create new file, put content there ans save it you home directory. N.B. POSIX systems have no concept of file extension, i.e. leading dot is part of file name.

Kakadu
  • 2,837
  • 19
  • 29
  • Thank you - I need to try it out. Sorry for my low level. – Bombyx mori May 15 '14 at 11:44
  • No problem. Everybody was like you. I hope you will like GNU/Linux and will abandon Windows in some future. – Kakadu May 15 '14 at 11:46
  • I tried to execute this in ocaml. But I got a strange message which says "Unbound module Core". And if I try any Core commands (like Float.of_int) then it says "Unbound" again. – Bombyx mori May 15 '14 at 11:49
  • Start from `#use "ocamlfind"` and other lines. – Kakadu May 15 '14 at 11:53
  • The "ocamlfind" command still does not work, but I finally managed to load core successfully. Thanks! – Bombyx mori May 15 '14 at 12:00
  • I want to ask - where is the home directory in Ubuntu? I found the webpage asked me to put it in the top level, but my top level has an .opam folder. I could not find it anywhere. Should I just save it in my home folder? – Bombyx mori May 15 '14 at 12:08
  • Sorry I have to leave for a few hours, but thanks nevertheless! – Bombyx mori May 15 '14 at 12:10
  • in Ubuntu home directory is `/home/username` – Kakadu May 15 '14 at 12:17
  • It's highly recommended not to use SO comments for long sequences of miniquestions. See you at OCaml mail-list or #ocaml on Freenode IRC server. Also you can mark question as resolved. – Kakadu May 16 '14 at 15:54