rtx-cli 1.22.0

Polyglot runtime manager (asdf rust clone)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
# [rtx]https://github.com/jdxcode/rtx

[![Crates.io](https://img.shields.io/crates/v/rtx-cli.svg)](https://crates.io/crates/rtx-cli)
[![License: MIT](https://img.shields.io/github/license/jdxcode/rtx)](https://github.com/jdxcode/rtx/blob/main/LICENSE)
[![CI](https://github.com/jdxcode/rtx/actions/workflows/rtx.yml/badge.svg?branch=main)](https://github.com/jdxcode/rtx/actions/workflows/rtx.yml)
[![Codecov](https://codecov.io/gh/jdxcode/rtx/branch/main/graph/badge.svg?token=XYH3Q0BOO0)](https://codecov.io/gh/jdxcode/rtx)
[![Discord](https://img.shields.io/discord/1066429325269794907)](https://discord.gg/mABnUDvP57)

_Polyglot runtime manager (asdf rust clone)_

## 30 Second Demo

The following shows using rtx to install [nodejs](https://nodejs.org) and
[jq](https://stedolan.github.io/jq/) into a project using a `.tool-versions` file.
[hyperfine](https://github.com/sharkdp/hyperfine) is used to show the performance using
rtx vs asdf. (See [Performance](#performance)).
Note that calling `which node` gives us a real path to the binary, not a shim.

[![demo](./docs/demo.gif)](./docs/demo.gif)

## Features

- **asdf-compatible** - rtx is compatible with asdf plugins and `.tool-versions` files. It can be used as a drop-in replacement.
- **Polyglot** - compatible with any language, so no more figuring out how nvm, nodenv, pyenv, etc work individually—just use 1 tool.
- **Fast** - rtx is written in Rust and is very fast. 20x-200x faster than asdf.
- **No shims** - shims (used by asdf) cause problems, they break `which node`, and add overhead. We don't use them by default.
- **Better UX** - asdf is full of strange UX decisions (like `asdf plugin add` but also `asdf install`). We've taken care to make rtx easy to use.
- **Fuzzy matching and aliases** - no need to specify exact version numbers like with asdf.
- **One command install** - No need to manually install each plugin, just run `rtx install` and it will install all the plugins you need.
- **Arbitrary env vars** - Set custom env vars when in a project directory like `NODE_ENV=production` or `AWS_PROFILE=staging`.

## Quickstart

Install rtx (other methods [here](#installation)):

```sh-session
$ curl https://rtx.pub/rtx-latest-macos-arm64 > ~/bin/rtx
$ chmod +x ~/bin/rtx
$ rtx --version
rtx 1.22.0
```

Hook rtx into to your shell. This will automatically add `~/bin` to `PATH` if it isn't already.
(choose one, and open a new shell session for the changes to take effect):

```sh-session
$ echo 'eval "$(~/bin/rtx activate bash)"' >> ~/.bashrc
$ echo 'eval "$(~/bin/rtx activate zsh)"' >> ~/.zshrc
$ echo '~/bin/rtx activate fish | source' >> ~/.config/fish/config.fish
```

> **Warning**
>
> If you use direnv with `layout python` or other logic that needs to reference rtx runtimes inside
> of an `.envrc`, see the [direnv section]#direnv below.

Install a runtime and set it as the default:

```sh-session
$ rtx install nodejs@18
$ rtx global nodejs@18
$ node -v
v18.10.9
```

> **Note**
>
> `rtx install` is optional, `rtx global` will prompt to install the runtime if it's not
> already installed. This is configurable in [`~/.config/rtx/config.toml`]#configuration.

## Table of Contents

<!-- AUTO-GENERATED-CONTENT:START (TOC:collapse=true&collapseText=Click to expand&maxDepth=3) -->
<details>
<summary>Click to expand</summary>

- [30 Second Demo]#30-second-demo
- [Features]#features
- [Quickstart]#quickstart
- [About]#about
  - [What do I use this for?]#what-do-i-use-this-for
  - [How it works]#how-it-works
  - [Common example commands]#common-example-commands
- [Installation]#installation
  - [Standalone]#standalone
  - [Homebrew]#homebrew
  - [Cargo]#cargo
  - [npm]#npm
  - [GitHub Releases]#github-releases
  - [apt]#apt
  - [dnf]#dnf
  - [yum]#yum
  - [~~apk~~ (coming soon)]#apk-coming-soon
  - [aur]#aur
  - [nix]#nix
- [Other Shells]#other-shells
  - [Bash]#bash
  - [Fish]#fish
  - [Xonsh]#xonsh
  - [Something else?]#something-else
- [Uninstalling]#uninstalling
- [Configuration]#configuration
  - [`.tool-versions`]#tool-versions
  - [Legacy version files]#legacy-version-files
  - [Global config: `~/.config/rtx/config.toml`]#global-config-configrtxconfigtoml
  - [[experimental] `.rtx.toml`]#experimental-rtxtoml
  - [Environment variables]#environment-variables
- [Aliases]#aliases
- [Plugins]#plugins
  - [Plugin Options]#plugin-options
- [Versioning]#versioning
  - [Calver Breaking Changes]#calver-breaking-changes
- [Commands]#commands
  - [`rtx activate`]#rtx-activate
  - [`rtx alias get`]#rtx-alias-get
  - [`rtx alias ls`]#rtx-alias-ls
  - [`rtx alias set`]#rtx-alias-set
  - [`rtx alias unset`]#rtx-alias-unset
  - [`rtx bin-paths`]#rtx-bin-paths
  - [`rtx cache clear`]#rtx-cache-clear
  - [`rtx complete`]#rtx-complete
  - [`rtx current`]#rtx-current
  - [`rtx deactivate`]#rtx-deactivate
  - [`rtx direnv activate`]#rtx-direnv-activate
  - [`rtx doctor`]#rtx-doctor
  - [`rtx env`]#rtx-env
  - [`rtx exec`]#rtx-exec
  - [`rtx global`]#rtx-global
  - [`rtx implode`]#rtx-implode
  - [`rtx install`]#rtx-install
  - [`rtx latest`]#rtx-latest
  - [`rtx local`]#rtx-local
  - [`rtx ls`]#rtx-ls
  - [`rtx ls-remote`]#rtx-ls-remote
  - [`rtx plugins install`]#rtx-plugins-install
  - [`rtx plugins ls`]#rtx-plugins-ls
  - [`rtx plugins ls-remote`]#rtx-plugins-ls-remote
  - [`rtx plugins uninstall`]#rtx-plugins-uninstall
  - [`rtx plugins update`]#rtx-plugins-update
  - [`rtx prune`]#rtx-prune
  - [`rtx reshim`]#rtx-reshim
  - [`rtx self-update`]#rtx-self-update
  - [`rtx settings get`]#rtx-settings-get
  - [`rtx settings ls`]#rtx-settings-ls
  - [`rtx settings set`]#rtx-settings-set
  - [`rtx settings unset`]#rtx-settings-unset
  - [`rtx shell`]#rtx-shell
  - [`rtx uninstall`]#rtx-uninstall
  - [`rtx version`]#rtx-version
  - [`rtx where`]#rtx-where
  - [`rtx which`]#rtx-which
- [FAQs]#faqs
  - [I don't want to put a `.tool-versions` file into my project since git shows it as an untracked file.]#i-dont-want-to-put-a-tool-versions-file-into-my-project-since-git-shows-it-as-an-untracked-file
  - [rtx is failing or not working right]#rtx-is-failing-or-not-working-right
  - [Windows support?]#windows-support
  - [How do I use rtx with http proxies?]#how-do-i-use-rtx-with-http-proxies
  - [How do the shorthand plugin names map to repositories?]#how-do-the-shorthand-plugin-names-map-to-repositories
  - [How do I migrate from asdf?]#how-do-i-migrate-from-asdf
  - [How compatible is rtx with asdf?]#how-compatible-is-rtx-with-asdf
  - [rtx isn't working with tmux]#rtx-isnt-working-with-tmux
- [Comparison to asdf]#comparison-to-asdf
  - [Performance]#performance
  - [Environment variables in rtx]#environment-variables-in-rtx
  - [UX]#ux
  - [CI/CD]#cicd
  - [GitHub Actions]#github-actions
- [Shims]#shims
- [direnv]#direnv
  - [rtx inside of direnv (`use rtx` in `.envrc`)]#rtx-inside-of-direnv-use-rtx-in-envrc
  - [Do you need direnv?]#do-you-need-direnv
- [Cache Behavior]#cache-behavior
  - [Plugin/Runtime Cache]#pluginruntime-cache

</details>
<!-- AUTO-GENERATED-CONTENT:END -->

## About

_New developer? Try reading the [Beginner's Guide](https://dev.to/jdxcode/beginners-guide-to-rtx-ac4) for a gentler introduction._

rtx is a tool for managing programming language and tool versions. For example, use this to install
a particular version of node.js and ruby for a project. Using `rtx activate`, you can have your
shell automatically switch to the correct node and ruby versions when you `cd` into the project's
directory. Other projects on your machine can use a different set of versions.

rtx is inspired by [asdf](https://asdf-vm.com) and uses asdf's vast [plugin ecosystem](https://github.com/asdf-vm/asdf-plugins)
under the hood. However, it is _much_ faster than asdf and has a more friendly user experience.
For more on how rtx compares to asdf, [see below](#comparison-to-asdf). The goal of this project
was to create a better front-end to asdf.

It uses the same `.tool-versions` file that asdf uses. It's also compatible with idiomatic version
files like `.node-version` and `.ruby-version`. See [Legacy Version Files](#legacy-version-files) below.

Come chat about rtx on [discord](https://discord.gg/mABnUDvP57).

### What do I use this for?

Typically, developers would use rtx to manage versions of their dev tools for _local_ development.
The main purpose of using rtx is being able to have different versions of languages for different projects
on the same machine. (For example, one project might require python-3.10 and another python-3.11).

Using rtx in production is less common but still a supported use-case. Usually a production setup
won't have different directories for different projects with different dev tool requirements.
However using `.tool-versions`/`.rtx.toml` config in production provides parity with local development
so rtx is still definitely useful in production setups. See the [GitHub Action](#github-actions) for
an example of using rtx in production.

### How it works

rtx installs as a shell extension (e.g. `rtx activate zsh`) that sets the `PATH`
environment variable to point your shell to the correct runtime binaries. When you `cd` into a
directory containing a `.tool-versions` file, rtx will automatically activate the correct versions.

Every time your prompt starts it will call `rtx hook-env` to fetch new environment variables. This
should be very fast and it exits early if the the directory wasn't changed or the `.tool-versions`
files haven't been updated. On my machine this takes 4ms in the fast case, 14ms in the slow case. See [Performance](#performance) for more on this topic.

Unlike asdf which uses shim files to dynamically locate runtimes when they're called, rtx modifies
`PATH` ahead of time so the runtimes are called directly. This is not only faster since it avoids
any overhead, but it also makes it so commands like `which node` work as expected. This also
means there isn't any need to run `asdf reshim` after installing new runtime binaries.

rtx does not directly install runtimes. Instead, it uses asdf plugins to install runtimes. See
[plugins](#plugins) below.

### Common example commands

    rtx install nodejs@18.0.0       Install a specific version number
    rtx install nodejs@18.0         Install a fuzzy version number
    rtx local nodejs@18             Use node-18.x in current project
    rtx global nodejs@18            Use node-18.x as default

    rtx install nodejs              Install the version specified in .tool-versions
    rtx local nodejs@latest         Use latest node in current directory
    rtx global nodejs@system        Use system node as default

    rtx x nodejs@18 -- node app.js  Run `node app.js` with the PATH pointing to node-18.x

## Installation

### Standalone

Note that it isn't necessary for `rtx` to be on `PATH`. If you run the activate script in your rc
file, rtx will automatically add itself to `PATH`.

```sh-session
$ curl https://rtx.pub/install.sh | sh
```

or if you're allergic to `| sh`:

```sh-session
$ curl https://rtx.pub/rtx-latest-macos-arm64 > /usr/local/bin/rtx
```

It doesn't matter where you put it. So use `~/bin`, `/usr/local/bin`, `~/.local/share/rtx/bin/rtx`
or whatever.

Supported architectures:

- `x64`
- `arm64`

Supported platforms:

- `macos`
- `linux`

If you need something else, compile it with [cargo](#cargo).

### Homebrew

There are 2 ways to install rtx with Homebrew. The recommended method is to use
the custom tap which will always contain the latest release.

```sh-session
$ brew install jdxcode/tap/rtx
```

Alternatively, you can use the built-in tap (homebrew-core), which will be updated
once Homebrew maintainers merge the PR for a new release:

```sh-session
$ brew install rtx
```

### Cargo

Build from source with Cargo:

```sh-session
$ cargo install rtx-cli
```

Do it faster with [cargo-binstall](https://github.com/cargo-bins/cargo-binstall):

```sh-session
$ cargo install cargo-binstall
$ cargo binstall rtx-cli
```

Build from the latest commit in main:

```sh-session
$ cargo install rtx-cli --git https://github.com/jdxcode/rtx --branch main
```

### npm

rtx is available on npm as precompiled binaries. This isn't a node.js package, just distributed
via npm. It can be useful for JS projects that want to setup rtx via `package.json` or `npx`.

```sh-session
$ npm install -g rtx-cli
```

Or use npx if you just want to test it out for a single command without fully installing:

```sh-session
$ npx rtx-cli exec python@3.11 -- python some_script.py
```

### GitHub Releases

Download the latest release from [GitHub](https://github.com/jdxcode/rtx/releases).

```sh-session
$ curl https://github.com/jdxcode/rtx/releases/download/v1.22.0/rtx-v1.22.0-linux-x64 | tar -xJv
$ mv rtx/bin/rtx /usr/local/bin
```

### apt

For installation on Ubuntu/Debian:

```sh-session
wget -qO - https://rtx.pub/gpg-key.pub | gpg --dearmor | sudo tee /usr/share/keyrings/rtx-archive-keyring.gpg 1> /dev/null
echo "deb [signed-by=/usr/share/keyrings/rtx-archive-keyring.gpg arch=amd64] https://rtx.pub/deb stable main" | sudo tee /etc/apt/sources.list.d/rtx.list
sudo apt update
sudo apt install -y rtx
```

> **Warning**
>
> If you're on arm64 you'll need to run the following:
> ```
> echo "deb [signed-by=/usr/share/keyrings/rtx-archive-keyring.gpg arch=arm64] https://rtx.pub/deb stable main" | sudo tee /etc/apt/sources.list.d/rtx.list
> ```

### dnf

For Fedora, CentOS, Amazon Linux, RHEL and other dnf-based distributions:

```sh-session
dnf install -y dnf-plugins-core
dnf config-manager --add-repo https://rtx.pub/rpm/rtx.repo
dnf install -y rtx
```

### yum

```sh-session
yum install -y yum-utils
yum-config-manager --add-repo https://rtx.pub/rpm/rtx.repo
yum install -y rtx
```

### ~~apk~~ (coming soon)

For Alpine Linux:

```sh-session
apk add rtx --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
```

### aur

For Arch Linux:

```sh-session
git clone https://aur.archlinux.org/rtx.git
cd rtx
makepkg -si
```

### nix

For NixOS or those using the Nix package manager:

```nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    rtx-flake = {
      url = "github:chadac/rtx/add-nix-flake";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.flake-utils.follows = "flake-utils";
    };
  };

  outputs = { self, nixpkgs, flake-utils, rtx-flake }:
    flake-utils.lib.eachDefaultSystem(system:
      let
        pkgs = import nixpkgs {
          inherit system;
          overlays = [ rtx-flake.overlay ];
        };
      in {
        devShells.default = pkgs.mkShell {
          name = "my-dev-env";
          nativeBuildInputs = with pkgs; [
            rtx
          ];
        };
      }
    );
}
```

You can also import the package directly using
`rtx-flake.packages.${system}.rtx`. It supports all default Nix
systems.

## Other Shells

### Bash

```sh-session
$ echo 'eval "$(rtx activate bash)"' >> ~/.bashrc
```

### Fish

```sh-session
$ echo 'rtx activate fish | source' >> ~/.config/fish/config.fish
```

### Xonsh

Since `.xsh` files are [not compiled](https://github.com/xonsh/xonsh/issues/3953) you may shave a bit off startup time by using a pure Python import: add the code below to, for example, `~/.config/xonsh/rtx.py` config file and `import rtx` it in `~/.config/xonsh/rc.xsh`:
```xsh
from pathlib        	import Path
from xonsh.built_ins	import XSH

ctx = XSH.ctx
rtx_init = subprocess.run([Path('~/bin/rtx').expanduser(),'activate','xonsh'],capture_output=True,encoding="UTF-8").stdout
XSH.builtins.execx(rtx_init,'exec',ctx,filename='rtx')
```

Or continue to use `rc.xsh`/`.xonshrc`:
```xsh
echo 'execx($(~/bin/rtx activate xonsh))' >> ~/.config/xonsh/rc.xsh # or ~/.xonshrc
```

Given that `rtx` replaces both shell env `$PATH` and OS environ `PATH`, watch out that your configs don't have these two set differently (might throw `os.environ['PATH'] = xonsh.built_ins.XSH.env.get_detyped('PATH')` at the end of a config to make sure they match)

### Something else?

Adding a new shell is not hard at all since very little shell code is
in this project.
[See here](https://github.com/jdxcode/rtx/tree/main/src/shell) for how
the others are implemented. If your shell isn't currently supported
I'd be happy to help you get yours integrated.

## Uninstalling

Use `rtx implode` to uninstall rtx. This will remove the rtx binary and all of its data. Use
`rtx implode --help` for more information.

Alternatively, manually remove the following directories to fully clean up:

* `~/.local/share/rtx` (can also be `RTX_DATA_DIR` or `XDG_DATA_HOME/rtx`)
* `~/.config/rtx` (can also be `RTX_CONFIG_DIR` or `XDG_CONFIG_HOME/rtx`)
* on Linux: `~/.cache/rtx` (can also be `RTX_CACHE_DIR` or `XDG_CACHE_HOME/rtx`)
* on macOS: `~/Library/Caches/rtx` (can also be `RTX_CACHE_DIR`)

## Configuration

### `.tool-versions`

The `.tool-versions` file is used to specify the runtime versions for a project. An example of this
is:

```
nodejs      18.0.0       # comments are allowed
ruby        3            # can be fuzzy version
shellcheck  latest       # also supports "latest"
jq          1.6
erlang      ref:master   # compile from vcs ref
golang      prefix:1.19  # uses the latest 1.19.x version—needed in case "1.19" is an exact match
shfmt       path:./shfmt # use a custom runtime
```

Create `.tool-versions` files manually, or use [`rtx local`](#rtx-local) to create them automatically.
See [the asdf docs](https://asdf-vm.com/manage/configuration.html#tool-versions) for more info on this file format.

### Legacy version files

rtx supports "legacy version files" just like asdf. They're language-specific files like `.node-version`
and `.python-version`. These are ideal for setting the runtime version of a project without forcing
other developers to use a specific tool like rtx/asdf.

They support aliases, which means you can have an `.nvmrc` file with `lts/hydrogen` and it will work
in rtx and nvm. Here are some of the supported legacy version files:

| Plugin    | "Legacy" (Idiomatic) Files                         |
| --------- | -------------------------------------------------- |
| crystal   | `.crystal-version`                                 |
| elixir    | `.exenv-version`                                   |
| golang    | `.go-version`, `go.mod`                            |
| java      | `.java-version`                                    |
| nodejs    | `.nvmrc`, `.node-version`                          |
| python    | `.python-version`                                  |
| ruby      | `.ruby-version`, `Gemfile`                         |
| terraform | `.terraform-version`, `.packer-version`, `main.tf` |
| yarn      | `.yvmrc`                                           |

In rtx these are enabled by default. You can disable them with `rtx settings set legacy_version_file false`.
There is a performance cost to having these when they're parsed as it's performed by the plugin in
`bin/parse-version-file`. However these are [cached](#cache-behavior) so it's not a huge deal.
You may not even notice.

> **Note**
>
> asdf calls these "legacy version files" so we do too. I think this is a bad name since it implies
> that they shouldn't be used—which is definitely not the case IMO. I prefer the term "idiomatic"
> version files since they're version files not specific to asdf/rtx and can be used by other tools.
> (`.nvmrc` being a notable exception, which is tied to a specific tool.)

### Global config: `~/.config/rtx/config.toml`

rtx can be configured in `~/.config/rtx/config.toml`. The following options are available (defaults shown):

```toml
[settings]
# whether to prompt to install plugins and runtimes if they're not already installed
missing_runtime_behavior = 'prompt' # other options: 'ignore', 'warn', 'prompt', 'autoinstall'

# plugins can read the versions files used by other version managers (if enabled by the plugin)
# for example, .nvmrc in the case of nodejs's nvm
legacy_version_file = true         # enabled by default (different than asdf)

# configure `rtx install` to always keep the downloaded archive
always_keep_download = false        # deleted after install by default

# configure how frequently (in minutes) to fetch updated plugin repository changes
# this is updated whenever a new runtime is installed
# (note: this isn't currently implemented but there are plans to add it: https://github.com/jdxcode/rtx/issues/128)
plugin_autoupdate_last_check_duration = 10080 # (one week) set to 0 to disable updates

verbose = false     # set to true to see full installation output, see `RTX_VERBOSE`
asdf_compat = false # set to true to ensure .tool-versions will be compatible with asdf, see `RTX_ASDF_COMPAT`
jobs = 4            # number of plugins or runtimes to install in parallel. The default is `4`.
raw = false         # set to true to directly pipe plugins to stdin/stdout/stderr

shorthands_file = '~/.config/rtx/shorthands.toml' # path to the shorthands file, see `RTX_SHORTHANDS_FILE`
disable_default_shorthands = false # disable the default shorthands, see `RTX_DISABLE_DEFAULT_SHORTHANDS`

experimental = false # enable experimental features such as shims
shims_dir = '~/.local/share/rtx/shims' # [experimental] directory where shims are stored

[alias.nodejs]
my_custom_node = '18'  # makes `rtx install nodejs@my_custom_node` install node-18.x
                       # this can also be specified in a plugin (see below in "Aliases")
```

These settings can also be managed with `rtx settings ls|get|set|unset`.

### [experimental] `.rtx.toml`

`.rtx.toml` is a new config file that replaces both the global config and the `.tool-versions` 
file. Think of `~/.config/rtx/config.toml` as just a
special `.rtx.toml` which is used from any directory on the machine.

It allows for functionality that is not possible with `.tool-versions`, such as:

* setting arbitrary env vars while inside the directory
* passing options to plugins like `virtualenv='.venv'` for [rtx-python]https://github.com/jdxcode/rtx-python#virtualenv-support.
* specifying plugin repo url for custom plugins so it does not need to be added manually

Here is what the config looks like:

```toml
[env]
NODE_ENV = 'production' # supports arbitrary env vars so rtx can be used like dotenv

[tools]
# specify single or multiple versions
terraform = '1.0.0'
erlang = ['23.3', '24.0']

# supports everything you can do with .tool-versions currently
nodejs = ['16', 'prefix:18', 'ref:master', 'path:~/.nodes/14']

# send arbitrary options to the plugin, passed as:
# RTX_TOOL_OPTS__VENV=.venv
# RTX_TOOL_OPTS__DEFAULT_PACKAGES__0=ansible
# RTX_TOOL_OPTS__DEFAULT_PACKAGES__1=pipenv
python = { version = '3.10', venv = '.venv', default_packages = ['ansible', 'pipenv'] }

[plugins]
# specify a custom repo url
# note this will only be used if the plugin does not already exist
python = 'https://github.com/jdxcode/rtx-python'

[settings] # project-local settings
verbose = true
missing_runtime_behavior = 'warn'
shims_dir = '~/.rtx/shims'

[alias.nodejs] # project-local aliases
my_custom_node = '18'
```

`.rtx.toml` is currently experimental and may change in minor versions of rtx. It does not 
require setting `experimental = true` in the global config in part because this config can 
itself contain the setting for `experimental`.

### Environment variables

rtx can also be configured via environment variables. The following options are available:

#### `RTX_MISSING_RUNTIME_BEHAVIOR`

This is the same as the `missing_runtime_behavior` config option in `~/.config/rtx/config.toml`.

```sh-session
$ RTX_MISSING_RUNTIME_BEHAVIOR=ignore rtx install nodejs@18
$ RTX_NODEJS_VERSION=18 rtx exec -- node --version
```

#### `RTX_DATA_DIR`

This is the directory where rtx stores its data. The default is `~/.local/share/rtx`.

#### `RTX_CACHE_DIR`

This is the directory where rtx stores cache. The default is `~/.cache/rtx` on Linux and `~/Library/Caches/rtx` on macOS.

#### `RTX_CONFIG_FILE`

This is the path to the config file. The default is `~/.config/rtx/config.toml`.
(Or `$XDG_CONFIG_HOME/config.toml` if that is set)

#### `RTX_DEFAULT_TOOL_VERSIONS_FILENAME`

Set to something other than ".tool-versions" to have rtx look for configuration with alternate names.

#### `RTX_DEFAULT_CONFIG_FILENAME`

Set to something other than ".rtx.toml" to have rtx look for configuration with alternate names.

This is the same as `RTX_DEFAULT_TOOL_VERSIONS_FILENAME` but for `.rtx.toml` format.

#### `RTX_${PLUGIN}_VERSION`

Set the version for a runtime. For example, `RTX_NODEJS_VERSION=18` will use nodejs@18.x regardless
of what is set in `.tool-versions`.

#### `RTX_LEGACY_VERSION_FILE`

Plugins can read the versions files used by other version managers (if enabled by the plugin)
for example, .nvmrc in the case of nodejs's nvm.

#### `RTX_USE_TOML`

Set to `1` to use default to using `.rtx.toml` in `rtx local` instead of `.tool-versions` for 
configuration.

#### `RTX_LOG_LEVEL=trace|debug|info|warn|error`

Can also use `RTX_DEBUG=1`, `RTX_TRACE=1`, and `RTX_QUIET=1`. These adjust the log
output to the screen.

#### `RTX_LOG_FILE=~/.rtx/rtx.log`

Output logs to a file.

#### `RTX_LOG_FILE_LEVEL=trace|debug|info|warn|error`

Same as `RTX_LOG_LEVEL` but for the log file output level. This is useful if you want
to store the logs but not have them litter your display.

#### `RTX_VERBOSE=1`

This shows the installation output during `rtx install` and `rtx plugin install`.
This should likely be merged so it behaves the same as `RTX_DEBUG=1` and we don't have
2 configuration for the same thing, but for now it is it's own config.

#### `RTX_ASDF_COMPAT=1`

Only output `.tool-versions` files in `rtx local|global` which will be usable by asdf.

#### `RTX_JOBS=1`

Set the number plugins or runtimes to install in parallel. The default is `4`.

#### `RTX_RAW=1`

Set to "1" to directly pipe plugin scripts to stdin/stdout/stderr. By default stdin is disabled
because when installing a bunch of plugins in parallel you won't see the prompt. Use this if a
plugin accepts input or otherwise does not seem to be installing correctly.

Sets `RTX_JOBS=1` because only 1 plugin script can be executed at a time.

#### `RTX_SHORTHANDS_FILE=~/.config/rtx/shorthands.toml`

Use a custom file for the shorthand aliases. This is useful if you want to share plugins within
an organization.

The file should be in toml format:

```toml
elixir = "https://github.com/my-org/rtx-elixir.git"
nodejs = "https://github.com/my-org/rtx-nodejs.git"
```

#### `RTX_DISABLE_DEFAULT_SHORTHANDS=1`

Disables the shorthand aliases for installing plugins. You will have to specify full urls when
installing plugins, e.g.: `rtx plugin install nodejs https://github.com/asdf-vm/asdf-nodejs.git`

Currently this disables the following:

* `--fuzzy` as default behavior (`rtx local nodejs@18` will save exact version)

#### `RTX_HIDE_OUTDATED_BUILD=1`

If a release is 12 months old, it will show a warning message every time it launches:

```
rtx has not been updated in over a year. Please update to the latest version.
```

You likely do not want to be using rtx if it is that old. I'm doing this instead of
autoupdating. If, for some reason, you want to stay on some old version, you can hide
this message with `RTX_HIDE_OUTDATED_BUILD=1`.

#### `RTX_EXPERIMENTAL=1`

Enables experimental features such as shims.

#### [experimental] `RTX_SHIMS_DIR=~/.local/share/rtx/shims`

Set a directory to output shims when running `rtx reshim`. Requires `experimental = true`.

## Aliases

rtx supports aliasing the versions of runtimes. One use-case for this is to define aliases for LTS
versions of runtimes. For example, you may want to specify `lts/hydrogen` as the version for nodejs@18.x.
So you can use the runtime with `nodejs lts/hydrogen` in `.tool-versions`.

User aliases can be created by adding an `alias.<PLUGIN>` section to `~/.config/rtx/config.toml`:

```toml
[alias.nodejs]
my_custom_18 = '18'
```

Plugins can also provide aliases via a `bin/list-aliases` script. Here is an example showing node.js
versions:

```bash
#!/usr/bin/env bash

echo "lts/hydrogen 18"
echo "lts/gallium 16"
echo "lts/fermium 14"
```

> **Note:**
>
> Because this is rtx-specific functionality not currently used by asdf it isn't likely to be in any
> plugin currently, but plugin authors can add this script without impacting asdf users.

## Plugins

rtx uses asdf's plugin ecosystem under the hood. These plugins contain shell scripts like
`bin/install` (for installing) and `bin/list-all` (for listing all of the available versions).

See https://github.com/asdf-vm/asdf-plugins for the list of built-in plugins shorthands. See asdf's
[Create a Plugin](https://asdf-vm.com/plugins/create.html) for how to create your own or just learn
more about how they work.

### Plugin Options

rtx has support for "plugin options" which is configuration specified in `.rtx.toml` to change behavior
of plugins. One example of this is virtualenv on python runtimes:

```toml
[tools]
python = {version='3.11', virtualenv='.venv'}
```

This will be passed to all plugin scripts as `RTX_TOOL_OPTS__VIRTUALENV=.venv`. The user can specify
any option and it will be passed to the plugin in that format.

Currently this only supports simple strings, but we can make it compatible with more complex types
(arrays, tables) fairly easily if there is a need for it.

## Versioning

rtx is currently a new project and is under very rapid development. Slight behavior changes may 
occur between releases. 
Features marked as "experimental" may change significantly or be removed entirely.

Starting June 1, 2023*, rtx will move to [Calver](https://calver.org/) versioning (`2023.6.1`). After the move to Calver, rtx's design will become mostly permanent and you will be able to rely on 
its behavior for the long term.
Breaking changes will be few but when they do happen,
they will be communicated in the CLI with plenty of notice whenever possible.

Rather than have semver major releases to communicate change in large releases,
new functionality and changes can be opted-into with settings like `experimental = true`.
This way plugin authors and users can
test out new functionality immediately without waiting for a major release.

The numbers in Calver (YYYY.MM.RELEASE) simply represent the date of the release—not compatibility
or how many new features were added.
Each release will be small and incremental.

_*This plan is tentative and the details may change, but the rough idea of making many changes now so we can have stability later is the goal._

### Calver Breaking Changes

When we switch to Calver, we'll immediately make some notable design changes to rtx. This will 
be the first and last time that such a change is made and I actually want to make sure we make 
as many as we can—because we'll be stuck with these decisions.

Here are a list of the changes that will be made:

* `rtx local` will default to creating `.rtx.toml` instead of `.tool-versions`. (If the config 
  already exists the format will be preserved.)
* `rtx global` will modify `~/.config/rtx/config.toml` instead of `~/.tool-versions`. This path 
  can be changed with `RTX_CONFIG_FILE`.
* `~/.tool-versions` will become simply another `.tool-versions` instead of being a special file 
  that is read anywhere such as from `/tmp`.
* (more to be added)

<!-- RTX:COMMANDS -->
## Commands

### `rtx activate`

```
Initializes rtx in the current shell

This should go into your shell's rc file.
Otherwise, it will only take effect in the current session.
(e.g. ~/.bashrc)

Usage: activate [OPTIONS] [SHELL_TYPE]

Arguments:
  [SHELL_TYPE]
          Shell type to generate the script for
          
          [possible values: bash, fish, xonsh, zsh]

Options:
      --status
          Show "rtx: <PLUGIN>@<VERSION>" message when changing directories

Examples:
    $ eval "$(rtx activate bash)"
    $ eval "$(rtx activate zsh)"
    $ rtx activate fish | source
    $ execx($(rtx activate xonsh))
```
### `rtx alias get`

```
Show an alias for a plugin

This is the contents of an alias.<PLUGIN> entry in ~/.config/rtx/config.toml

Usage: get <PLUGIN> <ALIAS>

Arguments:
  <PLUGIN>
          The plugin to show the alias for

  <ALIAS>
          The alias to show

Examples:
  $ rtx alias get nodejs lts/hydrogen
  18.0.0
```
### `rtx alias ls`

```
List aliases
Shows the aliases that can be specified.
These can come from user config or from plugins in `bin/list-aliases`.

For user config, aliases are defined like the following in `~/.config/rtx/config.toml`:

  [alias.nodejs]
  lts = "18.0.0"

Usage: ls [OPTIONS]

Options:
  -p, --plugin <PLUGIN>
          Show aliases for <PLUGIN>

Examples:
  $ rtx aliases
  nodejs    lts/hydrogen   18.0.0
```
### `rtx alias set`

```
Add/update an alias for a plugin

This modifies the contents of ~/.config/rtx/config.toml

Usage: set <PLUGIN> <ALIAS> <VALUE>

Arguments:
  <PLUGIN>
          The plugin to set the alias for

  <ALIAS>
          The alias to set

  <VALUE>
          The value to set the alias to

Examples:
  $ rtx alias set nodejs lts/hydrogen 18.0.0
```
### `rtx alias unset`

```
Clears an alias for a plugin

This modifies the contents of ~/.config/rtx/config.toml

Usage: unset <PLUGIN> <ALIAS>

Arguments:
  <PLUGIN>
          The plugin to remove the alias from

  <ALIAS>
          The alias to remove

Examples:
  $ rtx alias unset nodejs lts/hydrogen
```
### `rtx bin-paths`

```
List all the active runtime bin paths

Usage: bin-paths
```
### `rtx cache clear`

```
Deletes all cache files in rtx

Usage: clear
```
### `rtx complete`

```
Generate shell completions

Usage: complete --shell <SHELL>

Options:
  -s, --shell <SHELL>
          shell type
          
          [possible values: bash, elvish, fish, powershell, zsh]

Examples:
  $ rtx complete -s bash > /etc/bash_completion.d/rtx
  $ rtx complete -s zsh  > /usr/local/share/zsh/site-functions/_rtx
  $ rtx complete -s fish > ~/.config/fish/completions/rtx.fish
```
### `rtx current`

```
Shows current active and installed runtime versions

This is similar to `rtx ls --current`, but this only shows the runtime
and/or version. It's designed to fit into scripts more easily.

Usage: current [PLUGIN]

Arguments:
  [PLUGIN]
          Plugin to show versions of e.g.: ruby, nodejs

Examples:
  # outputs `.tool-versions` compatible format
  $ rtx current
  python 3.11.0 3.10.0
  shfmt 3.6.0
  shellcheck 0.9.0
  nodejs 18.13.0

  $ rtx current nodejs
  18.13.0

  # can output multiple versions
  $ rtx current python
  3.11.0 3.10.0
```
### `rtx deactivate`

```
Disable rtx for current shell session

This can be used to temporarily disable rtx in a shell session.

Usage: deactivate

Examples:
  $ rtx deactivate bash
  $ rtx deactivate zsh
  $ rtx deactivate fish
  $ execx($(rtx deactivate xonsh))
```
### `rtx direnv activate`

```
Output direnv function to use rtx inside direnv

See https://github.com/jdxcode/rtx#direnv for more information

Because this generates the legacy files based on currently installed plugins,
you should run this command after installing new plugins. Otherwise
direnv may not know to update environment variables when legacy file versions change.

Usage: activate

Examples:
  $ rtx direnv activate > ~/.config/direnv/lib/use_rtx.sh
  $ echo 'use rtx' > .envrc
  $ direnv allow
```
### `rtx doctor`

```
Check rtx installation for possible problems.

Usage: doctor

Examples:
  $ rtx doctor
  [WARN] plugin nodejs is not installed
```
### `rtx env`

```
Exports env vars to activate rtx a single time

Use this if you don't want to permanently install rtx. It's not necessary to
use this if you have `rtx activate` in your shell rc file.

Usage: env [OPTIONS] [RUNTIME]...

Arguments:
  [RUNTIME]...
          Runtime version to use

Options:
  -s, --shell <SHELL>
          Shell type to generate environment variables for
          
          [possible values: bash, fish, xonsh, zsh]

Examples:
  $ eval "$(rtx env -s bash)"
  $ eval "$(rtx env -s zsh)"
  $ rtx env -s fish | source
  $ execx($(rtx env -s xonsh))
```
### `rtx exec`

```
Execute a command with runtime(s) set

use this to avoid modifying the shell session or running ad-hoc commands with the rtx runtimes
set.

Runtimes will be loaded from .tool-versions, though they can be overridden with <RUNTIME> args
Note that only the plugin specified will be overridden, so if a `.tool-versions` file
includes "nodejs 18" but you run `rtx exec python@3.11`; it will still load nodejs@18.

The "--" separates runtimes from the commands to pass along to the subprocess.

Usage: exec [OPTIONS] [RUNTIME]... [-- <COMMAND>...]

Arguments:
  [RUNTIME]...
          Runtime(s) to start e.g.: nodejs@18 python@3.10

  [COMMAND]...
          Command string to execute (same as --command)

Options:
  -c, --command <C>
          Command string to execute

Examples:
  rtx exec nodejs@18 -- node ./app.js  # launch app.js using node-18.x
  rtx x nodejs@18 -- node ./app.js     # shorter alias

  # Specify command as a string:
  rtx exec nodejs@18 python@3.11 --command "node -v && python -V"
```
### `rtx global`

```
Shows/sets the global runtime version(s)

Displays the contents of ~/.tool-versions after writing.
The file is `$HOME/.tool-versions` by default. It can be changed with `$RTX_CONFIG_FILE`.
If `$RTX_CONFIG_FILE` is set to anything that ends in `.toml`, it will be parsed as `.rtx.toml`.
Otherwise, it will be parsed as a `.tool-versions` file.
A future v2 release of rtx will default to using `~/.config/rtx/config.toml` instead.

Use `rtx local` to set a runtime version locally in the current directory.

Usage: global [OPTIONS] [RUNTIME]...

Arguments:
  [RUNTIME]...
          Runtime(s) to add to .tool-versions
          e.g.: nodejs@18
          If this is a single runtime with no version, the current value of the global
          .tool-versions will be displayed

Options:
      --pin
          Save exact version to `~/.tool-versions`
          e.g.: `rtx local --pin nodejs@18` will save `nodejs 18.0.0` to ~/.tool-versions

      --fuzzy
          Save fuzzy version to `~/.tool-versions`
          e.g.: `rtx local --fuzzy nodejs@18` will save `nodejs 18` to ~/.tool-versions
          this is the default behavior unless RTX_ASDF_COMPAT=1

      --remove <PLUGIN>
          Remove the plugin(s) from ~/.tool-versions

      --path
          Get the path of the global config file

Examples:
  # set the current version of nodejs to 18.x
  # will use a fuzzy version (e.g.: 18) in .tool-versions file
  $ rtx global --fuzzy nodejs@18

  # set the current version of nodejs to 18.x
  # will use a precise version (e.g.: 18.0.0) in .tool-versions file
  $ rtx global --pin nodejs@18

  # show the current version of nodejs in ~/.tool-versions
  $ rtx global nodejs
  18.0.0
```
### `rtx implode`

```
Removes rtx CLI and all related data

Skips config directory by default.

Usage: implode [OPTIONS]

Options:
      --config
          Also remove config directory

      --dry-run
          List directories that would be removed without actually removing them
```
### `rtx install`

```
Install a runtime

This will install a runtime to `~/.local/share/rtx/installs/<PLUGIN>/<VERSION>`
It won't be used simply by being installed, however.
For that, you must set up a `.tool-version` file manually or with `rtx local/global`.
Or you can call a runtime explicitly with `rtx exec <PLUGIN>@<VERSION> -- <COMMAND>`.

Runtimes will be installed in parallel. To disable, set `--jobs=1` or `RTX_JOBS=1`

Usage: install [OPTIONS] [RUNTIME]...

Arguments:
  [RUNTIME]...
          Runtime(s) to install e.g.: nodejs@18

Options:
  -p, --plugin <PLUGIN>
          Only install runtime(s) for <PLUGIN>

  -f, --force
          Force reinstall even if already installed

  -v, --verbose...
          Show installation output

Examples:
  $ rtx install nodejs@18.0.0  # install specific nodejs version
  $ rtx install nodejs@18      # install fuzzy nodejs version
  $ rtx install nodejs         # install version specified in .tool-versions
  $ rtx install                # installs all runtimes specified in .tool-versions for installed plugins
  $ rtx install --all          # installs all runtimes and all plugins
```
### `rtx latest`

```
Gets the latest available version for a plugin

Usage: latest <RUNTIME>

Arguments:
  <RUNTIME>
          Runtime to get the latest version of

Examples:
  $ rtx latest nodejs@18  # get the latest version of nodejs 18
  18.0.0

  $ rtx latest nodejs     # get the latest stable version of nodejs
  20.0.0
```
### `rtx local`

```
Sets or gets tool versions in the local .tool-versions or .rtx.toml file

Use this to set a tool's version when within a directory
Use `rtx global` to set a runtime version globally
This uses `.tool-version` by default unless there is a `.rtx.toml` file or if `RTX_USE_TOML`
is set. A future v2 release of rtx will default to using `.rtx.toml`.

Usage: local [OPTIONS] [RUNTIME]...

Arguments:
  [RUNTIME]...
          Runtimes to add to .tool-versions/.rtx.toml
          e.g.: nodejs@18
          if this is a single runtime with no version,
          the current value of .tool-versions/.rtx.toml will be displayed

Options:
  -p, --parent
          Recurse up to find a .tool-versions file rather than using the current directory only
          by default this command will only set the runtime in the current directory ("$PWD/.tool-versions")

      --pin
          Save exact version to `.tool-versions`
          e.g.: `rtx local --pin nodejs@18` will save `nodejs 18.0.0` to .tool-versions

      --fuzzy
          Save fuzzy version to `.tool-versions` e.g.: `rtx local --fuzzy nodejs@18` will save `nodejs 18` to .tool-versions This is the default behavior unless RTX_ASDF_COMPAT=1

      --remove <PLUGIN>
          Remove the plugin(s) from .tool-versions

      --path
          Get the path of the config file

Examples:
  # set the current version of nodejs to 18.x for the current directory
  # will use a precise version (e.g.: 18.0.0) in .tool-versions file
  $ rtx local nodejs@18

  # set nodejs to 18.x for the current project (recurses up to find .tool-versions)
  $ rtx local -p nodejs@18

  # set the current version of nodejs to 18.x for the current directory
  # will use a fuzzy version (e.g.: 18) in .tool-versions file
  $ rtx local --fuzzy nodejs@18

  # removes nodejs from .tool-versions
  $ rtx local --remove=nodejs

  # show the current version of nodejs in .tool-versions
  $ rtx local nodejs
  18.0.0
```
### `rtx ls`

```
List installed runtime versions

The "arrow (->)" indicates the runtime is installed, active, and will be used for running commands.
(Assuming `rtx activate` or `rtx env` is in use).

Usage: ls [OPTIONS]

Options:
  -p, --plugin <PLUGIN>
          Only show runtimes from [PLUGIN]

  -c, --current
          Only show runtimes currently specified in .tool-versions

Examples:
  $ rtx list
  -> nodejs     18.0.0 (set by ~/src/myapp/.tool-versions)
  -> python     3.11.0 (set by ~/.tool-versions)
     python     3.10.0

  $ rtx list --current
  -> nodejs     18.0.0 (set by ~/src/myapp/.tool-versions)
  -> python     3.11.0 (set by ~/.tool-versions)
```
### `rtx ls-remote`

```
List runtime versions available for install

note that these versions are cached for commands like `rtx install nodejs@latest`
however _this_ command will always clear that cache and fetch the latest remote versions

Usage: ls-remote <PLUGIN> [PREFIX]

Arguments:
  <PLUGIN>
          Plugin to get versions for

  [PREFIX]
          The version prefix to use when querying the latest version
          same as the first argument after the "@"

Examples:
  $ rtx ls-remote nodejs
  18.0.0
  20.0.0

  $ rtx ls-remote nodejs@18
  18.0.0
  18.1.0

  $ rtx ls-remote nodejs 18
  18.0.0
  18.1.0
```
### `rtx plugins install`

```
Install a plugin

note that rtx automatically can install plugins when you install a runtime
e.g.: `rtx install nodejs@18` will autoinstall the nodejs plugin

This behavior can be modified in ~/.config/rtx/config.toml

Usage: install [OPTIONS] [NAME] [GIT_URL]

Arguments:
  [NAME]
          The name of the plugin to install
          e.g.: nodejs, ruby
          Can specify multiple plugins: `rtx plugins install nodejs ruby python`

  [GIT_URL]
          The git url of the plugin

Options:
  -f, --force
          Reinstall even if plugin exists

  -a, --all
          Install all missing plugins
          This will only install plugins that have matching shorthands.
          i.e.: they don't need the full git repo url

  -v, --verbose...
          Show installation output

Examples:
  # install the nodejs via shorthand
  $ rtx install nodejs

  # install the nodejs plugin using a specific git url
  $ rtx install nodejs https://github.com/jdxcode/rtx-nodejs.git

  # install the nodejs plugin using the git url only
  # (nodejs is inferred from the url)
  $ rtx install https://github.com/jdxcode/rtx-nodejs.git

  # install the nodejs plugin using a specific ref
  $ rtx install nodejs http://github.com/jdxcode/rtx-nodejs.git#v1.0.0
```
### `rtx plugins ls`

```
List installed plugins

Can also show remotely available plugins to install.

Usage: ls [OPTIONS]

Options:
  -a, --all
          List all available remote plugins
          Same as `rtx plugins ls-remote`

  -u, --urls
          Show the git url for each plugin
          e.g.: https://github.com/asdf-vm/asdf-nodejs.git

Examples:
  $ rtx plugins ls
  nodejs
  ruby

  $ rtx plugins ls --urls
  nodejs                        https://github.com/asdf-vm/asdf-nodejs.git
  ruby                          https://github.com/asdf-vm/asdf-ruby.git
```
### `rtx plugins ls-remote`

```
List all available remote plugins

These are fetched from https://github.com/asdf-vm/asdf-plugins

Examples:
  $ rtx plugins ls-remote


Usage: ls-remote [OPTIONS]

Options:
  -u, --urls
          Show the git url for each plugin e.g.: https://github.com/asdf-vm/asdf-nodejs.git

      --only-names
          Only show the name of each plugin by default it will show a "*" next to installed plugins
```
### `rtx plugins uninstall`

```
Removes a plugin

Usage: uninstall <PLUGIN>...

Arguments:
  <PLUGIN>...
          Plugin(s) to remove

Examples:
  $ rtx uninstall nodejs
```
### `rtx plugins update`

```
Updates a plugin to the latest version

note: this updates the plugin itself, not the runtime versions

Usage: update [OPTIONS] [PLUGIN]...

Arguments:
  [PLUGIN]...
          Plugin(s) to update

Options:
  -a, --all
          Update all plugins

Examples:
  $ rtx plugins update --all        # update all plugins
  $ rtx plugins update nodejs       # update only nodejs
  $ rtx plugins update nodejs@beta  # specify a ref
```
### `rtx prune`

```
Delete unused versions of tools
rtx tracks which config files have been used in ~/.local/share/rtx/tracked_config_files
Versions which are no longer the latest specified in any of those configs are deleted.
Versions installed only with environment variables (`RTX_<PLUGIN>_VERSION`) will be deleted,
as will versions only referenced on the command line (`rtx exec <PLUGIN>@<VERSION>`).

Usage: prune [OPTIONS] [PLUGINS]...

Arguments:
  [PLUGINS]...
          Prune only versions from these plugins

Options:
      --dry-run
          Do not actually delete anything

Examples:
  $ rtx prune --dry-run
  rm -rf ~/.local/share/rtx/versions/nodejs/18.0.0
  rm -rf ~/.local/share/rtx/versions/nodejs/18.0.1
```
### `rtx reshim`

```
[experimental] rebuilds the shim farm

this requires that the shims_dir is set

Usage: reshim

Examples:
  $ rtx settings set experimental true
  $ rtx settings set shims_dir ~/.rtx/shims
  $ rtx reshim
  $ ~/.rtx/shims/node -v
  v18.0.0
```
### `rtx self-update`

```
Updates rtx itself
Uses whatever package manager was used to install rtx or just downloads
a binary from GitHub Releases if rtx was installed manually.
Supports: standalone, brew, deb, rpm

Usage: self-update

Examples:
  $ rtx self-update
  Checking target-arch... macos-arm64
  Checking current version... v1.0.0
  Checking latest released version... v1.22.0-DEBUG macos-arm64 (built 2023-03-05)
  New release found! v1.0.0 --> v1.22.0-DEBUG macos-arm64 (built 2023-03-05)
  New release is compatible

  rtx release status:
    * Current exe: "/Users/jdx/bin/rtx"
    * New exe release: "rtx-v1.22.0-DEBUG macos-arm64 (built 2023-03-05)-macos-arm64"

  The new release will be downloaded/extracted and the existing binary will be replaced.
  Do you want to continue? [Y/n] y
  Downloading...
  Extracting archive... Done
  Replacing binary file... Done
  Updated rtx to 1.22.0-DEBUG macos-arm64 (built 2023-03-05)
```
### `rtx settings get`

```
Show a current setting

This is the contents of a single entry in ~/.config/rtx/config.toml

Note that aliases are also stored in this file
but managed separately with `rtx aliases get`

Usage: get <KEY>

Arguments:
  <KEY>
          The setting to show

Examples:
  $ rtx settings get legacy_version_file
  true
```
### `rtx settings ls`

```
Show current settings

This is the contents of ~/.config/rtx/config.toml

Note that aliases are also stored in this file
but managed separately with `rtx aliases`

Usage: ls

Examples:
  $ rtx settings
  legacy_version_file = false
```
### `rtx settings set`

```
Add/update a setting

This modifies the contents of ~/.config/rtx/config.toml

Usage: set <KEY> <VALUE>

Arguments:
  <KEY>
          The setting to set

  <VALUE>
          The value to set

Examples:
  $ rtx settings set legacy_version_file true
```
### `rtx settings unset`

```
Clears a setting

This modifies the contents of ~/.config/rtx/config.toml

Usage: unset <KEY>

Arguments:
  <KEY>
          The setting to remove

Examples:
  $ rtx settings unset legacy_version_file
```
### `rtx shell`

```
Sets a tool version for the current shell session

Only works in a session where rtx is already activated.

Usage: shell [OPTIONS] [RUNTIME]...

Arguments:
  [RUNTIME]...
          Runtime version(s) to use

Options:
  -u, --unset
          Removes a previously set version

Examples:
  $ rtx shell nodejs@18
  $ node -v
  v18.0.0
```
### `rtx uninstall`

```
Removes runtime versions

Usage: uninstall <RUNTIME>...

Arguments:
  <RUNTIME>...
          Runtime(s) to remove

Examples:
  $ rtx uninstall nodejs@18.0.0 # will uninstall specific version
  $ rtx uninstall nodejs        # will uninstall current nodejs version
```
### `rtx version`

```
Show rtx version

Usage: version
```
### `rtx where`

```
Display the installation path for a runtime

Must be installed.

Usage: where <RUNTIME>

Arguments:
  <RUNTIME>
          Runtime(s) to look up
          e.g.: ruby@3
          if "@<PREFIX>" is specified, it will show the latest installed version
          that matches the prefix
          otherwise, it will show the current, active installed version

Examples:
  # Show the latest installed version of nodejs
  # If it is is not installed, errors
  $ rtx where nodejs@18
  /home/jdx/.local/share/rtx/installs/nodejs/18.0.0

  # Show the current, active install directory of nodejs
  # Errors if nodejs is not referenced in any .tool-version file
  $ rtx where nodejs
  /home/jdx/.local/share/rtx/installs/nodejs/18.0.0
```
### `rtx which`

```
Shows the path that a bin name points to

Usage: which [OPTIONS] <BIN_NAME>

Arguments:
  <BIN_NAME>
          

Options:
      --plugin
          Show the plugin name instead of the path

      --version
          Show the version instead of the path

Examples:
  $ rtx which node
  /home/username/.local/share/rtx/installs/nodejs/18.0.0/bin/node
  $ rtx which node --plugin
  nodejs
  $ rtx which node --version
  18.0.0
```
<!-- RTX:COMMANDS -->

## FAQs

### I don't want to put a `.tool-versions` file into my project since git shows it as an untracked file.

You can make git ignore these files in 3 different ways:

- Adding `.tool-versions` to project's `.gitignore` file. This has the downside that you need to commit the change to the ignore file.
- Adding `.tool-versions` to project's `.git/info/exclude`. This file is local to your project so there is no need to commit it.
- Adding `.tool-versions` to global gitignore (`core.excludesFile`). This will cause git to ignore `.tool-versions` files in all projects. You can explicitly add one to a project if needed with `git add --force .tool-versions`.

### rtx is failing or not working right

First try setting `RTX_DEBUG=1` or `RTX_TRACE=1` and see if that gives you more information.
You can also set `RTX_LOG_FILE_LEVEL=debug RTX_LOG_FILE=/path/to/logfile` to write logs to a file.

If something is happening with the activate hook, you can try disabling it and calling `eval "$(rtx hook-env)"` manually.
It can also be helpful to use `rtx env` which will just output environment variables that would be set.
Also consider using [shims](#shims) which can be more compatible.

If runtime installation isn't working right, try using the `--raw` flag which will install things in
series and connect stdin/stdout/stderr directly to the terminal. If a plugin is trying to interact
with you for some reason this will make it work.

Of course check the version of rtx with `rtx --version` and make sure it is the latest. Use `rtx self-update`
to update it. `rtx cache clean` can be used to wipe the internal cache and `rtx implode` can be used
to remove everything except config.

Before submitting a ticket, it's a good idea to test what you were doing with asdf. That way we can rule
out if the issue is with rtx or if it's with a particular plugin. For example, if `rtx install python@latest`
doesn't work, try running `asdf install python latest` to see if it's an issue with asdf-python.

Lastly, there is `rtx doctor` which will show diagnostic information and any warnings about issues
detected with your setup. If you submit a bug report, please include the output of `rtx doctor`.

### Windows support?

This is something we'd like to add! https://github.com/jdxcode/rtx/discussions/66

It's not a near-term goal and it would require plugin modifications, but it should be feasible.

### How do I use rtx with http proxies?

Short answer: just set `http_proxy` and `https_proxy` environment variables. These should be lowercase.

rtx doesn't really do anything with http itself. The only exception to that is checking for new versions
and `rtx self-update`. It uses `git` to clone plugins and the plugins themselves generally will download
files with `curl` or `wget`.

However this is really up to the plugin. If you're having a proxy-related issue installing something
you should post an issue on the plugin's repo.

### How do the shorthand plugin names map to repositories?

e.g.: how does `rtx plugin install nodejs` know to fetch [https://github.com/asdf-vm/asdf-nodejs](https://github.com/asdf-vm/asdf-nodejs)?

asdf maintains [an index](https://github.com/asdf-vm/asdf-plugins) of shorthands that rtx uses as a base.
This is regularly updated every time that rtx has a release. This repository is stored directly into
the codebase [here](./src/default_shorthands.rs). The bottom of that file contains modifications that
rtx makes. For example, we add `node` which points to the same plugin as `nodejs` and change `python`
to point to [rtx-python](https://github.com/jdxcode/rtx-python) which is a fork of [asdf-python](https://github.com/danhper/asdf-python)
with some rtx features like virtualenv support.

Over time I suspect that more plugins will be forked like rtx-python as we're able to offer more rtx-specific
enhancements.

### How do I migrate from asdf?

First, just install rtx with `rtx activate` like in the getting started guide and remove asdf from your
shell rc file.

Then you can just run `rtx install` in a directory with an asdf `.tool-versions` file and it will
install the runtimes. You could attempt to avoid this by copying the internal directory from asdf over
to rtx with `cp -r ~/.asdf ~/.local/share/rtx`. That _should_ work because they use the same structure,
however this isn't officially supported or regularly tested. Alternatively you can set `RTX_DATA_DIR=~/.asdf`
and see what happens.

### How compatible is rtx with asdf?

rtx should be able to read/install any `.tool-versions` file used by asdf. Any asdf plugin 
should be usable in rtx. The commands in rtx are slightly
different, such as `rtx install nodejs@18.0.0` vs `asdf install nodejs 18.0.0`—this is done so 
multiple tools can be specified at once. However, asdf-style syntax is still supported: (`rtx 
install nodejs 18.0.0`). This is the case for most commands, though the help for the command may 
say that asdf-style syntax is supported.

When in doubt, just try asdf syntax and see if it works.  If it doesn't open a ticket. It may 
not be possible to support every command identically, but
we should attempt to make things as consistent as possible.

This isn't important for usability reasons so much as making it so plugins continue to work that 
call asdf commands.

If you need to switch to/from asdf or work in a project with asdf users, you can set 
[`RTX_ASDF_COMPAT=1`](#rtx_asdf_compat1). That prevents
rtx from writing `.tool-versions` files that will not be
compatible with asdf. Also consider using `.rtx.toml` instead which won't conflict with asdf setups.

### rtx isn't working with tmux

It's been reported that PATH doesn't work correctly with tmux. The fix seems to be calling `hook-env`
right after activating:

```bash
eval "$(rtx activate bash)"
eval "$(rtx hook-env)"
```

This can also be useful if you need to use a runtime right away in an rc file. The default behavior
of `rtx activate` is that it will only run `hook-env` when the shell is about to be displayed, not
immediately after activating. Not calling `hook-env` immediately appears to work better with direnv.

## Comparison to asdf

rtx is mostly a clone of asdf, but there are notable areas where improvements have been made.

### Performance

asdf made (what I consider) a poor design decision to use shims that go between a call to a runtime
and the runtime itself. e.g.: when you call `node` it will call an asdf shim file `~/.asdf/shims/node`,
which then calls `asdf exec`, which then calls the correct version of node.

These shims have terrible performance, adding ~120ms to every runtime call. rtx does not use shims and instead
updates `PATH` so that it doesn't have any overhead when simply calling binaries. These shims are the main reason that I wrote this. Note that in the demo gif at the top of this README
that `rtx` isn't actually used when calling `node -v` for this reason. The performance is
identical to running node without using rtx.

I don't think it's possible for asdf to fix these issues. The author of asdf did a great writeup
of [performance problems](https://stratus3d.com/blog/2022/08/11/asdf-performance/). asdf is written
in bash which certainly makes it challenging to be performant, however I think the real problem is the
shim design. I don't think it's possible to fix that without a complete rewrite.

rtx does call an internal command `rtx hook-env` every time the directory has changed, but because
it's written in Rust, this is very quick—taking ~10ms on my machine. 4ms if there are no changes, 14ms if it's
a full reload.

tl;dr: asdf adds overhead (~120ms) when calling a runtime, rtx adds a small amount of overhead (~10ms)
when the prompt loads.

### Environment variables in rtx

asdf only helps manage runtime executables. However, some tools are managed via environment variables
(notably Java which switches via `JAVA_HOME`). This isn't supported very well in asdf and requires
a separate shell extension just to manage.

However asdf _plugins_ have a `bin/exec-env` script that is used for exporting environment variables
like [`JAVA_HOME`](https://github.com/halcyon/asdf-java/blob/master/bin/exec-env). rtx simply exports
the environment variables from the `bin/exec-env` script in the plugin but places them in the shell
for _all_ commands. In asdf it only exports those commands when the shim is called. This means if you
call `java` it will set `JAVA_HOME`, but not if you call some Java tool like `mvn`.

This means we're just using the existing plugin script but because rtx doesn't use shims it can be
used for more things. It would be trivial to make a plugin that exports arbitrary environment
variables like [dotenv](https://github.com/motdotla/dotenv) or [direnv](https://github.com/direnv/direnv).

### UX

Some commands are the same in asdf but others have been changed. Everything that's possible
in asdf should be possible in rtx but may use slightly different syntax. rtx has more forgiving commands,
such as using fuzzy-matching, e.g.: `rtx install nodejs@18`. While in asdf you _can_ run
`asdf install nodejs latest:18`, you can't use `latest:18` in a `.tool-versions` file or many other places.
In `rtx` you can use fuzzy-matching everywhere.

asdf requires several steps to install a new runtime if the plugin isn't installed, e.g.:

```sh-session
$ asdf plugin add nodejs
$ asdf install nodejs latest:18
$ asdf local nodejs latest:18
```

In `rtx` this can all be done in a single step to set the local runtime version. If the plugin
and/or runtime needs to be installed it will prompt:

[![asciicast](https://asciinema.org/a/564031.svg)](https://asciinema.org/a/564031)

I've found asdf to be particularly rigid and difficult to learn. It also made strange decisions like
having `asdf list all` but `asdf latest --all` (why is one a flag and one a positional argument?).
`rtx` makes heavy use of aliases so you don't need to remember if it's `rtx plugin add nodejs` or
`rtx plugin install nodejs`. If I can guess what you meant, then I'll try to get rtx to respond
in the right way.

That said, there are a lot of great things about asdf. It's the best multi-runtime manager out there
and I've really been impressed with the plugin system. Most of the design decisions the authors made
were very good. I really just have 2 complaints: the shims and the fact it's written in Bash.

### CI/CD

Using rtx in CI/CD is a great way to synchronize tool versions for dev/build.

### GitHub Actions

Use [`jdxcode/rtx-action`](https://github.com/jdxcode/rtx-action):

```yaml
- uses: jdxcode/rtx-action@v1
- run: node -v # will be the node version from `.tool-versions`
```

## Shims

While the PATH design of rtx works great in most cases, there are some situations where shims are
preferable. One example is when calling rtx binaries from an IDE.

To support this, there is experimental support for using rtx in a "shim" mode. To use:

```
$ rtx settings set experimental true
$ rtx settings set shims_dir ~/.rtx/shims
$ rtx i nodejs@18.0.0
$ rtx reshim
$ ~/.rtx/shims/node -v
v18.0.0
```

## direnv

[direnv](https://direnv.net) and rtx both manage environment variables based on directory. Because they both analyze
the current environment variables before and after their respective "hook" commands are run, they can conflict with each other.
As a result, there were a [number of issues with direnv](https://github.com/jdxcode/rtx/issues/8).
However, we think we've mitigated these. If you find that rtx and direnv are not working well together,
please comment on that ticket ideally with a good description of your directory layout so we can
reproduce the problem.

If there are remaining issues, they're likely to do with the ordering of PATH. This means it would
really only be a problem if you were trying to manage the same runtime with direnv and rtx. For example,
you may use `layout python` in an `.envrc` but also be maintaining a `.tool-versions` file with python
in it as well.

A more typical usage of direnv would be to set some arbitrary environment variables, or add unrelated
binaries to PATH. In these cases, rtx will not interfere with direnv.

### rtx inside of direnv (`use rtx` in `.envrc`)

If you do encounter issues with `rtx activate`, or just want to use direnv in an alternate way,
this is a simpler setup that's less likely to cause issues—at the cost of functionality.

This may be required if you want to use direnv's `layout python` with rtx. Otherwise there are
situations where rtx will override direnv's PATH. `use rtx` ensures that direnv always has control.

To do this, first use `rtx` to build a `use_rtx` function that you can use in `.envrc` files:

```sh-session
$ rtx direnv activate > ~/.config/direnv/lib/use_rtx.sh
```

Now in your `.envrc` file add the following:

```sh-session
use rtx
```

direnv will now call rtx to export its environment variables. You'll need to make sure to add `use_rtx`
to all projects that use rtx (or use direnv's `source_up` to load it from a subdirectory). You can also add `use rtx` to `~/.config/direnv/direnvrc`.

Note that in this method direnv typically won't know to refresh `.tool-versions` files
unless they're at the same level as a `.envrc` file. You'll likely always want to have
a `.envrc` file next to your `.tool-versions` for this reason. To make this a little
easier to manage, I encourage _not_ actually using `.tool-versions` at all, and instead
setting environment variables entirely in `.envrc`:

```
export RTX_NODEJS_VERSION=18.0.0
export RTX_PYTHON_VERSION=3.11
```

Of course if you use `rtx activate`, then these steps won't have been necessary and you can use rtx
as if direnv was not used.

If you continue to struggle, you can also try using the [experimental shims feature](#shims).

### Do you need direnv?

While making rtx compatible with direnv is, and will always be a major goal of this project, I also
want rtx to be capable of replacing direnv if needed. This is why rtx includes support for managing
env vars and virtualenv for python using `.rtx.toml`.

If you find you continue to need direnv, please open an issue and let me know what it is to see if
it's something rtx could support. rtx will never be as capable as direnv with a DSL like `.envrc`,
but I think we can handle enough common use cases to make that unnecessary for most people.

## Cache Behavior

rtx makes use of caching in many places in order to be efficient. The details about how long to keep
cache for should eventually all be configurable. There may be gaps in the current behavior where
things are hardcoded, but I'm happy to add more settings to cover whatever config is needed.

Below I explain the behavior it uses around caching. If you're seeing behavior where things don't appear
to be updating, this is a good place to start.

### Plugin/Runtime Cache

Each plugin has a cache that's stored in `~/$RTX_CACHE_DIR/<PLUGIN>`. It stores
the list of versions available for that plugin (`rtx ls-remote <PLUGIN>`), the legacy filenames (see below),
the list of aliases, the bin directories within each runtime installation, and the result of 
running `exec-env` after the runtime was installed.

Remote versions are updated daily by default or anytime that `rtx ls-remote` is called explicitly. The file is
zlib messagepack, if you want to view it you can run the following (requires [msgpack-cli](https://github.com/msgpack/msgpack-cli)).

```sh-session
cat ~/$RTX_CACHE_DIR/nodejs/remote_versions.msgpack.z | perl -e 'use Compress::Raw::Zlib;my $d=new Compress::Raw::Zlib::Inflate();my $o;undef $/;$d->inflate(<>,$o);print $o;' | msgpack-cli decode
```

Note that the caching of `exec-env` may be problematic if the script isn't simply exporting 
static values. The vast majority of `exec-env` scripts only export static values, but if you're 
working with a plugin that has a dynamic `exec-env` submit
a ticket and we can try to figure out what to do.

Caching `exec-env` massively improved the performance of rtx since it requires calling bash 
every time rtx is initialized. Ideally, we can keep this
behavior.