-1

I'm trying to install ruby in terminal via homebrew.

So far I've entered:

brew install rbenv

and then I rain

rbenv init

after the command was run I received

# Load rbenv automatically by appending
# the following to ~/.bash_profile:

eval "$(rbenv init -)"

finally I entered:

echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

I restarted my terminal per instructions and then received

rbenv: no such command `init-'

at the top of my new terminal.

error messages: rbenv: no such command `init-'

expected messages: nothing, blank terminal

Simba
  • 23,537
  • 7
  • 64
  • 76
Eric W
  • 1
  • 3

1 Answers1

2

The default shell (Bash before macOS 10.15) on macOS is a login shell. Only .bash_profile is used in initialization by default.

You need to put eval "$(rbenv init -)" into ~/.bash_profile but not ~/.bashrc.

Bash init files

  1. login mode:

    • /etc/profile
    • ~/.bash_profile, ~/.bash_login, ~/.profile (only first one that exists)
  2. interactive non-login:

    • /etc/bash.bashrc (some Linux; not on Mac OS X)
    • ~/.bashrc
  3. non-interactive:

    • source file in $BASH_ENV

Check the path of the red line for an interactive, login shell on macOS.

enter image description here

References

Simba
  • 23,537
  • 7
  • 64
  • 76