-
-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-interactive chruby-exec
fails with zsh:1: command not found: chruby
#502
Comments
@amomchilov Could you post your We cannot always specify Also note that chruby-0.3.9 was indeed released 2014-11-23. GitHub releases are separate from the git tags, and I didn't start adding GitHub releases for git tags until much later. |
My zsh_user_path=(
"/opt/homebrew/bin"
)
export path=($zsh_user_path $path)
if [[ -f"/opt/homebrew/opt/chruby/share/chruby/chruby.sh" ]]; then
source "/opt/homebrew/opt/chruby/share/chruby/chruby.sh"
fi My
|
FWIW there is |
Hey @eregon, I agree that's the right approach in the abstract, but regrettably, that's just not the common convention with ZSH. For example, Homebrew's official installation instructions used to suggest adding to your To me, the most puzzling part here is why |
@postmodern Please take a look at the I think the Homebrew version is not sourcing the full path when executing the shell. I tested the GitHub version and it worked as I expected. I looked at the homebrew recipe and don't see any overrides so I assume the bottle is broken. I'll try to do a source install for homebrew and see what that does. Diff:
# chruby-exec in homebrew
#!/usr/bin/env bash
source "${0%/*}/../share/chruby/chruby.sh"
case "$1" in
-h|--help)
echo "usage: chruby-exec RUBY [RUBYOPTS] -- COMMAND [ARGS...]"
exit
;;
-V|--version)
echo "chruby version $CHRUBY_VERSION"
exit
;;
esac
if (( $# == 0 )); then
echo "chruby-exec: RUBY and COMMAND required" >&2
exit 1
fi
argv=()
for arg in "$@"; do
shift
if [[ "$arg" == "--" ]]; then break
else argv+=($arg)
fi
done
if (( $# == 0 )); then
echo "chruby-exec: COMMAND required" >&2
exit 1
fi
command="chruby $(printf "%q " "${argv[@]}") && $(printf "%q " "$@")"
if [[ -t 0 ]]; then exec "$SHELL" -i -l -c "$command"
else exec "$SHELL" -l -c "$command"
fi # chruby-exec on GitHub HEAD
#!/usr/bin/env bash
chruby_sh="${0%/*}/../share/chruby/chruby.sh"
source "$chruby_sh"
case "$1" in
-h|--help)
echo "usage: chruby-exec RUBY [RUBYOPTS] -- COMMAND [ARGS...]"
exit
;;
-V|--version)
echo "chruby version $CHRUBY_VERSION"
exit
;;
esac
if (( $# == 0 )); then
echo "chruby-exec: RUBY and COMMAND required" >&2
exit 1
fi
argv=()
for arg in "$@"; do
shift
if [[ "$arg" == "--" ]]; then break
else argv+=($arg)
fi
done
if (( $# == 0 )); then
echo "chruby-exec: COMMAND required" >&2
exit 1
fi
shell_opts=("-l")
[[ -t 0 ]] && shell_opts+=("-i")
source_command="command -v chruby >/dev/null || source $chruby_sh"
chruby_command="chruby $(printf "%q " "${argv[@]}")"
sub_command="$(printf "%q " "$@")"
command="$source_command; $chruby_command && exec $sub_command"
exec "$SHELL" "${shell_opts[@]}" -c "$command" |
Confirmed that |
The issue here is that |
Description
chruby.sh
is typically sourced from~/.zshrc
, which is only run in interactive shells. For non-interactive shells,chruby-exec
callszsh
without the-i
:chruby/bin/chruby-exec
Line 41 in 6719201
This causes the
~/.zshrc
to never be sourced, and thus, forchruby
to be unavailable.Steps To Reproduce
Steps to reproduce the bug:
Install the latest release (0.39.0 right now) with
brew install chruby
Run
chruby-exec
with a non-terminal STDIN. E.g. with:Expected Behavior
Run the command successfully, (in this example,
ruby --version
). It works correctly if you drop theecho "abc" |
:$ chruby-exec "ruby-3.3.0" -- ruby --version ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
This works fine because it hits this other branch, which include
-i
and runs~/.zshrc
:chruby/bin/chruby-exec
Line 40 in 6719201
This also works on the latest
master
branch, so it looks like it's a packaging/release issue:Actual Behavior
Notes
https://github.com/postmodern/chruby/releases/tag/v0.3.9 was release in April 19, 2023, but for some reason, it doesn't include this change to
chruby-exec
from 2014. I confirmed this in 2 ways:bin/chruby-exec
of thechruby-0.3.9.tar.gz
downloaded right from the release page/opt/homebrew/bin/chruby-exec
installed by homebrew.It looks to me like the release process just didn't package up this file correctly.
Environment
The text was updated successfully, but these errors were encountered: