ubuntuclasspathhaxehaxelib

haxe cannot find csv library installed by haxelib


EDIT: Leaving this up because other people are bound to have the same issue, but the root cause was that the ubuntu package was a very old version of haxe. I uninstalled that and installed from source instead, and everything just works


I have installed haxe globally on my ubuntu system, and set up haxelib as user, with install path /home/mdemello/opt/share/haxe/lib

haxelib appears to work, except for a post-install error:

$ haxelib install csv
Downloading csv-0,4,0.zip...
Download complete : 10518 bytes in 4.3s (2.3KB/s)
  Install CHANGES.txt
  Install haxelib.json
  Created lib/
  Install LICENSE.txt
  Install README.md
  Created test/
  Install test.hxml
  Created lib/format/
  Created lib/format/csv/
  Install lib/format/csv/Reader.hx
  Install lib/format/csv/Utf8Reader.hx
  Install lib/format/csv/Data.hx
  Install test/Test.hx
  Current version is now 0.4.0
Done
Invalid field access : index

but using the installed library via -lib fails; I have to specify the full path using -cp:

$ head CSV.hx
import format.csv.Reader;

$ haxe -lib csv -x CSV.hx
./CSV.hx:1: characters 7-24 : Class not found : format.csv.Reader

$ haxelib path csv
/home/mdemello/opt/share/haxe/lib/csv/0,4,0/
-D csv

$ haxe -cp /home/mdemello/opt/share/haxe/lib/csv/0,4,0/lib/ -x CSV.hx
# works

edit: here's the output when running with haxe -v:

$ haxe -v -lib csv -x CSV.hx
Classpath : /home/mdemello/opt/share/haxe/lib/csv/0,4,0/;./;/usr/share/haxe/std/neko/_std/;/usr/share/haxe/std/
Defines : true;sys;neko;haxe_ver;haxe_release;haxe3;dce;csv
Parsed /usr/share/haxe/std/StdTypes.hx
Parsed /usr/share/haxe/std/neko/_std/String.hx
Parsed /usr/share/haxe/std/neko/_std/Array.hx
Parsed /usr/share/haxe/std/haxe/EnumTools.hx
Parsed /usr/share/haxe/std/neko/_std/Std.hx
Parsed ./CSV.hx
./CSV.hx:1: characters 7-24 : Class not found : format.csv.Reader

I note that the classpath it added from -lib was /home/mdemello/opt/share/haxe/lib/csv/0,4,0/ whereas the one I had to add manually via -cp was /home/mdemello/opt/share/haxe/lib/csv/0,4,0/lib


Solution

  • EDIT: It looks like the default haxelib on ubuntu (3.0.0) is not honouring the classPath directive in the csv package. The workaround below still works but it shouldn't need to be done. Update haxe instead.


    looks like an issue with the csv package directory structure. i fixed it by adding the following symlink from lib/format -> format:

    csv
    └── 0,4,0
        ├── format -> lib/format/  <--- symlink added
        ├── lib
        │   └── format
        │       └── csv
        └── test