chruby-fish
chruby-fish copied to clipboard
chruby cannot successfully switch to mruby-3.0.0 under Fish
Description
chruby cannot successfully switch to mruby-3.0.0 under Fish, but seems to work as expected under Bash in spite of raising a Ruby NoMethodError exception when attempting to change rubies. The latter issue was raised upstream with chruby.
Steps To Reproduce
Steps to reproduce the bug:
-
ruby-install mruby-3.0.0
-
exec fish --login
, which is required for chruby to pick up the newly installed Ruby -
chruby mruby
orchruby mruby-3.0.0
-
chruby
, which shows that the selected Ruby hasn't changed
Expected Behavior
chruby-fish should not halt execution or report a different exit status than chruby itself. If the Ruby exception is not a show-stopper, then chruby-fish should not halt execution when the Bash version of chruby continues, and should change to the requested Ruby under the same circumstances that the Bash version of chruby does.
Actual Behavior
My default Ruby is currently set to Ruby 3.1.2. ruby-install mruby-3.0.0
succeeds without error. Under Bash, the following error still occurs:
$ bash --version | head -1
GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin20.6.0)
$ chruby mruby
trace (most recent call last):
-:1: undefined method 'defined?' (NoMethodError)
but the current Ruby is changed to mruby-3.0.0, RUBY_ROOT is set correctly, and mirb is executable. However, under Fish, the script exits non-zero. This error stops chruby from switching the current Ruby, and RUBY_ROOT and other variables remain unchanged.
~> bash -c 'echo $BASH_VERSION'
5.1.16(1)-release
~> echo $FISH_VERSION
3.4.1
~> chruby mruby
trace (most recent call last):
-:1: undefined method 'defined?' (NoMethodError)
[I] user@localhost ~ [1]> chruby
jruby-9.3.4.0
mruby-3.0.0
ruby-2.7.0
ruby-2.7.5
ruby-3.0.3
ruby-3.0.4
ruby-3.1.0
ruby-3.1.1
* ruby-3.1.2
ruby-3.2.0-preview1
truffleruby-22.1.0
truffleruby-graalvm-22.1.0
~> chruby --version
chruby: 0.3.9
chruby-fish: 0.8.2
~> gem env | sed "s/$(id -un)/\$LOGNAME/g"
RubyGems Environment:
- RUBYGEMS VERSION: 3.3.7
- RUBY VERSION: 3.1.2 (2022-04-12 patchlevel 20) [x86_64-darwin20]
- INSTALLATION DIRECTORY: /Users/$LOGNAME/.gem/ruby/3.1.2
- USER INSTALLATION DIRECTORY: /Users/$LOGNAME/.gem/ruby/3.1.0
- RUBY EXECUTABLE: /Users/$LOGNAME/.rubies/ruby-3.1.2/bin/ruby
- GIT EXECUTABLE: /usr/local/bin/git
- EXECUTABLE DIRECTORY: /Users/$LOGNAME/.gem/ruby/3.1.2/bin
- SPEC CACHE DIRECTORY: /Users/$LOGNAME/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/$LOGNAME/.rubies/ruby-3.1.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-20
- GEM PATHS:
- /Users/$LOGNAME/.gem/ruby/3.1.2
- /Users/$LOGNAME/.rubies/ruby-3.1.2/lib/ruby/gems/3.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["https://rubygems.org"]
- :concurrent_downloads => 4
- "gem" => "--env-shebang --minimal-deps --no-document --patch --suggestions --wrappers"
- REMOTE SOURCES:
- https://rubygems.org
- SHELL PATH:
- /Users/$LOGNAME/.gem/ruby/3.1.2/bin
- /Users/$LOGNAME/.rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/bin
- /Users/$LOGNAME/.rubies/ruby-3.1.2/bin
- /Users/$LOGNAME/bin
- /Users/$LOGNAME/perl5/bin
- /usr/local/bin
- /usr/local/sbin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/puppetlabs/pdk/bin
- /opt/X11/bin
- /opt/puppetlabs/bin
- /Library/Apple/usr/bin
- /Users/$LOGNAME/bin
- /Users/$LOGNAME/perl5/bin
- /usr/local/sbin
- /usr/local/opt/openssl/bin
- /usr/local/Cellar/[email protected]/3.9.12/libexec/bin
- /usr/local/opt/[email protected]/bin
- /usr/local/opt/openssl@3/bin
- /Users/$LOGNAME/.local/bin/jetbrains
- /usr/local/opt/[email protected]/bin
- /usr/local/opt/gcc/bin
- /Users/$LOGNAME/node_modules/bin
- /Users/$LOGNAME/go/bin