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 for .ruby-version files #302

Merged
merged 6 commits into from
Jan 3, 2013
Merged

Support for .ruby-version files #302

merged 6 commits into from
Jan 3, 2013

Conversation

sstephenson
Copy link
Contributor

This branch adds support for per-project .ruby-version files.

rbenv treats .ruby-version files the same way as it has always treated .rbenv-version files. A version specified in a .ruby-version file maps directly to a directory in $RBENV_ROOT/versions, without fuzzy version matching or other preprocessing (but with additional consideration for version names beginning with ruby-, as described below).

.ruby-version becomes the preferred file for storing local version specifications. The rbenv version-file command now prefers .ruby-version files when searching up the working directory tree. rbenv will still read versions specified in .rbenv-version if a .ruby-version file is not present.

Setting the local version with rbenv local now writes a .ruby-version file. If the local version was previously specified by .rbenv-version, rbenv will remove it and print a migration notice to stderr.

For compatibility with other version managers, if the version specification begins with ruby- but does not match a directory in $RBENV_ROOT/versions, rbenv will try to match it by removing the ruby- prefix. If a match is found, rbenv accepts it but prints a warning to stderr.

/cc @mislav @jeremy

@fnichol
Copy link

fnichol commented Dec 31, 2012

Thanks Sam, this looks really good. I'm really happy to see .ruby-version being promoted over .rbenv-version, even if it isn't strictly necessary.

Given the backwards compatibility of detecting either dot file, would you see this requiring a minor version bump if and when it's released?

@sstephenson
Copy link
Contributor Author

Glad you're on board, @fnichol! This is the last remaining issue before we release rbenv 0.4.0 (this week, assuming no major blockers). We will maintain backwards compatibility with existing .rbenv-version files for the foreseeable future.

@mislav
Copy link
Member

mislav commented Dec 31, 2012

Looks good!

The only issue I see here is that rbenv local will not report a location version if it's set from a file in one of the parent directories and not the current directory. I've taken care of this in "version-file" branch. Do you think the current behavior should be like that by design, or is it a bug?

@sstephenson
Copy link
Contributor Author

@mislav It's by design. I'm open to reconsidering if you feel strongly about it, but I wanted to focus strictly on .ruby-version-related changes in this branch.

@@ -13,10 +13,18 @@ if [ -z "$RBENV_VERSION" ] || [ "$RBENV_VERSION" = "system" ]; then
exit
fi

RBENV_VERSION_PATH="${RBENV_ROOT}/versions/${RBENV_VERSION}"
version_exists() {
local version="$1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the intermediate var?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Bash lacks named function arguments, I tend to explicitly assign them to local variables for clarity.

@sethvargo
Copy link

👍 @sstephenson any estimate on a release for this? It looks like it's all that's remaining for 0.4.0.

@parkr
Copy link

parkr commented Dec 31, 2012

This is cool, but I can't find an argument for making the change. What makes this change desirable? Just want to rename the file for clarity?

@guilleiguaran
Copy link
Contributor

@parkr compatibility with other ruby version managers (rvm, chruby, ...)

@sethvargo
Copy link

@parkr
Copy link

parkr commented Dec 31, 2012

@guilleiguaran @sethvargo Thanks! Just found that link after looking through a couple more issues here. A common ruby-version file will be nice. Thanks for the help in understanding, guys.

sstephenson added a commit that referenced this pull request Jan 3, 2013
Support for .ruby-version files
@sstephenson sstephenson merged commit 80750f7 into master Jan 3, 2013
@sstephenson
Copy link
Contributor Author

🎉

@sethvargo
Copy link

❤️ 👍

cehoffman pushed a commit to cehoffman/rbenv that referenced this pull request Apr 8, 2014
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.

7 participants