Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007347OCaml~DO NOT USE (was: OCaml general)public2016-09-08 19:382017-02-18 16:13
Reportersebmondet 
Assigned To 
PrioritynormalSeveritytextReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.03.0 
Target Version4.05.0 +dev/beta1/beta2/beta3/rc1Fixed in Version4.05.0 +dev/beta1/beta2/beta3/rc1 
Summary0007347: Toplevel #use with relative paths have different behavior between 4.02.3 and 4.03.0
DescriptionSince 4.03.0, the `#use` directive seems to treat "file.ml" and "./file.ml" differently:

- the "file.ml" one seems to be relative to the script.
- the "./file.ml" one seems to be relative to the current-directory of the `ocaml` process.

(Doesn't seem to be in the changelog: https://github.com/ocaml/ocaml/blob/bf6261c2b7058a2ac2c471839d48acb1c77c22fd/Changes#L841 [^])


Steps To Reproduceexample/ex.ml:
```
#use "same_dir.ml"

#use "./dot_slash.ml"


let () = Printf.printf "%s, %s\n%!" Same_dir.(hello ()) Dot_slash.(hello ())
```

example/same_dir.ml
```
module Same_dir = struct let hello () = "same-dir" end
```

example/dot_slash.ml:
```
module Dot_slash = struct let hello () = "dot-slash" end
```


### With 4.02.0

 $ ocaml -version
The OCaml toplevel, version 4.02.3
 $ ocaml example/ex.ml
Cannot find file same_dir.ml.
Cannot find file ./dot_slash.ml.
File "example/ex.ml", line 7, characters 36-44:
Error: Unbound module Same_dir
 $ cd example/ ; ocaml ex.ml
same-dir, dot-slash

### With 4.03.0

It finds `same_dir.ml`.

 $ ocaml -version
The OCaml toplevel, version 4.03.0
 $ ocaml example/ex.ml
Cannot find file ./dot_slash.ml.
File "./example/ex.ml", line 7, characters 56-65:
Error: Unbound module Dot_slash
 $ cd example/ ; ocaml ex.ml
same-dir, dot-slash


TagsNo tags attached.
Attached Files

- Relationships
child of 0006081closed ocaml should add script's directory to search path, not current directory 

-  Notes
(0016334)
doligez (administrator)
2016-09-27 16:35
edited on: 2016-09-27 16:35

That's 0006081 and it is in the change log for 4.03.0.

Do you want to argue that we should revert it? I think the new behaviour is much better for scripts.

(0016335)
sebmondet (reporter)
2016-09-27 16:43

I don't know :)
It was just a surprising way of breaking a script I had running on TravisCI.

At least, having "file.ml" and "./file.ml" have the same behavior and/or documenting it would be nice?
(0016337)
doligez (administrator)
2016-09-27 17:12

We'll document it, but really it is the standard behaviour for the compilers: if you say "file.cma" it looks in the library path, and if you say "./file.cma" it looks in the current directory. In fact, the shell does the same for commands.
(0017328)
xleroy (administrator)
2017-02-18 16:13

Documentation added in manual, chapter "Toplevel", version 4.05 and up.

- Issue History
Date Modified Username Field Change
2016-09-08 19:38 sebmondet New Issue
2016-09-27 16:33 doligez Relationship added child of 0006081
2016-09-27 16:35 doligez Note Added: 0016334
2016-09-27 16:35 doligez Status new => feedback
2016-09-27 16:35 doligez Target Version => 4.05.0 +dev/beta1/beta2/beta3/rc1
2016-09-27 16:35 doligez Description Updated View Revisions
2016-09-27 16:35 doligez Steps to Reproduce Updated View Revisions
2016-09-27 16:35 doligez Note Edited: 0016334 View Revisions
2016-09-27 16:43 sebmondet Note Added: 0016335
2016-09-27 16:43 sebmondet Status feedback => new
2016-09-27 17:12 doligez Note Added: 0016337
2016-09-27 17:12 doligez Status new => confirmed
2016-12-07 16:37 doligez Category OCaml tools (ocaml{lex,yacc,dep,browser,debug}) => OCaml tools (ocaml{lex,yacc,dep,debug})
2016-12-09 08:49 shinwell Category OCaml tools (ocaml{lex,yacc,dep,debug}) => OCaml general
2017-02-18 16:13 xleroy Note Added: 0017328
2017-02-18 16:13 xleroy Severity minor => text
2017-02-18 16:13 xleroy Status confirmed => resolved
2017-02-18 16:13 xleroy Resolution open => fixed
2017-02-18 16:13 xleroy Fixed in Version => 4.05.0 +dev/beta1/beta2/beta3/rc1
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker