OcalIDE doesn't find library path

General discussion about OcaIDE

OcalIDE doesn't find library path

Postby borish » Tue Aug 11, 2009 10:10 pm

Hello,

I use OcaIDE 1.1 on FreeBSD 7.2 with Eclipse 3.4 (Ganymede) and OCaml 3.11.

Ocaml binaries are installed in /usr/local/bin, library in /usr/local/lib/ocaml.

My problems:
- OcaIDE does not detect these paths.
- After I set the paths manually, OcaIDE complains that the library path is wrong. The error log shows lots of error messages (see below) if I type "List." or Ctrl-Space.

With OcaIDE 1.2.5, I have the same problems. I also get some more warnings about the library path.

The Ocaml browser however works and gives me description of library modules.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Errors for 1.1:

eclipse.buildId=M20080911-1700
java.version=1.6.0_07
java.vendor=The FreeBSD Foundation
BootLoader constants: OS=freebsd, ARCH=x86, WS=gtk, NL=en
Command-line arguments: -os freebsd -ws gtk -arch x86


Error
Tue Aug 11 23:15:10 CEST 2009
Error trying relative path in completion job

java.lang.IllegalArgumentException: Path must include project and resource name: /test1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Error
Tue Aug 11 23:00:40 CEST 2009
Wrong path: (in project:test1)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Error
Tue Aug 11 22:48:43 CEST 2009
/icons/caml32.gif

java.io.FileNotFoundException: /icons/caml32.gif

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Only for 1.2.5:

Warning
Tue Aug 11 23:28:19 CEST 2009
Parsing of mli files aborted : directory not found

The following paths are not correctly set:ocaml library directory

Please set them in Window>Preferences>Ocaml>Paths.
borish
 
Posts: 8
Joined: Tue Aug 11, 2009 8:44 pm

Re: OcalIDE doesn't find library path

Postby nicolas » Wed Aug 12, 2009 6:56 am

Parsing of mli files aborted : directory not found

This message should only appear if the O'Caml library directory specified in the preferences does not exist or is not a directory.
I never used FreeBSD, maybe it handles paths differently?
nicolas
Site Admin
 
Posts: 169
Joined: Sun Jul 22, 2007 10:00 am
Location: France

Re: OcalIDE doesn't find library path

Postby borish » Wed Aug 12, 2009 9:27 am

Hello Nicolas,

the *.mli files are in /usr/local/lib/ocaml/. All Ocaml library files are in this directory. FreeBSD uses ldconfig to handle libraries. Does OcaIDE call a tool or read an environment variable to determine paths and handle libraries?

Some outputs on my system:

~% ldconfig -r
/var/run/ld-elf.so.hints:
search directories: /lib:/usr/lib:/usr/lib/compat:/usr/local/lib:/usr/local/lib/nss:/usr/local/lib/zsh
0:-lc.7 => /lib/libc.so.7
1:-lcrypt.4 => /lib/libcrypt.so.4
2:-lkvm.4 => /lib/libkvm.so.4
...

~% echo $LD_LIBRARY_PATH

~%
borish
 
Posts: 8
Joined: Tue Aug 11, 2009 8:44 pm

Re: OcalIDE doesn't find library path

Postby nicolas » Wed Aug 12, 2009 12:42 pm

Does OcaIDE call a tool or read an environment variable to determine paths and handle libraries?

When OcaIDE initializes paths, it tries common paths, and if that fails tries with the "which" command on Linux.
But if that fails, you can still enter the paths by hand in the preferences, and that should work.
Could you try adding or removing the last "/" in "/usr/local/lib/ocaml/"? Maybe the path is interpreted in a different way depending on this.
nicolas
Site Admin
 
Posts: 169
Joined: Sun Jul 22, 2007 10:00 am
Location: France

Re: OcalIDE doesn't find library path

Postby borish » Wed Aug 12, 2009 9:20 pm

Could you try adding or removing the last "/" in "/usr/local/lib/ocaml/"? Maybe the path is interpreted in a different way depending on this.


No, this doesn't make any difference. Neither with 1.1.0 nor with 1.2.5.

When OcaIDE initializes paths, it tries common paths, and if that fails tries with the "which" command on Linux.


I wonder why OcalIDE didn't find the paths automatically. "which" gives the paths for the executables:

~% which ocaml
/usr/local/bin/ocaml
~% which ocamlc
/usr/local/bin/ocamlc

I use zsh, but this also works for bash and sh. "which" however doesn't give library paths. How does OcalIDE determine these?

Does OcalIDE make any assumptions that are true on Linux only?

I've removed ~/.eclipse, my workbench and started Eclipse again with OcalIDE 1.1.0. I've attached the logfile [1]. Then I added the paths manually and entered "List." and hit Ctl-Space. The resulting logfile is [2]. (Uploading these as attachments produced an error message "The extension is not allowed.")

(at (org|eclipse).* parts removed from logs)
[1]
!SESSION 2009-08-12 23:03:25.083 -----------------------------------------------
eclipse.buildId=M20080911-1700
java.version=1.6.0_07
java.vendor=The FreeBSD Foundation
BootLoader constants: OS=freebsd, ARCH=x86, WS=gtk, NL=en
Command-line arguments: -os freebsd -ws gtk -arch x86

!ENTRY ocaml 4 0 2009-08-12 23:04:24.115
!MESSAGE ocamlbuild path is not configured

!ENTRY ocaml 4 0 2009-08-12 23:05:34.346
!MESSAGE ocamlbuild path is not configured

!ENTRY ocaml 2 0 2009-08-12 23:05:36.019
!MESSAGE Parsing of mli files aborted : directory not found

!ENTRY ocaml 2 0 2009-08-12 23:05:43.405
!MESSAGE The following paths are not correctly set:
ocamlc (ocaml compiler)
ocaml library directory
ocaml (toplevel)
ocamldep (ocaml dependencies generator)
ocamlopt (ocaml native code compiler)
ocamllex (ocaml lexer generator)
ocamlyacc (ocaml parser generator)
ocamldoc (ocaml documentation generator)
camlp4 (ocaml preprocessor-pretty printer)

Please set them in Window>Preferences>Ocaml>Paths.

!ENTRY org.eclipse.jface 4 0 2009-08-12 23:05:43.655
!MESSAGE /icons/caml32.gif
!STACK 0
java.io.FileNotFoundException: /icons/caml32.gif



[2]
!SESSION 2009-08-12 23:10:04.934 -----------------------------------------------
eclipse.buildId=M20080911-1700
java.version=1.6.0_07
java.vendor=The FreeBSD Foundation
BootLoader constants: OS=freebsd, ARCH=x86, WS=gtk, NL=en
Command-line arguments: -os freebsd -ws gtk -arch x86

!ENTRY org.eclipse.jface 4 0 2009-08-12 23:10:16.882
!MESSAGE /icons/caml32.gif
!STACK 0
java.io.FileNotFoundException: /icons/caml32.gif

!ENTRY ocaml 4 0 2009-08-12 23:10:30.604
!MESSAGE Error trying relative path in completion job
!STACK 0
java.lang.IllegalArgumentException: Path must include project and resource name: /a

!ENTRY ocaml 4 0 2009-08-12 23:10:30.608
!MESSAGE Wrong path: (in project:a)

!ENTRY ocaml 4 0 2009-08-12 23:10:36.571
!MESSAGE Error trying relative path in completion job
!STACK 0
java.lang.IllegalArgumentException: Path must include project and resource name: /a

!ENTRY ocaml 4 0 2009-08-12 23:10:36.574
!MESSAGE Wrong path: (in project:a)
borish
 
Posts: 8
Joined: Tue Aug 11, 2009 8:44 pm

Re: OcalIDE doesn't find library path

Postby borish » Thu Aug 13, 2009 8:53 am

I found this in OcamlPlugin.java:

public static boolean runningOnLinuxCompatibleSystem() {
String os = Platform.getOS();
return (os.equals(Platform.OS_LINUX) || os.equals(Platform.OS_MACOSX));
}

This may be the root of the problem. All BSDs (FreeBSD, NetBSD, OpenBSD) are very similar to Linux (even more than OSX), but it don't know what Platform.getOS() returns on FreeBSD. It may return Platform.OS_FREEBSD. I'll discuss this on the FreeBSD-Eclipse mailing list.
borish
 
Posts: 8
Joined: Tue Aug 11, 2009 8:44 pm

Re: OcalIDE doesn't find library path

Postby borish » Thu Aug 13, 2009 4:48 pm

Ok, everything seems to work now after I've replaced

Code: Select all
public static boolean runningOnLinuxCompatibleSystem() {
String os = Platform.getOS();
return (os.equals(Platform.OS_LINUX) || os.equals(Platform.OS_MACOSX));
}


with

Code: Select all
public static boolean runningOnLinuxCompatibleSystem() {
String os = Platform.getOS();
return (os.equals(Platform.OS_LINUX) || os.equals(Platform.OS_MACOSX) || os.equals(Platform.OS_FREEBSD));
}
borish
 
Posts: 8
Joined: Tue Aug 11, 2009 8:44 pm

Re: OcalIDE doesn't find library path

Postby nicolas » Tue Aug 25, 2009 6:52 am

Thank you for investigating this problem.
Actually,
Code: Select all
Platform.OS_FREEBSD
cannot be used directly, since it is only defined in the FreeBSD version of Eclipse.
The following is more likely to work on all platforms, but I cannot test it on FreeBSD. Could you confirm that it works as intended?
Code: Select all
public static String freeBSDPlatformString = null;

public static String getFreeBSDPlatformString() {
   if (freeBSDPlatformString == null) {
      try {
         Field field = Platform.class.getField("OS_FREEBSD");
         return (String) field.get(null);
      } catch (Exception e) {
         // ignore
      }
      freeBSDPlatformString = "freebsd";
   }
   return freeBSDPlatformString;
}

/** @return true if the system is compatible with linux (that is: Linux, Mac OS X or FreeBSD) */
public static boolean runningOnLinuxCompatibleSystem() {
   String os = Platform.getOS();
   return (os.equals(Platform.OS_LINUX) || os.equals(Platform.OS_MACOSX) || os
         .equals(getFreeBSDPlatformString()));
}
nicolas
Site Admin
 
Posts: 169
Joined: Sun Jul 22, 2007 10:00 am
Location: France

Re: OcalIDE doesn't find library path

Postby borish » Tue Oct 13, 2009 6:35 pm

Hello Nicolas,

sorry for the late reply.

Your code works on FreeBSD if java.lang.reflect.Field is imported. However, there's also NetBSD, OpenBSD, DragonFlyBSD, AIX, QNX, HP-UX, Solaris, and possibly some other Unixes. If you look at the Platform class you see there's Windows, various brands of Unix, and unknown. Therefore, this should work on most systems:

Code: Select all
public static boolean runningOnLinuxCompatibleSystem() {
    String os = Platform.getOS();
    return !(os.equals(Platform.OS_WIN32));
}
borish
 
Posts: 8
Joined: Tue Aug 11, 2009 8:44 pm


Return to Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron