Skip to content

chruby reports exit status 0 under Bash, but still throws a Ruby exception when switching to mruby #477

@todd-a-jacobs

Description

@todd-a-jacobs

Description

ruby-install sucessfully installs mruby-3.0.0 without errors. However, chruby reports a successful exit status under Bash, but still throws a Ruby exception when attempting to switch to mruby.

Whatever the underlying error is, it causes chruby-fish to exit non-zero, which prevents chruby from switching to mruby at all. This has been reported separately to chruby-fish as a related issue.

Steps To Reproduce

Steps to reproduce the bug:

  1. ruby-install mruby-3.0.0
  2. exec bash, which is required for chruby to pick up the newly installed Ruby
  3. chruby mruby; echo or chruby mruby-3.0.0

Expected Behavior

chruby should either exit non-zero if there's an error during the switch, or not display an error if the Ruby exception raised is expected.

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 occurs:

$ chruby mruby
trace (most recent call last):
-:1: undefined method 'defined?' (NoMethodError)

$ echo $?
0

The current Ruby is still changed to mruby-3.0.0, RUBY_ROOT is set correctly, and mirb is executable.

Environment

$ bash --version | head -1
GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin20.6.0)

$ chruby --version
chruby: 0.3.9

$ ruby --version
mruby 3.0.0 (2021-03-05)

$ gem --version
4.0.3

$ gem env | sed "s/$(id -un)/\$LOGNAME/g"
RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.3
  - RUBY VERSION: 2.6.3 (2019-04-16 patchlevel 62) [universal.x86_64-darwin20]
  - INSTALLATION DIRECTORY: /Users/$LOGNAME/.gem
  - USER INSTALLATION DIRECTORY: /Users/$LOGNAME/.gem/ruby/2.6.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
  - GIT EXECUTABLE: /usr/local/bin/git
  - EXECUTABLE DIRECTORY: /Users/$LOGNAME/.gem/bin
  - SPEC CACHE DIRECTORY: /Users/$LOGNAME/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-20
  - GEM PATHS:
     - /Users/$LOGNAME/.gem
  - 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///bin
     - /Users/$LOGNAME/.rubies/mruby-3.0.0/bin
     - /usr/local/opt/python@3.9/libexec/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/python@3.9/3.9.12/libexec/bin
     - /usr/local/opt/openssl@1.1/bin
     - /usr/local/opt/openssl@3/bin
     - /Users/$LOGNAME/.local/bin/jetbrains
     - /usr/local/opt/v8@3.15/bin
     - /usr/local/opt/gcc/bin
     - /Users/$LOGNAME/node_modules/bin
     - /Users/$LOGNAME/go/bin

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions