postmodern / chruby

Changes the current Ruby
MIT License
2.85k stars 190 forks source link

Chruby puts a missing directory on the PATH #489

Open schneems opened 1 year ago

schneems commented 1 year ago

Description

Ruby install + chruby puts an missing directory on PATH. It's not a bug per-say but I wanted to check and see if it's intentional or not.

I wrote a tool to help people diagnose PATH issues and noticed this chruby while testing.

Steps To Reproduce

$ cargo install cargo-whichp
$ cargo whichp a-command-that-does-not-exist
Program "a-command-that-does-not-exist" not found

Info: No other executables with the same name are found on the PATH

Info: These executables have the closest spelling to "a-command-that-does-not-exist" but did not match:
      "mbedtls-selftest", "qt-cmake-standalone-test", "g-ir-annotation-tool"

Info: The following directories on PATH were searched (top to bottom):
  - [OK     ] "/Users/rschneeman/.gem/ruby/3.1.3/bin"
  - [MISSING] "/Users/rschneeman/.rubies/ruby-3.1.3/lib/ruby/gems/3.1.0/bin"
  - [OK     ] "/Users/rschneeman/.rubies/ruby-3.1.3/bin"
  - [OK     ] "/Users/rschneeman/.cargo/bin"
  - [OK     ] "/usr/local/bin"
  - [OK     ] "/usr/local/sbin"
  - [OK     ] "/Users/rschneeman/bin/dotfiles/bin/"
  - [OK     ] "/usr/local/bin"
  - [OK     ] "/System/Cryptexes/App/usr/bin"
  - [OK     ] "/usr/bin"
  - [OK     ] "/bin"
  - [OK     ] "/usr/sbin"
  - [OK     ] "/sbin"
  - [OK     ] "/Users/rschneeman/.cargo/bin"
Explanation:
    [OK     ] - Path part is a valid, non-empty, directory
    [MISSING] - Path part does not exist exist on disk, no such directory

It puts this on the PATH but it doesn't seem to actually be a directory:

  - [MISSING] "/Users/rschneeman/.rubies/ruby-3.1.3/lib/ruby/gems/3.1.0/bin"

Expected Behavior

Directories on the PATH are all on disk

Actual Behavior

  - [MISSING] "/Users/rschneeman/.rubies/ruby-3.1.3/lib/ruby/gems/3.1.0/bin"
$ ls /Users/rschneeman/.rubies/ruby-3.1.3/lib/ruby/gems/3.1.0/bin
ls: /Users/rschneeman/.rubies/ruby-3.1.3/lib/ruby/gems/3.1.0/bin: No such file or directory

Environment

$ bash --version
GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin20.6.0)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
⛄️ 3.1.3 🚀 /private/tmp/lol-yolo (main)
$  zsh --version
zsh 5.8.1 (x86_64-apple-darwin22.0)
⛄️ 3.1.3 🚀 /private/tmp/lol-yolo (main)
$ chruby --version
chruby: 0.3.9
⛄️ 3.1.3 🚀 /private/tmp/lol-yolo (main)
$ ruby --version
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x86_64-darwin20]
⛄️ 3.1.3 🚀 /private/tmp/lol-yolo (main)
$ gem --version
3.3.26
⛄️ 3.1.3 🚀 /private/tmp/lol-yolo (main)
$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.3.26
  - RUBY VERSION: 3.1.3 (2022-11-24 patchlevel 185) [x86_64-darwin20]
  - INSTALLATION DIRECTORY: /Users/rschneeman/.gem/ruby/3.1.3
  - USER INSTALLATION DIRECTORY: /Users/rschneeman/.gem/ruby/3.1.0
  - RUBY EXECUTABLE: /Users/rschneeman/.rubies/ruby-3.1.3/bin/ruby
  - GIT EXECUTABLE: /usr/local/bin/git
  - EXECUTABLE DIRECTORY: /Users/rschneeman/.gem/ruby/3.1.3/bin
  - SPEC CACHE DIRECTORY: /Users/rschneeman/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/rschneeman/.rubies/ruby-3.1.3/etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-darwin-20
  - GEM PATHS:
     - /Users/rschneeman/.gem/ruby/3.1.3
     - /Users/rschneeman/.rubies/ruby-3.1.3/lib/ruby/gems/3.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => true
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/rschneeman/.gem/ruby/3.1.3/bin
     - /Users/rschneeman/.rubies/ruby-3.1.3/lib/ruby/gems/3.1.0/bin
     - /Users/rschneeman/.rubies/ruby-3.1.3/bin
     - /Users/rschneeman/.cargo/bin
     - /usr/local/bin
     - /usr/local/sbin
     - /Users/rschneeman/bin/dotfiles/bin/
     - /usr/local/bin
     - /System/Cryptexes/App/usr/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Users/rschneeman/.cargo/bin
postmodern commented 1 year ago

Ah yes, I added the ruby's gem root bin/ directory to cover my bases, but apparently rubygems does not use that directory and instead installs gem executable binstubs into $RUBY_ROOT/bin. I can remove the directory from $PATH now that it's actually causing issues.

schneems commented 1 year ago

That makes sense. Thanks for looking into it!