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

Won't work if there is no system rbenv command installed #10

Open
dmeranda opened this issue Nov 14, 2015 · 3 comments
Open

Won't work if there is no system rbenv command installed #10

dmeranda opened this issue Nov 14, 2015 · 3 comments

Comments

@dmeranda
Copy link
Contributor

In ruby_selector's Rbenv class it removes all .rbenv directories out of the $PATH and other environment variable cleansing. However, if there is no global system-installed rbenv command, then this means that it can no longer find any rbenv command to run rbenv versions --bare

$ schema_dev bundle install
...
/home/.../.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/schema_dev-3.5.1/lib/schema_dev/ruby_selector.rb:41:in ``': No such file or directory - rbenv (Errno::ENOENT)
    from /home/.../.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/schema_dev-3.5.1/lib/schema_dev/ruby_selector.rb:41:in `initialize'
    from /home/.../.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/schema_dev-3.5.1/lib/schema_dev/ruby_selector.rb:8:in `new'
    from /home/.../.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/schema_dev-3.5.1/lib/schema_dev/ruby_selector.rb:8:in `command'
...

The user-installed rbenv is:

$ which rbenv
~/.rbenv/bin/rbenv

$ rbenv --version
rbenv 0.4.0-190-gc30e096

$ rbenv versions --bare
1.9.3-p484
2.2.3
@ronen
Copy link
Member

ronen commented Nov 15, 2015

Drat. It used to work for me with rbenv. Yeah I probably had rbenv installed in /usr/local via homebrew. Unfortunately I don't use rbenv any more (I use chruby now), so it'll be hard for me to debug.

Looks like it'd be possible to reorder the code so that it runs rbenv versions --bare before it cleanses the environment... would you be willing to try it and make a PR?

@dmeranda
Copy link
Contributor Author

I verified that moving the assignment of @versions to the top of Rbenv.initialize seems to work, at least with some limited testing. However I'm not sure what the purpose of altering the $PATH environment variable is. I understand changing the other environment variables, but not the path.

Rather than moving the line that determines the available ruby versions, would it not work just as well to delete the line that filters out the $PATH variable? Or perhaps only removing .rbenv/shims but not .rbenv/bin?

@ronen
Copy link
Member

ronen commented Nov 16, 2015

However I'm not sure what the purpose of altering the $PATH environment variable is. I understand changing the other environment variables, but not the path.

Rather than moving the line that determines the available ruby versions, would it not work just as well to delete the line that filters out the $PATH variable? Or perhaps only removing .rbenv/shims but not .rbenv/bin?

You're probably right. I can't think of any reason that $PATH would need to be cleansed, if its contents don't depend on the version of ruby that were chosen. I don't remember whether I included it in the cleansing because of a specific problem or just for thoroughness. I do vaguely remember having some sort of problem which prompted me to do that cleansing in the first place, but I don't remember the details. I should have added a more detailed comment at the time.

Anyway, since you use rbenv and I don't, I'd say feel free to make whatever changes you think best-- and once you've convinced yourself it really works I'll be happy to take your word for it and merge a PR. (And if other people then raise rbenv-related issues, I might send them your way :)

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

No branches or pull requests

2 participants