How to install a gem globally without sudo using rbenv?

后端 未结 1 1841
醉梦人生
醉梦人生 2021-02-06 10:46

I am using rbenv and I am trying to install sass without success.

So, I installed rbenv via Homebrew, then Ruby 2.2 (rbenv i

相关标签:
1条回答
  • 2021-02-06 11:24

    Basically, the problem was I did not add rbenv/bin/rbenv to $PATH.

    export PATH="$HOME/.rbenv/bin:$PATH"
    

    Better yet, add this to your .bashrc or .bash_profile to start every session with rbenv.

    After that, make sure to:

    eval "$(rbenv init -)"
    

    In order to enable shims and autocompletion.

    fishshell

    For those using fish, you can accomplish the same like this:

    if status --is-interactive
      . (rbenv init - | psub)
    end
    

    Now, if you don't like modifying $PATH directly and have ownership over /usr/local/bin, a more nifty solution is to symlink with ~/.rbenv/bin/rbenv.

     ln -s ~/.rbenv/bin/rbenv /usr/local/bin
    

    ruby-build

    As a final warning, make sure to install ruby-build (a rbenv plugin to add the install command to rbenv and be able to easily install Ruby versions.)

    If you are using homebrew it's easy as pie:

    brew install ruby-build
    
    0 讨论(0)
提交回复
热议问题