RiotGamesCookbooks / rbenv-cookbook

Installs and configures rbenv
http://community.opscode.com/cookbooks/rbenv
Apache License 2.0
137 stars 109 forks source link

rbenv and ruby installed by cookbook could not accessed in cap shell ? #57

Open dfang opened 11 years ago

dfang commented 11 years ago

i installed rbenv in my recipe using these code

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

rbenv_ruby '2.1.0-dev' do
  global true
end

rbenv_gem "bundler" do
  ruby_version "2.1.0-dev"
end

if i ssh to server, rbenv and ruby command is ok, but when i cap deploy a rails application, bundle not found, which rbenv and which ruby is not available in cap shell.

i noticed the path is different.

the path after ssh to server:

/opt/rbenv/shims:/opt/rbenv/bin:/opt/rbenv/bin/rbenv:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

the path in cap shell:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

why rbenv installed rbenv to opt directory, and why i can't access it in cap shell. anyone can help ?

thanks !

capoferro commented 11 years ago

Is the cap shell running as a different user than you are sshing in as?

On Thu, Aug 29, 2013 at 1:03 AM, dfang notifications@github.com wrote:

i installed rbenv in my recipe using these code

include_recipe "rbenv::default"include_recipe "rbenv::ruby_build" rbenv_ruby '2.1.0-dev' do global trueend rbenv_gem "bundler" do ruby_version "2.1.0-dev"end

if i ssh to server, rbenv and ruby command is ok, but when i cap deploy a rails application, bundle not found, which rbenv and which ruby is not available in cap shell.

i noticed the path is different.

the path after ssh to server:

/opt/rbenv/shims:/opt/rbenv/bin:/opt/rbenv/bin/rbenv:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

the path in cap shell:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

why rbenv installed rbenv to opt directory, and why i can't access it in cap shell. anyone can help ?

thanks !

— Reply to this email directly or view it on GitHubhttps://github.com/RiotGames/rbenv-cookbook/issues/57 .

dfang commented 11 years ago

hi @bluepojo, how to know the use cap shell running as ? the one configured in config/deploy.rb ? the user ssh in as is deployer.

FYI: i added a line deployer ALL=(ALL:ALL) ALL in /etc/sudoers, after ssh into server, bundle update failed

deployer $: gem install atomic -v '1.1.10'
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /opt/rbenv/versions/2.1.0-dev/lib/ruby/gems/2.1.0 directory.

deployer $: sudo gem install atomic -v '1.1.10'
sudo: gem: command not found

thanks !

reset commented 11 years ago

@dfang you'll need to ensure that you include the following in your path: /opt/rbenv/bin:/opt/rbenv/shims:$PATH and also set the environment variables RBENV_ROOT=/opt/rbenv and RBENV_VERSION=2.1.0-dev.

You could also source /etc/profile.d/rbenv.sh when you make your initial ssh connection to the node.

There is a good chance that your sudo settings are manipulating your environment variables. This is a default setting on Ubuntu.

dfang commented 11 years ago

@reset i tried to add source /etc/profile.d/rbenv.sh to my .bashrc, then i have to add default_run_options[:shell] = '/bin/bash -l'(must as login shell) to my config/deploy.rb to make rbenv or ruby command to work in cap shell. and i will try a regular user.

I don't know why the setting path and environment variables thing is not included in README.md, maybe there is a better way, no need to set path and env, no need to add default_run_options[:shell] = '/bin/bash -l'` in config/deploy.rb...

i will keep more trying and can anybody share how did you deploy a rails application with capistrano with chef setting up rbenv and ruby environments ?

thanks !