Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support reading .ruby-version #300

Closed
wants to merge 3 commits into from
Closed

support reading .ruby-version #300

wants to merge 3 commits into from

Conversation

mislav
Copy link
Member

@mislav mislav commented Dec 29, 2012

This is a work-in-progress to support reading the .ruby-version file if
.rbenv-version is not present. Currently the file is read, but the
string "ruby-" is not stripped from its contents for compatibility with
other Ruby version managers.

First I reorganized code a bit to have only one command that has the
knowledge how local version files are named and looked up:
rbenv-local-version-file.

This also improves rbenv local command so it reports the local version
even if it's set in one of the parent directories, not the current one.

The only next step is to strip "ruby-" from the string read from
.ruby-version. However, I can't think of an elegant way to do that.
I'm not sure what is the right level of abstraction to put that logic
in. It certainly doesn't seem like it belongs to
rbenv-version-file-read. @sstephenson, wdyt?

The `rbenv local` command now reads the local ruby version even if the
".rbenv-version" file only exists higher up in the directory chain.

Furthermore, this creates a `rbenv-local-version-file` script that has
the responsibility of finding local version files and is the only
command that has the knowledge of how these files are named.
This is to help with compatibility with versions set from other managers
where MRI rubies are prefixed with "ruby-".
@mislav
Copy link
Member Author

mislav commented Dec 30, 2012

I've put the logic to strip away "ruby-" in version-file-read after all because it was the easiest. Otherwise I would have to repeat the logic twice in both rbenv-local and rbenv-version-name.

I'm not perfectly happy with this, because it makes version-file-read concerned with higher-level logic that it should not even know about. Suggestions welcome.

@sstephenson
Copy link
Contributor

This is a good first start. I have some reservations:

  1. We want to migrate everyone to .ruby-version, so it needs to take precedence over .rbenv-version.
  2. I don't think we need to change the semantics of rbenv local. It should always operate on the current directory without traversing upwards so that you can override a version specified in a parent directory.
  3. The ruby--stripping logic should live in rbenv-version-name and should trigger a warning message.

Let's move this over to #302.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants