hamler icon indicating copy to clipboard operation
hamler copied to clipboard

Set custom lib directory - Creation of asdf-hamler

Open scudelletti opened this issue 4 years ago • 8 comments

Hello,

I've created a recipe for the asdf version manager as you can find here.

ASDF would allow us to use multiple versions of hamler at the same time in different directories. You can read more about ASDF in their website.

However I couldn't figure out how to deal with the lib directory that is required in the installation. Specifically /usr/lib/hamler for Linux and /usr/local/lib/hamler for OSX.

I need to somehow tell hamler that it should look for the lib directory in another path. Each installation will point to a lib directory, that's needed to avoid having hamler 0.1 using the 0.2.1 library for example.

Is there a way I can do that already? Something like setting an environment variable or something similar?

BTW: The idea behind Hamler is amazing! Keep up the amazing work!

scudelletti avatar Sep 19 '20 12:09 scudelletti

Hi, @scudelletti Thank you very much for your attention to hamler. When building hamler, you can modify the lib path of hamler by setting the environment variable HAMLER_HOME. Can this achieve your goal? Looking forward to your reply

Rory-Z avatar Sep 21 '20 05:09 Rory-Z

Hi @zhanghongtong, thank you for the reply and for your time.

I'm currently installing the binary instead of building the whole project to avoid having dependencies such as haskell stack. It's a recipe quite similar to the homebrew and the linux installation guide.

I was thinking about installing it a folder inside ASDF_DATA_DIR environment variable so the whole installation would be in the same folder and the user would be able to configure it.

scudelletti avatar Sep 21 '20 06:09 scudelletti

Hi, @scudelletti Do you think we should distinguish lib path by version number? I'm not sure if this is correct Or we can soft link different versions of lib path to /usr/lib/hamler?

Rory-Z avatar Sep 21 '20 09:09 Rory-Z

I currently soft link the /usr/lib/hamler(here and here) and that works until someone decides to have 2 different hamler versions active at the same time.

Example: Terminal 1

cd ~/projects/hello-world-hamler
asdf local hamler 0.2.1
hamler repl

Terminal 2:

cd ~/projects/hamler-example
asdf local hamler 0.1
hamler repl

Both terminal 1 and 2 are running repl at the same time however they rely in different lib directories. So linking /usr/lib/hamler directly won't work.

Also ASDF documentation suggests that we install all files of a specific version in a single place, so would be nice to have the binary installed beside the lib directory. That structure is exactly the current structure of the tar file.

If possible the script should only place files in the ASDF_INSTALL_PATH directory once the build and installation of the tool is deemed successful by the install script. Quote from ASDF documentation

I was thinking about having something like HAMLER_HOME/HAMLER_LIB or something similar which would be used during runtime when and only if it is set.

I believe ruby has something similar with an environment variable called RUBYLIB. More info: https://stackoverflow.com/a/901109/1464792

scudelletti avatar Sep 21 '20 11:09 scudelletti

CC @EMQ-YangM Can hamler dynamically set the lib path at runtime?

Rory-Z avatar Sep 21 '20 14:09 Rory-Z

@scudelletti I can add a HAMLER_HOME environment variable. You can use this environment variable to specify the location of the hamler library file. Do you think this can solve your problem? #425

sdzx-1 avatar Sep 22 '20 01:09 sdzx-1

@EMQ-YangM That's perfect! 🎉 🎊

Thank you both!

scudelletti avatar Sep 22 '20 06:09 scudelletti