Giter Club home page Giter Club logo

Comments (2)

mislav avatar mislav commented on May 26, 2024 5

Sorry that this cost so much time to track down for people using Ruby debugger from VS Code.

The primary reason why we suggest putting rbenv initialization in zshrc is because we only wanted rbenv shell integrations to be loaded in interactive mode and not in non-interactive mode.

This is what eval "$(~/.rbenv/bin/rbenv init - zsh)" does in one's shell:

  1. Adds rbenv to PATH (if not already on PATH) - this is only necessary for invoking rbenv commands;
  2. Prepends rbenv's shims directory to PATH - this is crucial for ruby version switching;
  3. Loads rbenv shell completions;
  4. Executes rbenv rehash to make sure rbenv shims are up to date;
  5. Loads rbenv shell integrations (e.g. making rbenv shell command possible).

Only item (2) is actually necessary for ruby version switching; everything else is just convenience primarily made for interactive shells.

In summary, if someone wanted to ensure that their ruby version switching stays active in a non-interactive zsh shell, they should add this to their ~/.zshenv (assuming the default RBENV_ROOT setting):

export PATH="$HOME/.rbenv/shims:${PATH}"

But to aid interactive shells, they should still be adding the eval… line to their zshrc file. You can imagine that making a full setup like this is hard to document and explain in our setup guide. We went the easy path, leaving most of the fine-tuning as the responsibility of the user. Unfortunately, I suspect that most users aren't aware of shell nuances like this, and I wish we could do this better. But to improve the situation, we would have to move from manual setup (i.e. having users follow installation instructions) and onto a more automated setup (i.e. an installation script editing files like zshenv and zshrc for you).

Do others have a strong opinion on how rbenv could improve in this regard?

Ref. https://github.com/rbenv/rbenv/wiki/Unix-shell-initialization#zsh

from rbenv.

hsbt avatar hsbt commented on May 26, 2024

@ono-max Hi, Thanks you for filing this. I also heard this background from @ko1.

In my understanding, the reason of using ~/.zshrc in README.md is only for new people. We should avoid to confuse what is best place of rbenv configuration. So, it's not technical reason.

@mislav Do you have any opinion about prefer to use ~/.zshrc?

from rbenv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.