Bundler can't seem to find correct Ruby through Rbenv

巧了我就是萌 提交于 2019-12-08 16:51:43

问题


For years I used RVM as my Ruby version manager, but I want to switch to rbenv for its simplicity. However I'm finding some strange problems deploying. Here's where it seems to go wrong:

# env RBENV_ROOT=\"/home/deploy/.rbenv\" PATH=\"/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:$PATH\"  /home/deploy/.rbenv/bin/rbenv exec bundle install --gemfile /domains/myapp.com/releases/20140119013611/Gemfile --path /domains/myapp.com/shared/bundle --deployment --without development test

> rbenv: bundle: command not found

> The `bundle' command exists in these Ruby versions:
> 2.0.0-p353

Okay, so I specify the rbenv version I want --

# env RBENV_ROOT=\"/home/deploy/.rbenv\" PATH=\"/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:$PATH\" RBENV_VERSION=\"2.0.0-p353\" /home/deploy/.rbenv/bin/rbenv exec bundle install --gemfile /domains/myapp.com/releases/20140119013611/Gemfile --path /domains/myapp.com/shared/bundle --deployment --without development test
> rbenv: version `"2.0.0-p353"' is not installed

Huh. That's weird.

# rbenv versions
> system
> * 2.0.0-p353 (set by /home/deploy/.rbenv/version)

Any idea where I'm going wrong? The bundle install command appears to think that 2.0.0-p353 is absent, but rbenv versions shows it. What might be up?


回答1:


I believe it's an escaping problem.

I can set the current ruby version like this successfully:

rbenv local 2.0.0-p247

or this:

rbenv local "2.0.0-p247"

But if I escape the quotes, I get an error exactly like you get (notice the quotes in the error response):

> rbenv local \"2.0.0-p247\"
rbenv: version `"2.0.0-p247"' not installed

Note that usually quotes are not around a a bogus version:

> rbenv local 2.0.0-p111
rbenv: version `2.0.0-p111`

So, in conclusion, I'm guessing that the bundler-less system ruby is invoked in your first snippet, and you haven't yet seen a successful attempt to try bundle with the rbenv managed version due to the RBENV_VERSION quoting issue.




回答2:


install the bundler tool: gem install bundler.

install the dependancies of the project: bundle install



来源:https://stackoverflow.com/questions/21212278/bundler-cant-seem-to-find-correct-ruby-through-rbenv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!