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

Some relative symlinks seem not to be followed #6498

Closed
vicuna opened this issue Jul 25, 2014 · 3 comments
Closed

Some relative symlinks seem not to be followed #6498

vicuna opened this issue Jul 25, 2014 · 3 comments

Comments

@vicuna
Copy link

vicuna commented Jul 25, 2014

Original bug ID: 6498
Reporter: maro
Status: closed (set by @damiendoligez on 2015-03-27T21:33:58Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.01.0
Target version: 4.02.2+dev / +rc1
Fixed in version: 4.02.2+dev / +rc1
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues
Related to: #5395
Monitored by: @gasche

Bug description

Relative symbolic links for directories with "../../" in their paths do not seem to be correctly followed.

I had the issue arrive in a large project, and I tried to reproduce it in a smaller directory structure (attached).

In the folder containing the extracted paths, when trying to compile b.ml with the following command:

ocamlbuild -I dir1/dir2 -I dir1/dir4/dir3 b.native

I obtain the following error message:

File "b.ml", line 2, characters 0-6:
Error: Unbound module C
Command exited with code 2.

I expected module C to be found since it is present in directory dir3.

If I run instead this command:

ocamlbuild -I dir1/dir2 -I dir1/dir4/dir5 b.native

Then compilation succeeds, as expected.

The difference between them, if I'm not mistaken, is that dir3 is a symbolic link to a directory which contains "../../" (two occurrences of "..") in its path, while dir5 is a standard directory containing a symbolic link to a file. Though this symbolic link also contains "../../" in its path, it still works.

Note that a single "../" is not an issue, as exemplified by the dir2 directory. Symlinks to directories containing 3 or more ".." also seem to trigger the issue.

Steps to reproduce

Uncompress the contents of the attached tar.gz file and run:

ocamlbuild -I dir1/dir2 -I dir1/dir4/dir3 b.native

ocamlbuild -I dir1/dir2 -I dir1/dir4/dir5 b.native

The first line should succeed but fails, while the second one succeeds.

File attachments

@vicuna
Copy link
Author

vicuna commented Jul 28, 2014

Comment author: maro

I did some more tests, and the "../.." does not seem to be the problem (it does work in some cases), but the issue seems related to:

  1. using an include with nested directories (e.g. -I dir1/dir2);
  2. using a relative symbolic link for a directory.

I still couldn't find the exact situations where these work and where they don't, but it seems I have to combine both to obtain an error.

It would seem that in some cases the relative path is interpreted with respect to the directory from where ocamlbuild is run, instead of the directory containing the relative symbolic link. For instance, the following example code seems to trigger the issue on my machine:

echo "open B" > a.ml
mkdir d1
mkdir d1/d2
touch d1/d2/b.ml
ln -s d2 d1/d3
ocamlbuild -I d1/d2 a.native # works
ocamlbuild -I d1/d3 a.native # unbound module B

@vicuna
Copy link
Author

vicuna commented Jul 30, 2014

Comment author: @damiendoligez

The problem seems to be that ocamlbuild reproduces the structure of the source directory under _build, but fails to reproduce the symlinks.

@vicuna
Copy link
Author

vicuna commented Mar 27, 2015

Comment author: @damiendoligez

This is fixed by the fix for #5395 (branch 4.02, rev 15970).

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

No branches or pull requests

1 participant