asdf
asdf copied to clipboard
Trying to get a global install working
Yes! ASDF is pretty much agnostic to where it is installed. Just clone asdf at any shared location, say /opt/asdf and make sure all users have permissions for reading and executing binaries installed there. Have their shell profile source the asdf.sh environment and violá.
I'd recommend having a single user manage installed tool versions, since asdf has no restriction on what a plugin-install command can do, and what permissions files are created with. So, I guess the best would be, install things for other users and make sure everyone can read and execute.
Originally posted by @vic in https://github.com/asdf-vm/asdf/issues/577#issuecomment-539102716
I'd like an easier way to use asdf related tools for scripts running as root and systemd scripts. So I thought I'd try the above out.
But it appears to fail to source lib/utils.bash correctly, resulting in problems such as:
-
Each terminal command output is prefixed with (due to a shell plugin which depends on python, which for me is provided by asdf)
/opt/asdf/lib/commands/command-exec.bash: line 31: with_shim_executable: command not found -
A more confusing error in my asdf install script. If the script is run in zsh it works fine, but if run with bash it errors out as below (and before moving to a global install the install script worked fine for bash). I take it this must mean that I'm not sourcing the correct file somewhere anymore, but even explicitly
source /opt/asdf/lib/utils.bashdoesn't seem to make these funcs available. Any suggestions?
/opt/asdf/lib/commands/command-list.bash: line 20: check_if_plugin_exists: command not found
/opt/asdf/lib/commands/command-list.bash: line 27: list_installed_versions: command not found
/opt/asdf/lib/commands/command-list.bash: line 34: display_error: command not found
/opt/asdf/lib/commands/command-install.bash: line 84: get_plugin_path: command not found
/opt/asdf/lib/commands/command-install.bash: line 85: check_if_plugin_exists: command not found
/opt/asdf/lib/commands/command-install.bash: line 108: get_install_path: command not found
mkdir: cannot create directory ‘’: No such file or directory
@jackmac92 can you explain exactly what commands you ran to setup asdf? Those errors seem to indicate something wasn't setup correctly. Regardless of where you put asdf on your system, you'll need to run . /path/to/asdf/files/asdf.sh in the shell as the same user that issues the asdf commands.
Hey @Stratus3D I took a working install from ~/.asdf and tried moving it to /opt/asdf and setting ASDF_DATA_DIR=/opt/asdf and ASDF_DIR=/opt/asdf
Everything looks correct with how I'm sourcing . /opt/asdf/asdf.sh in my dotFiles, and the issue persists even if I try to resource that file in an interactive shell. So I think the issue must be something else.
Feel free to close this issue, the remainder of this comment is just me describing my confusion. You have better things to do (but I figure it's worth posting in case someone happens to have similar issues later :man_shrugging:)
I tried re-enabling my global setup, and just realized that asdf_dir is returning empty string.
Also any confused by this. That my shell has with_shim_executable defined, but apparently asdf command-exec.bash can't see it. Seems like some sort of caching issue (but that caching may be coming from somewhere else in my dotfile setup)
> which with_shim_executable
/opt/asdf/lib/commands/command-exec.bash: line 31: with_shim_executable: command not found
with_shim_executable () {
local shim_name
shim_name=$(basename "$1")
local shim_exec="${2}"
if [ ! -f "$(asdf_data_dir)/shims/${shim_name}" ]
...
Everything looks correct with how I'm sourcing . /opt/asdf/asdf.sh in my dotFiles, and the issue persists even if I try to resource that file in an interactive shell. So I think the issue must be something else.
You shouldn't be manually sourceing anything. All you need to do is run . /path/to/asdf/files/asdf.sh with the correct environment variables set and everything should work. If you've got with_shim_executable available in your shell as a function that means you've sourced something you shouldn't have. Only the asdf command, and eventually the asdf shims (e.g. ruby, irb, etc...)
Thanks for taking a look @Stratus3D!
Generally I don't manually source anything, I just have . ~/.asdf/asdf.sh in my rc file.
I just tried again, using a bash shell instead of zsh (just to reduce the variables, my zsh config has too much going on), but I'm still getting a similar error
shell setup
jmccown@homeframe:~$ echo $ASDF_DATA_DIR
/opt/asdf
jmccown@homeframe:~$ echo $ASDF_DIR
/opt/asdf
jmccown@homeframe:~$ asdf
Command 'asdf' not found, did you mean:
command 'adsf' from deb ruby-adsf (1.4.3+dfsg1-1)
command 'sdf' from deb sdf (2.001+1-7)
command 'asdfg' from deb aoeui (1.7+20160302.git4e5dee9-2)
command 'sadf' from deb sysstat (12.2.0-2)
Try: sudo apt install <deb name>
activating asdf
jmccown@homeframe:~$ . /opt/asdf/asdf.sh
jmccown@homeframe:~$ asdf
/opt/asdf/lib/commands/command-help.bash: line 4: asdf_version: command not found
version:
/opt/asdf/lib/commands/command-help.bash: line 6: asdf_dir: command not found
cat: /help.txt: No such file or directory
/opt/asdf/lib/commands/command-help.bash: line 19: get_plugin_path: command not found
"Late but latest"
-- Rajinikanth
I'll try to dig in a bit more tonight, any other suggestions of something I could test?
Not sure if it's too late but just want to note this down.
In the following codes: https://github.com/asdf-vm/asdf/blob/c6145d08d01691a6e16c990e7d1c8778733e8c76/bin/asdf#L73-L84
If the .bash files in the lib/commands folder are executable, then notice that they will be ran using the exec command, which will somehow lose reference to the functions in utils.bash. Once I run chmod a-x on the .bash files, the errors are gone.
@Stratus3D is this behaviour intentional? Probably for some reasons that weren't obvious to me...
@jackmac92 Were you ever able to figure this out? I'm facing the same issue trying to install asdf in a Docker container and failing to get it to run when running the container as a different user. Same error :/
@Nickersoft https://github.com/asdf-vm/asdf/issues/1540 there is a solution for this. Also happend to me today