Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im using Zsh on the client and server. When I use ssh to run a command on the remote server it can not find the binary:

ssh gt "cd /home/****/app/staging && bundle exec rake db:migrate RAILS_ENV=staging"
zsh:1: command not found: bundle

I can run the same command fine if I SSH in with an interactive shell.

On the server the $PATH is set in both .zshrc and .zshenv


It appears bundle is not in my $PATH on the server. Maybe this has something to do with RVM (Ruby Version Manager) which hooks in to cd, so when you cd in to a directory with a .rvmrc file it sets up the Ruby environment and adds bundle to the $PATH. I need to find out if the cd hook is also triggered for non-interactive shells.

share|improve this question

The path in which your binary is, is probably added to the $PATH variable on login. And when you run the presented command, it is executed via a non-login shell. The easiest (and safe) way of solving this is to specify a full path in this case.

share|improve this answer
As I read man zsh, the file sourced by non-login shells is .zshenv. This means that bundle is not found in the $PATH set in that file. Do a simple check ssh gt 'echo $PATH' (mind the single quotes!). – rozcietrzewiacz Nov 4 '11 at 10:59
It looks like single quotes may have been the issue, changing from double quotes to single seems to have fixed the issue. – Kris Nov 4 '11 at 13:48

the reason is the PATH here.

please do a which bundle , on both the shells, that should be self-explanatory ! and you could either edit the PATH variable exporting it to your needs, or use absolute paths for the same.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.