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

Load RUBIES from common directories #29

Closed
postmodern opened this issue Dec 10, 2012 · 10 comments
Closed

Load RUBIES from common directories #29

postmodern opened this issue Dec 10, 2012 · 10 comments
Assignees
Milestone

Comments

@postmodern
Copy link
Owner

We should load RUBIES from common directories where Rubies are commonly installed.

  • /usr/local/rubies/
  • /opt/rubies/
  • ~/.rubies/
@ghost ghost assigned postmodern Dec 10, 2012
@postmodern
Copy link
Owner Author

This can be done with:

RUBIES=({/usr/local,/opt,$HOME}/rubies/*)

@postmodern
Copy link
Owner Author

Hmm nope:

   jruby-1.7.0
   rubinius-2.0.0-rc1
   ruby-1.9.3-p327
   ruby-2.0.0-preview2
   *
   *

@postmodern
Copy link
Owner Author

Better solution from @havenwood:

RUBIES=$(for path in {/usr/local/rubies,/opt/rubies,$HOME/.rubies}/*; do echo $path; done)

@postmodern
Copy link
Owner Author

or we could just append them to an empty Array:

RUBIES=()

for path in {/usr/local/rubies,/opt/rubies,$HOME/.rubies}/*; do
  [[ -x $path/bin/ruby ]] && RUBIES+=($path)
done

@postmodern
Copy link
Owner Author

Arg, zsh strikes again:

>>> Running tests under /usr/bin/zsh ...
./share/chruby/chruby.sh:3: no matches found: /opt/rubies/*

@postmodern
Copy link
Owner Author

for rubies in /usr/rubies /usr/local/rubies /opt/rubies "$HOME"/.rubies; do
    [[ -d "$rubies" ]] && RUBIES+=("$rubies"/*)
done

I removed the [[ -x $path/bin/ruby ]] check, since a user could set RUBIES to any list of directories and no error would be raised. Better to fail consistently.

postmodern added a commit that referenced this issue Dec 11, 2012
* Search in /usr/local/rubies, /opt/rubies, ~/.rubies.
* Only allow directories which contain bin/ruby.
@havenwood
Copy link
Collaborator

for rubies in /opt/rubies /usr/rubies /usr/local/rubies "$HOME"/.rubies "$HOME"/.rvm/rubies "$HOME"/.rbfu/rubies "$HOME"/.rbenv/versions; do
  [[ -d "$rubies" ]] && RUBIES+=("$rubies"/*)
done

Too much to include migration directories as common directories? Would allow us to autodetect existing installed Rubies for users migrating to chruby.

@postmodern
Copy link
Owner Author

I think that should be an explicit choice by the user. That way they don't forget about ~/.rvm/rubies or ~/.rbenv/versions while using chruby. Also, I'm guessing most users will rvm implode or rm -rf ~/.rbenv beforehand.

@postmodern
Copy link
Owner Author

Merged into the 0.3.0.

@postmodern
Copy link
Owner Author

This has been released in 0.3.0.

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

No branches or pull requests

2 participants