EDIT:把这个留在这里,因为其他人肯定会有同样的问题,但根本原因是ubuntu包是一个非常旧的haxe版本。我卸载了它,从源代码安装,一切正常
我已经在我的ubuntu系统上全局安装了haxe,并以用户身份设置了haxelib,安装路径为/home/mdemello/opt/share/haxe/lib
haxelib似乎可以工作,除了一个安装后错误:
$ 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
但是通过-lib使用安装的库失败;我必须使用-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
编辑:以下是使用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
我注意到它从-lib添加的类路径是/home/mdemello/opt/share/haxe/lib/csv/0,4,0/
,而我必须通过-cp手动添加的类路径是/home/mdemello/opt/share/haxe/lib/csv/0,4,0/lib
EDIT:看起来ubuntu(3.0.0)上默认的haxelib不支持csv包中的classPath指令。下面的解决方法仍然有效,但不应该这样做。更新haxe
看起来像是CSV包目录结构的问题。我通过从lib/format -> format
添加以下符号链接来修复它:
csv
└── 0,4,0
├── format -> lib/format/ <--- symlink added
├── lib
│ └── format
│ └── csv
└── test