cabesa-collective / capistrano-asdf

ASDF support for Capistrano v3
MIT License
21 stars 8 forks source link

Add support for ASDF_DATA_DIR for a global asdf deployment #7

Open DerekK19 opened 1 week ago

DerekK19 commented 1 week ago

I install asdf (on a Debian web server) in /usr/local/asdf. Then I put all my plugins etc in /opt/asdf. I do this rather than having everything in ~/.asdf. When initialising asdf in my login script I set the env variable ASDF_DATA_DIR to /opt/asdf.

The advantage of this way of working is that every login user on my web server will have the same asdf set-up i.e the web server runner, the deploy user or me if I log onto the web server to triage problems.

When I deploy a web-site using capistrano, there is no mechanism for specifying my custom ASDF_DATA_DIR setting. It would be set in the asdf-wrapper script, but that is created on the fly as par of the deployment.

Please can the gem be modified to support this behaviour. I am thinking of an extra customisation variable (it could be called asdf_custom_data) which would be set in the same way as asdf_custom_path. In my case, I would add lines to deploy.rb like:

set :asdf_custom_path, '/usr/local/asdf' set :asdf_custom_data, '/opt/asdf'

and this setting would be reflected in the deploy to produce an asdf-wrapper script (in my case) like:

!/usr/bin/env bash

export ASDF_DATA_DIR="/opt/asdf"

. /usr/local/asdf/asdf.sh exec "$@"

FWIW I have taken a fork of the repo and made a change as I suggest, and it does work

sdubinsky commented 1 day ago

FWIW I have managed to achieve this by adding

set :default_env, {
      'ASDF_DIR': '/usr/local/bin/asdf-vm',
      'ASDF_DATA_DIR': '/opt/asdf'
    }

to my deploy.rb