|Anonymous | Login | Signup for a new account||2015-02-27 23:43 CET|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0005699||OCaml||OCaml general||public||2012-07-25 17:37||2013-12-05 16:07|
|Target Version||Fixed in Version|
|Summary||0005699: It would be nice to be able to set up OCAMLINIT root directory|
|Description||Currently, .ocamlinit is searched only in the current path and in $HOME. It would be nice to look in $OCAMLINIT as well.|
This would help packaging tools to set-up an appropriate user environment to run the toplevel.
|Attached Files||OCAMLINIT.diff [^] (947 bytes) 2012-07-25 17:37 [Show Content]|
The background to this request is for the OPAM package manager. It can switch installed compiler versions and maintains them in ~/.opam/<compiler>, along with a per-compiler ocamlfind and libraries. OPAM also has a special "system" compiler which uses any installed version of OCaml, and only installs its own ocamlfind in this case.
Compilers are switched by exporting variables to the local shell, much like ssh-agent (using "opam config -env", see https://github.com/OCamlPro/opam/issues/47 [^] for a few examples). OPAM currently sets the PATH to point to the local ocamlfind and CAML_LD_LIBRARY_PATH for stublibs.
The combination of a system OCaml and OPAM would be helped by this patch, as it would permit the package manager to override the interactive top-level in the same way.
I am wondering if the .ocamlinit file pointed to by $HOME or $OCAMLINIT is the same as for ./.ocamlinit : ./.ocamlinit is supposed to load values for the current project, whereas $HOME/.ocamlinit or $OCAMLINIT is more a user configuration. So, shouldn't both files be loaded, instead of just the first one found ?
@avsm: how does OPAM use OCAMLINIT exactly ? I don't really understand why you need that.
The patch looks quite useful. I think the need is that our mechanism to load the configuration is not extensible i.e. the .ocamlinit will be always loaded if we don't even want it, and if we want to load different configuration and (possibly) load the other one, one could do it with custom .ocamlinit. The other way round it would be to specify init file via. -init option in the ocaml comandline, but currently no way to cleanly disable loading completely.
Notes about the patch:
* should OCAMLINIT point to a directory or to a file? First would allow to load different file from a collection of files in the same directory. I think maybe providing *both* would be useful - check if it's an existing file otherwise do the same as now.
* should we allows several paths in OCAMLINIT, colon separated?
* I'm not sure how secure is to provide this override - e.g. if something sets OCAMLINIT to some malicious piece of code, but that's perhaps a separate consideration as always something can create/add code Caml code to .ocamlinit
* the documentation (e.g. man pages) would need to be updated too reflecting changes
Why not read all *.ml files from $OCAMLLIB/site_ocaml/ and $HOME/.ocaml/, or $OCAMLINIT/ at "ocaml" startup ? And then, afterwards, read .ocamlinit from the local directory ?
And also add OCAMLPATH for include directories ?
Also, wouldn't it help to transform some toplevel directives into functions that can easily be called from these files ?
The problem when you have multiple files to load is that the order is important, and loading a full directory can lead to random effects depending on the loading order (which is bad).
I guess the most important thing to have a way to be able to choose which .ocamlinit to load, which is not possible at the moment. From there, the .ocamlinit file can itself load some files in a directory by reading the content of another variable and doing some clever tricks to keep a consistent loading order, but that's a different concern.
Obtaining a consistent loading order can be enforced via a lexical convention on the names of the files (i.e. 10-foo, 20-bar, etc.), just like rc scripts on UNIX do.
For package managers like OPAM, we don't want to modify any files outside of the package manager area if at all possible, and so specifying an alternative location for ~/.ocamlinit would be very useful.
|2012-07-25 17:37||tgazagna||New Issue|
|2012-07-25 17:37||tgazagna||File Added: OCAMLINIT.diff|
|2012-07-25 17:45||avsm||Note Added: 0007809|
|2012-07-25 22:02||lefessan||Severity||minor => feature|
|2012-07-25 22:09||lefessan||Note Added: 0007810|
|2012-07-26 02:09||meyer||Note Added: 0007811|
|2012-07-26 18:42||lefessan||Note Added: 0007813|
|2012-07-26 18:43||lefessan||Assigned To||=> lefessan|
|2012-07-26 18:43||lefessan||Status||new => feedback|
|2012-07-27 01:24||tgazagna||Note Added: 0007819|
|2012-07-27 01:24||tgazagna||Status||feedback => assigned|
|2012-07-31 15:42||lefessan||Assigned To||lefessan =>|
|2012-08-06 18:32||xleroy||Status||assigned => acknowledged|
|2012-08-08 13:04||lefessan||Relationship added||child of 0005723|
|2012-08-08 13:04||lefessan||Relationship deleted||child of 0005723|
|2012-08-08 13:05||lefessan||Relationship added||related to 0005723|
|2012-10-24 02:43||avsm||Note Added: 0008317|
|2013-12-05 16:07||doligez||Assigned To||=> doligez|
|2013-12-05 16:07||doligez||Status||acknowledged => confirmed|
|2013-12-05 16:07||doligez||Assigned To||doligez =>|
|2013-12-05 16:07||doligez||Tag Attached: patch|
|Copyright © 2000 - 2011 MantisBT Group|