Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005534OCamlOCaml windowspublic2012-03-13 06:002013-08-31 12:48
Reporteradamgolding 
Assigned Toprotz 
PriorityhighSeveritymajorReproducibilityN/A
StatusclosedResolutionfixed 
PlatformPCOSWindowsOS Version7 Ultimate
Product Version 
Target VersionFixed in Version 
Summary0005534: Installer Obliterates PATH variable
DescriptionAfter installing OCaml, some pieces of software on my computer would not run because they could not find java--upon inspecting my PATH variable, I found that the only entries present were OCaml entries! It appears OCaml replaces, rather than appends to, the path.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0007053)
gasche (developer)
2012-03-13 06:25
edited on: 2012-03-13 06:28

Please make precise which OCaml installer you used, for example by giving an URL to the installer; they are several different ways to install OCaml for windows.

As you will guess this is a bug in your specific installer script -- no, the OCaml compiler does not eat your PATH for breakfast.

Did you use the new Windows installer by Jonathan Protzenko?
  http://protz.github.com/ocaml-installer/ [^]
There is a related known bug for this installer ( https://github.com/protz/ocaml-installer/issues/1 [^] ).

(0007063)
adamgolding (reporter)
2012-03-14 07:08

I'm not sure which URL I used, but the file is this:

ocaml-3.12.1-mingw32

at any rate, I'm about to switch to the cygwin version
(0007065)
gasche (developer)
2012-03-14 09:09

So I think you probably have the installer mentioned above -- strange that you don't remember the blink on the webpage! The problem comes from the Windows installer used (NSIS, I think), not from OCaml itself: the installer has a hard limit on the PATH length and simply empty it when it's too long.

Jonathan is investigating the issue. If anybody know a good (*reliable*) Windows installer that doesn't have this issue, suggestions are welcome.

Thanks for the bug report.
(0007066)
protz (manager)
2012-03-14 09:13

Yes so just for future reference, it turns out the installer generator that I'm using (namely, NSIS) has a stupid, hardcoded limit on the length of strings it can manipulate. So when the installer tries to prepend the path the the OCaml bin directory to the PATH env variable, if the PATH is already more than 1k long, it simply blasts the value of the PATH variable.

I'm unsure what's the right thing to do here. NSIS does provide very convenient wrappers for i) not appending the path if it's already in the PATH, ii) removing the right path from PATH at uninstall-time, and so on. Duplicating everything in one self-contained C program just because the generated installer can't deal with long strings seems silly, to say the least.
(0007128)
protz (manager)
2012-03-22 09:58

So what I'm about to do (following a suggestion from Alain) is have the installer generate .bat files that do the PATH thingy, then launch ocaml in a shell, or emacs. That way, we won't have these "minor annoyances".

Any objections?
(0007129)
ygrek (reporter)
2012-03-22 14:12

Why not use special nsis build (with 8192 chars limitation?). Also it should be possible to call windows api directly from the plugin dll (more work..). Or maybe check that new PATH will be less than 1024 and set it only in such case, otherwise warn user to launch ocaml via bat file (and interested users will be able to set the environment manually looking at bat file).
(0007130)
protz (manager)
2012-03-22 14:25

So yes I'm aware of the other NSIS build, but you're not really solving the problem, just making it harder to happen.

I'll try to see if I can check for the length of the PATH before overriding it, so that I can warn the user that they need to add the path to ocaml to their PATH by themselves. The problem seems to happen pretty frequently though.

The rationale for using .bat files is as follows:
- either the user is serious, and they're using msys/cygwin already, so they know how to add something to their PATH
- otherwise, they'll just use the .bat files.
(0007131)
protz (manager)
2012-03-22 14:45

http://trac.haskell.org/haskell-platform/ticket/25 [^] has some interesting insights (apparently the maximum length of an env variable on windows is 8192)
(0007139)
frisch (developer)
2012-03-23 17:57

