github.com/delicb/asdf-exec@v0.1.3-0.20220111003559-af5f44250ab7/README.md (about) 1 # asdf-exec 2 3 [![CircleCI](https://circleci.com/gh/danhper/asdf-exec.svg?style=svg)](https://circleci.com/gh/danhper/asdf-exec) 4 5 Experimental command to find and run executable used by [asdf][asdf] shims. 6 7 NOTE: This is not officially supported by asdf and requires to slightly 8 patch the asdf code 9 10 ## Installation 11 12 I assume `asdf` is installed in `~/.asdf`. If not, please change the commands accordingly. 13 14 First, grab the `asdf-exec` executable from [the releases](https://github.com/danhper/asdf-exec/releases/) 15 and put it in `~/.asdf/bin/private` as `asdf-exec` 16 17 ``` 18 # for linux 19 wget https://github.com/danhper/asdf-exec/releases/download/v0.1.2/asdf-exec-linux-x64 -O ~/.asdf/bin/private/asdf-exec 20 # for macos 21 wget https://github.com/danhper/asdf-exec/releases/download/v0.1.2/asdf-exec-darwin-x64 -O ~/.asdf/bin/private/asdf-exec 22 23 # for both: 24 chmod +x ~/.asdf/bin/private/asdf-exec 25 ``` 26 27 Then, patch asdf reshim command code and regenerate all shims. 28 29 ``` 30 sed -i.bak -e 's|exec $(asdf_dir)/bin/asdf exec|exec $(asdf_dir)/bin/private/asdf-exec|' ~/.asdf/lib/commands/command-reshim.bash 31 rm ~/.asdf/shims/* 32 asdf reshim 33 ``` 34 35 ## Rationale 36 37 As asdf is growing in features and complexity, the logic to run a single 38 command has become fairly involved and unfortunately quite slow. 39 For example 40 41 ``` 42 $ time python --version 43 Python 3.7.2 44 0.19user 0.04system 0:00.16elapsed 142%CPU (0avgtext+0avgdata 4344maxresident)k 45 0inputs+0outputs (0major+25175minor)pagefaults 0swaps 46 ``` 47 48 While there are surely many things we could do better with bash to improve 49 performance, tuning bash is quite tedious and error-prone. 50 51 I decided to give a native command a try. This would be called from shims 52 and would take care of locating the correct version. 53 Although this does results in quite a bit of duplication between the bash 54 code and this one, it does give a speed improvement which might be worth it. 55 56 ``` 57 $ time python --version 58 Python 3.7.2 59 0.00user 0.00system 0:00.01elapsed 100%CPU (0avgtext+0avgdata 4096maxresident)k 60 0inputs+0outputs (0major+691minor)pagefaults 0swaps 61 ``` 62 63 This is still totally experimental and there are no plan to merge or use this into 64 asdf for now, but please feel free to give it a try and let me know what you think. 65 66 67 68 69 [asdf]: https://github.com/asdf-vm/asdf