Domanda

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.

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top