Hi,
I’m deploying to a prod linux server via Capistrano, but the last step,
running the reaper, won’t complete.
Ruby is stored in /usr/local/bin on the server, and I’m deploying from
winxp.
$ ssh mcalogin@lx07
Password:
mcalogin@LX07:~> env | grep “^PATH”
PATH=/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/b
in:/opt/
kde3/bin:/usr/lib/java/jre/bin
mcalogin@LX07:~> which ruby
/usr/local/bin/ruby
Here is a copy of the log of ‘rake remote:restart’, run from my local
box:
loading configuration
c:/ruby/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/ca
pistrano/recipes/standard.rb
loading configuration ./config/deploy.rb
-
executing task restart
-
executing “sudo
/usr/local/rails/mcalogin/current/script/process/reaper”
servers: [“lx07”]
Password:
[lx07] executing command
** [out :: lx07] /usr/bin/env: ruby
** [out :: lx07] : No such file or directory
command finished
rake aborted!
command “sudo /usr/local/rails/mcalogin/current/script/process/reaper”
failed on
lx07
Fine, so I run it from my workstation by hand:
$ ssh mcalogin@lx07 “sudo
/usr/local/rails/mcalogin/current/script/process/reap
er”
Password:
Restarting [24835] /usr/local/bin/ruby
/usr/local/rails/mcalogin/current/public/
dispatch.fcgi
Restarting [24836] /usr/local/bin/ruby
/usr/local/rails/mcalogin/current/public/
dispatch.fcgi
Restarting [24837] /usr/local/bin/ruby
/usr/local/rails/mcalogin/current/public/
dispatch.fcgi
And it works just great!
I think something is going on with the path. It shows up when I ssh
mcalogin@lx07 “env” or ssh mcalogin@lx07 “sudo env”, however.
As a temporary fix, I’ve added a symbolic link from /usr/bin/ruby to
/usr/local/bin/ruby, and that seems to make it function. I don’t really
like doing that, however.
Why does it work from the ssh command line, but not from Capistrano? If
you’ve had similar trouble, how did you solve it?
Many thanks.
Regards,
Rich D.
Duzenbury, Rich wrote:
Why does it work from the ssh command line, but not from Capistrano? If
you’ve had similar trouble, how did you solve it?
A remote ssh doesn’t get your PATH. Depending on you ssh is configured,
it should get a path from .bashrc (“executed by bash(1) for non-login
shells”)
So if you make a file .bashrc in your home directory on the server, with
the line
export PATH=/usr/local/bin:$PATH
It should work.
–Al Evans
On 05/08/06, Al Evans [email protected] wrote:
So if you make a file .bashrc in your home directory on the server, with
the line
export PATH=/usr/local/bin:$PATH
Alternatively, running ssh with the ‘t’ switch (to allocate a terminal)
should work as well.
Why does it work from the ssh command line, but not from Capistrano?
If
you’ve had similar trouble, how did you solve it?
A remote ssh doesn’t get your PATH. Depending on you ssh is
configured,
it should get a path from .bashrc (“executed by bash(1) for non-login
shells”)
So if you make a file .bashrc in your home directory on the server,
with
the line
export PATH=/usr/local/bin:$PATH
It should work.
Thanks for the info. I had previously tried that to no avail, and then
I read this in the man page for ssh:
ENVIRONMENT
ssh will normally set the following environment variables:
… PATH Set to the default PATH, as specified when compiling ssh
…
What I can’t figure out is how come when I run via:
ssh mcalogin@lx07 “/usr/local/rails…reaper”, it works, but
rake remote:restart, which is supposedly running the same command,
doesn’t.
I wonder how I can see the actual ssh command that Capistrano uses.
I can only infer that when I run the command from my workstation, it
allocates a login tty, but Capistrano doesn’t?
Odd behavior, to me.
Thank you.
Regards,
Rich
If you have at the top of a script:
#! /usr/bin/env ruby
It is indeed executable. I use the SVN propset command to make sure
that it is set to executable when checked out. The problem is that
Capistano cannot find the ruby executable on the path, because it’s not
there (it’s in /usr/local/bin):
I find it interesting that the ssh command line does have it on the
path:
c:\cygwin\bin\ssh.exe mcalogin@lx07 “echo $PATH”
Password:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
So, there is some difference between what cygwin does (causes the
.bashrc file to execute), and what Capistrano does (no .bashrc).
As I mentioned earlier, I have symlinked the ruby executable to /usr/bin
so that I can at least run the reaper.
!/usr/bin/ruby
or
!/usr/local/bin/ruby
if you have ruby located there.
Sure, but I have to develop on windows, and deploy to Linux. The magic
of the env thing means I don’t have to mess with changing all of the
shebang lines whenever I deploy.
I’ve seen some capistrano recipes have to chmod +x after_code_update
in order to get a checked out file to be executable:
run(“chmod +x script/reaper”) # or script/* would work too
I think that is because some folks don’t know how to use the SVN propset
command to have SVN manage it for them.
rake remote:exec ACTION=“test_my_path”
This is very useful. I haven’t written, nor bothered to figure out how
to write, any Capistrano tasks. Thanks for this little bit. It helps
shed light on the nature of the problem.
Regards,
Rich
Are you sure it’s not a script executable error?
If you have at the top of a script:
#! /usr/bin/env ruby
That means to execute this script using the ruby on the path.
So if the file is named “spin.rb” that means you can do:
./spin.rb
Assuming it is chmod +x for the right user (that means it could be
chmod ugo+x – which is user, group, and other executable)
The alternative if you don’t have that line is for it to run it like:
ruby spin.rb
You could just as well have at the top of the script file:
!/usr/bin/ruby
or
!/usr/local/bin/ruby
if you have ruby located there.
I’ve seen some capistrano recipes have to chmod +x after_code_update
in order to get a checked out file to be executable:
run(“chmod +x script/reaper”) # or script/* would work too
you could always write a quick capistrano task to see what’s going on:
desc “test my path”
…
task :test_my_path do
run (" echo ‘my path is: $PATH’ ")
end
and execute it:
rake remote:exec ACTION=“test_my_path”
Also, rake remote:exec ACTION=“deploy” --trace may give you more info.
hope that helps,
Charles Brian Q.
self-promotion: www.seebq.com
highgroove studios: www.highgroove.com
slingshot hosting: www.slingshothosting.com
have you tried adding your path statement to .bash_login instead of
.bash_rc ?
what files does your server have when you login and do:
ls -la
On 8/7/06, Duzenbury, Rich [email protected] wrote:
If you have at the top of a script:
servers: [“lx07”]
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
or
in order to get a checked out file to be executable:
task :test_my_path do
Regards,
Rich
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Charles Brian Q.
self-promotion: www.seebq.com
highgroove studios: www.highgroove.com
slingshot hosting: www.slingshothosting.com
have you tried adding your path statement to .bash_login instead of
.bash_rc ?
Yes, it has no effect, unless I start a full login shell.
LX07:/home/mcalogin # cat .bashrc
export EDITOR="/usr/bin/pico -w"
export PATH=/usr/local/bin:$PATH:/this/is/a/test
LX07:/home/mcalogin # cat .bash_login
export PATH=$PATH:/test/of/bash/login/file
SSH command line (.bashrc works, .bash_login doesn’t)
c:\cygwin\bin\ssh.exe mcalogin@lx07 “echo $PATH”
Password:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/this/is/a/test
Capistrano (fails)
C:\Documents and Settings\RDuzenbury.PANORA\My Documents\Source
Code\MultiChoice
Annuity Login Manager>rake remote:exec ACTION=“mypath”
(in C:/Documents and Settings/RDuzenbury.PANORA/My Documents/Source
Code/MultiChoice Annuity Login Manager)
loading configuration
c:/ruby/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/recipes/s
tandard.rb
loading configuration ./config/deploy.rb
- executing task mypath
- executing “echo my path is: $PATH”
servers: [“lx07”]
Password:
[lx07] executing command
** [out :: lx07] my path is: /usr/bin:/bin:/usr/sbin:/sbin
command finished
what files does your server have when you login and do:
ls -la
LX07:/home/mcalogin # ls -al
total 12
drwxr-xr-x 5 mcalogin users 216 Aug 7 15:05 .
drwxr-xr-x 15 root root 400 Aug 1 13:24 …
-rw------- 1 mcalogin users 1474 Aug 7 15:06 .bash_history
-rw-r–r-- 1 mcalogin users 44 Aug 7 15:05 .bash_login
-rw-r–r-- 1 mcalogin users 84 Aug 7 12:02 .bashrc
drwxr-xr-x 2 mcalogin users 80 Aug 1 14:35 .gem
drwx------ 2 mcalogin users 80 Aug 4 16:37 .ssh
drwxr-xr-x 3 mcalogin users 152 Aug 1 14:24 .subversion
Thanks for your suggestions.
Regards,
Rich
Hi
When debian installs ruby 1.8 it puts the binary at:
/usr/bin/ruby1.8
the gem scripts looks for
/usr/bin/ruby
just create a symlink
ln -s /usr/bin/ruby /usr/bin/ruby1.8