HaxeFoundation / haxelib

The Haxe library manager
https://lib.haxe.org/
MIT License
172 stars 78 forks source link

Can you use local and global haxelib libraries together? #505

Open rb1147x opened 4 years ago

rb1147x commented 4 years ago

I've just discovered that you can have a local .haxelib folder with your libs. In my example below I'm trying to use:

2 libraries that are in my local .haxelib:

and 1 library that is in my global haxelib:

Without putting much thought into it I set up my hxml file as below. I guess I assumed that Haxe would be checking both locally and globally, but the below does not work, I'll receive an error - Error: Error: Cannot process [better-sqlite3]: Library better-sqlite3 is not installed : run 'haxelib install better-sqlite3' when I try to compile.

-main Main
-lib nodemailer
-lib node
-lib better-sqlite3
-js app.js

After some searching I came across this: https://lib.haxe.org/documentation/using-haxelib/#global and tried:

-main Main
-lib nodemailer
-lib node
--haxelib-global
-lib better-sqlite3
-js app.js

but, this doesn't work as now Haxe gives a similar error as above, but for my local libs. I'm not that surprised at this. The description on the haxelib doc page for 'global' says Force the usage of the global repository even if inside a local repository created with haxelib newrepo. and gives no indication that you can set specific libraries in your hxml as global. I may even be using this switch entirely incorrectly.

As an alternative solution, I know that I can just make all 3 libs local (or global), but that doesn't seem like the best solution? For example, if I'm building something with openfl or a large library, as a user, I don't want to be reinstalling it for every project, if I can avoid that.

So, can you use local and global libraries together and if yes, how? :)

Thanks.

Gama11 commented 4 years ago

You could haxelib dev a global lib locally.

rb1147x commented 4 years ago

Thanks, this works as a solution to my problem!

Is this the intended way to solve this problem or can/should there be a better, seamless experience when working with libs locally and globally in the same project?