Skip to content

bug: asdf shims not present in non-interactive shell #2085

@Kallin

Description

@Kallin

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions