asdf-vm / asdf-vm/asdf

bug: asdf shims not present in non-interactive shell

Open
#2,085 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Go
Stars
25.6k
Forks
941
Avg merge
9h 24m
Merged PRs (30d)
3

Description

### Describe the Bug

The ASDF shims are not at the front of the path when using a non-interactive shell on OSX.

### Steps to Reproduce

I'm using asdf on osx with zsh, and put the following into my .zshrc as suggested in the docs

`export PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"`

I recently installed Cursor, and noticed that it's integrated 'composer' agent AI was using a PATH that did not have ASDF at the front. Specifcally, I wanted it to use an ASDF managed Ruby, but the 'new' path had `/usr/bin` in the front, and Composer would find the system-default Ruby instead.

It turns out, adding this line to .zshenv instead of .zshrc has fixed the issue. Perhaps the docs should suggest .zshenv instead of .zshrc so that even non-interactive shells can access the desired tool versions?

```
brew info asdf
==> asdf: stable 0.16.7 (bottled), HEAD
Extendable version manager with support for Ruby, Node.js, Erlang & more
https://asdf-vm.com/
Installed
/opt/homebrew/Cellar/asdf/0.16.2 (10 files, 10.9MB) *
Poured from bottle using the formulae.brew.sh API on 2025-02-14 at 15:59:43
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/a/asdf.rb
License: MIT
==> Dependencies
Build: go ✘
==> Options
--HEAD
Install HEAD version
==> Caveats
zsh completions have been installed to:
/opt/homebrew/share/zsh/site-functions
==> Analytics
install: 12,140 (30 days), 60,264 (90 days), 146,652 (365 days)
install-on-request: 12,134 (30 days), 60,241 (90 days), 146,598 (365 days)
build-error: 9 (30 days)
```

### Expected Behaviour

pick up ASDF managed ruby when in non-interactive shell

### Actual Behaviour

picked up system ruby from /usr/bin

### Environment

```shell
OS:
Darwin TE1365 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000 arm64

SHELL:
zsh 5.9 (x86_64-apple-darwin23.0)

BASH VERSION:
3.2.57(1)-release

ASDF VERSION:
0.16.2

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/knagelberg/.asdf
ASDF_CONFIG_FILE=/Users/knagelberg/.asdfrc

ASDF INSTALLED PLUGINS:
java https://github.com/halcyon/asdf-java.git ff6f8509c5fdc9e242740d58010900d5de938728
nodejs https://github.com/asdf-vm/asdf-nodejs.git 2bd35bcf4bd017dc364fa70a22f8650f14e88ced
poetry https://github.com/asdf-community/asdf-poetry.git fed46cbf209e9f12aa986d5287db38d51aec59a0
python https://github.com/danhper/asdf-python.git a3a01856098d6d2b9642e382f5b38e70275726d1
ruby https://github.com/asdf-vm/asdf-ruby.git 3a1f574c51292cc84f4d8893d101078cba89f640
zoxide https://github.com/nyrst/asdf-zoxide.git 8ed95c97ca31ea91020afa03c26849ec12dac584
```

### asdf plugins affected (if relevant)

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating the documentation passage that recommends adding ASDF shims to .zshrc, then compare its behavior with .zshenv in a non-interactive zsh shell. Update the guidance if appropriate and verify that an ASDF-managed Ruby is selected instead of /usr/bin/ruby.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby, zsh
Domain
cli, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.