capistrano / rbenv

Idiomatic rbenv support for Capistrano 3.x
MIT License
203 stars 60 forks source link

is there supposed to be a ~/.rbenv/bin directory? #38

Open salex opened 10 years ago

salex commented 10 years ago

I have a server (OS X server) running several small rails applications. I had initially set it using brew to install ruby (could not get rvm to install!). I made some changes to one of the apps and ran into all kinds of problems with I updated the brew ruby version. I decided to try rbenv and set it up on the server. Lots of problems with clashes with the brew version that I eventually figured out.

I then tried to deploy and discovered that my bundle update loaded capistrano 3.1 and nothing worked. I started the conversion processes and I got stuck on:

set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"

I have no bin directory on what brew installed for rbenv. I changed it to:

set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} /usr/local/bin/rbenv exec"

and got it to work, but maybe I'm missing something. I did get a basic deploy to work, but still have to get the rest of my 'railscast/recipes' to work, like writing plists for launchd etc.

kirs commented 10 years ago

If you use Homebrew, your rbenv_ruby path should be /usr/local/Cellar/rbenv/0.4.0

kirs commented 10 years ago

That means you don't need to change rbenv_prefix at all.

salex commented 10 years ago

Thank you. Knew it had to be simpler. Again, new to rbenv and did the Capistrano using the recipes screencasts, not really understanding Capistrano -- I'll work on that.

mech commented 9 years ago

@salex, did you manage to get it working?

Is it as such:

set :rbenv_ruby, '/usr/local/Cellar/rbenv/0.4.0'

Don't think that is working on my side. Also do we need the .ruby-version file?

kirs commented 9 years ago

@mech rbenv_ruby should point to ruby version, not the directory with rbenv

mech commented 9 years ago

If I put the config as such

set :rbenv_type, :user
set :rbenv_ruby, '2.1.4'

I will get this error

bash: /Users/mech/.rbenv/bin/rbenv: No such file or directory

That's why it is puzzling how come it need to find such directory on a Mac OS X setup. I feel that it is like only for Linux. Obviously in a Mac using a typical install of rbenv with Homebrew, there is no such directory :(

shawnpyle commented 8 years ago

Based on the settings listed in the Usage section of capistrano/rbenv, the following worked by changing the path to the actual rbenv executable (/usr/local/bin/rbenv).

set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} /usr/local/bin/rbenv exec"
ghost commented 8 years ago

I had to set :rbenv_path, '/usr/local/opt/rbenv' in addition to @shawnpyle's solution to get rbenv to find the bundler executable.

jDeppen commented 7 years ago

@kirs, did you mean that this is already the default for rbenv_ruby and there's nothing to set?

If you use Homebrew, your rbenv_ruby path should be /usr/local/Cellar/rbenv/0.4.0

I'm wondering because you also said:

@mech rbenv_ruby should point to ruby version, not the directory with rbenv


Does this mean 'don't even set (rather than change) rbenv_prefix at all':

That means you don't need to change rbenv_prefix at all.


To avoid /Users/jason/.rbenv/bin/rbenv: No such file or directory, I had to: ln -s /usr/local/Cellar/rbenv/1.1.1/bin ~/.rbenv/bin Of course, this will break when rbenv is updated.

What's the proper way to set this up when installing with Homebrew? Thank you!

related: #52

brendon commented 3 years ago

In my case I installed the Ubuntu rbenv package. This seems to place the binary elsewhere (outside of the .rbenv path). To fix this you need to configure it explicitly:

set :rbenv_prefix, '/usr/bin/rbenv exec'

Use which rbenv on your server to find the correct location.

You can see the logic around this here::

https://github.com/capistrano/rbenv/blob/1fdb93a6dd4a4ab3fb786c995055cf6949daf7a4/lib/capistrano/tasks/rbenv.rake#L19

https://github.com/capistrano/rbenv/blob/1fdb93a6dd4a4ab3fb786c995055cf6949daf7a4/lib/capistrano/tasks/rbenv.rake#L35-L45