I strongly support the fact that the OCaml installer does not touch environment variables (PATH or OCAMLLIB). In addition to installing .bat files to start ocaml (the toplevel) and emacs (with proper PATH), it would be good to have one which runs a windows shell cmd.exe.
(0007140)
protz (manager)
2012-03-23 19:11

Well I discussed this with Xavier and we didn't have much opinions in favor of one way or another; .bat files add some burden, I'm not sure I can hide the command-line window that appears (although some answers on stack overflow seem to indicate that I can), and this means that I need to write wrappers for emacs (because there are shell associations with .ml and .mli files that the installer creates) that forward the arguments. Xavier also mentioned that passing the arguments through cmd.exe makes cmd.exe reparse them, which might no be a good idea. At that point, I was really unsure what the best move is.

Xavier, anything you want to add?
(0007141)
frisch (developer)
2012-03-23 19:29

> Xavier also mentioned that passing the arguments through cmd.exe makes cmd.exe reparse them, which might no be a good idea.

We are talking of a single argument, the file name to open (when the user double-click on an .ml/.mli file in the explorer), right?
(0007149)
xleroy (administrator)
2012-03-24 14:54

> We are talking of a single argument, the file name to open

All right, but even so, this single argument could contain spaces or other special characters, and who knows what cmd.exe will do with them. .bat files are always a problem, never a solution.
(0007160)
Bardou (reporter)
2012-03-26 12:04

If you embed the binaries in .bat files, won't we need to add the .bat files to the PATH anyway? To call them from the MinGW shell, for instance.
(0007162)
protz (manager)
2012-03-26 13:59

The whole point of adding .bat files is that the .bat files take care of exporting the right PATH, *then* launching ocaml. If the user is a power user, they know for sure how to add a directory to their path (using .bashrc, for instance), and then they'll call ocaml directly.

It looks like I'll be able to tweak the PATH correctly in the next iteration of the installer, I just need a few more days to make sure it works fine.
(0007224)
protz (manager)
2012-03-29 10:40

The latest version of the installer (http://yquem.inria.fr/~protzenk/caml-installer/ocaml-4.01.0+dev0-i686-mingw64.exe [^]) is now able to deal with PATHs that are up to 8192 bytes long. In case the PATH is already longer than that, it will not delete it.

I finally didn't go with the .bat files solution.

- Issue History
Date Modified Username Field Change
2012-03-13 06:00 adamgolding New Issue
2012-03-13 06:25 gasche Note Added: 0007053
2012-03-13 06:27 gasche Assigned To => gasche
2012-03-13 06:27 gasche Status new => feedback
2012-03-13 06:28 gasche Note Edited: 0007053 View Revisions
2012-03-13 20:24 gasche Assigned To gasche =>
2012-03-14 07:08 adamgolding Note Added: 0007063
2012-03-14 07:08 adamgolding Status feedback => new
2012-03-14 09:09 gasche Note Added: 0007065
2012-03-14 09:10 gasche Assigned To => protz
2012-03-14 09:10 gasche Status new => confirmed
2012-03-14 09:13 protz Note Added: 0007066
2012-03-22 09:58 protz Note Added: 0007128
2012-03-22 14:12 ygrek Note Added: 0007129
2012-03-22 14:25 protz Note Added: 0007130
2012-03-22 14:45 protz Note Added: 0007131
2012-03-23 17:57 frisch Note Added: 0007139
2012-03-23 19:11 protz Note Added: 0007140
2012-03-23 19:29 frisch Note Added: 0007141
2012-03-24 14:54 xleroy Note Added: 0007149
2012-03-26 12:04 Bardou Note Added: 0007160
2012-03-26 13:59 protz Note Added: 0007162
2012-03-29 10:40 protz Note Added: 0007224
2012-03-29 10:40 protz Status confirmed => resolved
2012-03-29 10:40 protz Resolution open => fixed
2013-08-31 12:48 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker