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

ocaml should add script's directory to search path, not current directory #6081

vicuna opened this issue Jul 19, 2013 · 3 comments


None yet
1 participant
Copy link

commented Jul 19, 2013

Original bug ID: 6081
Reporter: talex
Status: closed (set by @damiendoligez on 2015-01-16T22:45:14Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.00.1
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: ~DO NOT USE (was: OCaml general)
Tags: patch
Parent of: #7347
Monitored by: @gasche @hcarty

Bug description

When running "ocaml /path/to/", OCaml searches the current directory first for libraries. This is probably not useful, and can be a security risk. It would make more sense to add the script's directory to the search path instead, as e.g. Python does.

Steps to reproduce

$ cat /usr/local/bin/show_home
#load "unix.cma";;
print_endline (Unix.getenv "HOME")

$ touch /tmp/unix.cma

$ cd /
$ show_home

$ cd /tmp
$ show_home
Fatal error: exception End_of_file

Additional information

My attempt at a patch is here:


gasche asked me to report this here:

File attachments


This comment has been minimized.

Copy link

commented Aug 19, 2013

Comment author: @damiendoligez

Makes sense, but I don't think it has anything to do with the runtime system.


This comment has been minimized.

Copy link

commented Jan 17, 2014

Comment author: @damiendoligez

Got the patch from github and uploaded it here.

(hint: just add ".patch" to github's commit URL to get the raw patch file)


This comment has been minimized.

Copy link

commented Jan 16, 2015

Comment author: @damiendoligez

Patch adapted and applied to trunk (rev 15779).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.