/usr/bin/env is the default place to look for commands.

When typing rake (for example) your shell will typically use
/usr/bin/envto find the binary. We
use /usr/bin/env as the
default<https://github.com/capistrano/sshkit/blob/master/lib/sshkit/command_map.rb#L67>to
make it clear that we're deferring responsibility of resolving which
binary to use to the standard mechanisms. In your case, this resolution
hasn't had the PATH modifications usually performed by rvm.sh applied,
because it's not an interactive shell in Capistrano.

I might argue that this is a problem with the rvm/capistrano integration
(which I have never used, and didn't contribute to), there's a larger
question about why you are using rvm in production. (I'd argue that
distribution package maintainers are doing the world a disservice in not
providing modern Ruby packages)

The simple solution is to do something like this, to set the path to :rake:

SSHKit.config.command_map[:rake] = "./bin/rake"



Lee Hambley
--
http://lee.hambley.name/
+49 (0) 170 298 5667


On 29 January 2014 12:13, Douglas Magnenat <[email protected]>wrote:

> *Versions:*
> Ruby 2.1
> Capistrano 3.0.1
> Rake 10.1.1/ Rails 3.2.16 / rvm 1.25.12
>
> *I'm using rvm on myserver to facilitate ruby installation, but I install
> and udate manually the gems with user rvm_admin.*
> *rvm has been installed 'system wide'.*
> *I don't use capistrano-rvm and I don't use capistrano-rails, as I
> manually update ruby, gems, assets, and migrations.*
>
>
> *Platform:*
> Working on XUbuntu 12.04.4 LTS
> Deploying to Debian Wheezy
>
> Logs:
>
>    - Please past logs (as completely as possible to a 3rd party pasting
>    service such as pastie.org)
>
> Files:
>
>    - Capfile
>
> require 'capistrano/setup'
> require 'capistrano/deploy'
> Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
>
>    - deploy.rb
>
> set :application, 'odpf'
> set :repo_url, '[email protected]:myrepo/myapp.git'
> set :branch, 'production_1.01'
> set :deploy_to, '/var/www/odpf'
> set :pty, false
> set :scm, :git
> set :format, :pretty
>
>
> namespace :deploy do
>   desc 'Restart application'
>   task :restart do
>     on roles(:app), in: :sequence, wait: 5 do
>       # Your restart mechanism here, for example:
>       # l'exemple correspond à ce qu'il faut pour restart passenger :
>       #
> http://www.modrails.com/documentation/Users%20guide%20Apache.html#_redeploying_restarting_the_ruby_on_rails_application
>       execute :mkdir, '-p', "#{release_path}/tmp"
>       execute :touch, release_path.join('tmp/restart.txt')
>     end
>   end
>
>
>   after :restart, :clear_cache do
>     on roles(:web), in: :groups, limit: 3, wait: 10 do
>       # Here we can do anything such as:
>       # Conformément à :
> http://guides.rubyonrails.org/v3.2.14/command_line.html#tmp
>       within release_path do
>         execute :rake, 'tmp:cache:clear'
>       end
>     end
>   end
>
>
>   # Create symlink to database.yml after publication
>   before 'deploy:published', 'db_access:create_symlinks'
>
>
>   after :finishing, 'deploy:cleanup'
> end
>
>    - Stage files (production.rb, staging.rb)
>
> set :stage, :production
> server 'myserver.net', user: 'rvm_admin', roles: %w{web app db}
>
> set :ssh_options, { forward_agent: true, port: 8888 }
>
>
> When I perform a cap production deploy, It goes well untill the end of the
> output :
>
> INFO [0a0dbcb0] Running /usr/bin/env rake tmp:cache:clear on phisa-odpf-vd
> .vserver.nimag.net
> DEBUG [0a0dbcb0] Command: cd /var/www/odpf/releases/20140129101515 &&
> /usr/bin/env rake tmp:cache:clear
> DEBUG [0a0dbcb0] /usr/bin/env: rake
> DEBUG [0a0dbcb0] : Aucun fichier ou dossier de ce type
> cap aborted!
> rake stdout: Nothing written
> rake stderr: Nothing written
> /home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/sshkit-1.0.0/lib/sshkit/
> command.rb:94:in `exit_status='
> /home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/sshkit-1.0.0/lib/sshkit/backends/netssh.rb:125:in
> `block (4 levels) in _execute'
> /home/douglas/.rvm/gems/ruby-2.1.0@rails3/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in
> `call'
>
>
> Capistrano try to execute rake from /usr/bin/env
>
> but my gem is installed here :
>
> rvm_admin@myserver:/var/www/odpf/current$ bundle show rake
> /usr/local/rvm/gems/ruby-2.1.0/gems/rake-10.1.1
> rvm_admin@myserver:/var/www/odpf/current$ which rake
> /usr/local/rvm/gems/ruby-2.1.0/bin/rake
>
> What am I doing wrong ?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Capistrano" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/capistrano/58a8122b-a09f-47b7-add5-6fe395d812dd%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/capistrano/CAN_%2BVLX6EoE%3DTcoXOuGh71wAJJrorxXKDjZQ7HYpDGaEyacWTA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to