SSH “command not found” for Zsh

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite
1












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



EDIT



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



























    up vote
    0
    down vote

    favorite
    1












    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



    EDIT



    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

























      up vote
      0
      down vote

      favorite
      1









      up vote
      0
      down vote

      favorite
      1






      1





      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



      EDIT



      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















      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



      EDIT



      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.







      ssh zsh






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 4 '11 at 13:16

























      asked Nov 4 '11 at 10:33









      Kris

      13519




      13519




















          4 Answers
          4






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          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
















          • 3




            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

















          up vote
          0
          down vote













          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



























            up vote
            0
            down vote













            I upvoted the comment by @rozcietrewiacz, but I want to call it out as a full answer. (This wouldn't have helped the poster who had already set both dotfiles, but I think it will help people like me who find this question based on the error.)



            zsh reads .zshenv and .zshrc for interactive logins, but only .zshenv for noninteractive logins. To fix this problem, I needed to split out the PATH settings from my .zshrc and move them to .zshenv.



            In my case, I was unable to run mercurial commands that communicated by ssh with another server, because my path (with hg itself) was set in .zshrc on the server.



            More detail can be found here and here.






            share|improve this answer



























              up vote
              0
              down vote













              """
              To fix this problem, I needed to split out the PATH settings from my .zshrc and move them to .zshenv.
              """



              it works! fix my problem!





              share








              New contributor




              wallen wan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.

















                Your Answer







                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "106"
                ;
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function()
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled)
                StackExchange.using("snippets", function()
                createEditor();
                );

                else
                createEditor();

                );

                function createEditor()
                StackExchange.prepareEditor(
                heartbeatType: 'answer',
                convertImagesToLinks: false,
                noModals: false,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );













                 

                draft saved


                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f23947%2fssh-command-not-found-for-zsh%23new-answer', 'question_page');

                );

                Post as a guest






























                4 Answers
                4






                active

                oldest

                votes








                4 Answers
                4






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                2
                down vote



                accepted










                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
















                • 3




                  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














                up vote
                2
                down vote



                accepted










                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
















                • 3




                  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












                up vote
                2
                down vote



                accepted







                up vote
                2
                down vote



                accepted






                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












                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












                share|improve this answer



                share|improve this answer










                answered Nov 4 '11 at 10:50









                rozcietrzewiacz

                28.3k37191




                28.3k37191







                • 3




                  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












                • 3




                  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







                3




                3




                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





                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




                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












                up vote
                0
                down vote













                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
























                  up vote
                  0
                  down vote













                  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






















                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    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












                    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












                    share|improve this answer



                    share|improve this answer










                    answered Nov 4 '11 at 10:52









                    Gaumire

                    1,07173




                    1,07173




















                        up vote
                        0
                        down vote













                        I upvoted the comment by @rozcietrewiacz, but I want to call it out as a full answer. (This wouldn't have helped the poster who had already set both dotfiles, but I think it will help people like me who find this question based on the error.)



                        zsh reads .zshenv and .zshrc for interactive logins, but only .zshenv for noninteractive logins. To fix this problem, I needed to split out the PATH settings from my .zshrc and move them to .zshenv.



                        In my case, I was unable to run mercurial commands that communicated by ssh with another server, because my path (with hg itself) was set in .zshrc on the server.



                        More detail can be found here and here.






                        share|improve this answer
























                          up vote
                          0
                          down vote













                          I upvoted the comment by @rozcietrewiacz, but I want to call it out as a full answer. (This wouldn't have helped the poster who had already set both dotfiles, but I think it will help people like me who find this question based on the error.)



                          zsh reads .zshenv and .zshrc for interactive logins, but only .zshenv for noninteractive logins. To fix this problem, I needed to split out the PATH settings from my .zshrc and move them to .zshenv.



                          In my case, I was unable to run mercurial commands that communicated by ssh with another server, because my path (with hg itself) was set in .zshrc on the server.



                          More detail can be found here and here.






                          share|improve this answer






















                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            I upvoted the comment by @rozcietrewiacz, but I want to call it out as a full answer. (This wouldn't have helped the poster who had already set both dotfiles, but I think it will help people like me who find this question based on the error.)



                            zsh reads .zshenv and .zshrc for interactive logins, but only .zshenv for noninteractive logins. To fix this problem, I needed to split out the PATH settings from my .zshrc and move them to .zshenv.



                            In my case, I was unable to run mercurial commands that communicated by ssh with another server, because my path (with hg itself) was set in .zshrc on the server.



                            More detail can be found here and here.






                            share|improve this answer












                            I upvoted the comment by @rozcietrewiacz, but I want to call it out as a full answer. (This wouldn't have helped the poster who had already set both dotfiles, but I think it will help people like me who find this question based on the error.)



                            zsh reads .zshenv and .zshrc for interactive logins, but only .zshenv for noninteractive logins. To fix this problem, I needed to split out the PATH settings from my .zshrc and move them to .zshenv.



                            In my case, I was unable to run mercurial commands that communicated by ssh with another server, because my path (with hg itself) was set in .zshrc on the server.



                            More detail can be found here and here.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Mar 8 '17 at 17:11









                            Joshua Goldberg

                            1212




                            1212




















                                up vote
                                0
                                down vote













                                """
                                To fix this problem, I needed to split out the PATH settings from my .zshrc and move them to .zshenv.
                                """



                                it works! fix my problem!





                                share








                                New contributor




                                wallen wan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                Check out our Code of Conduct.





















                                  up vote
                                  0
                                  down vote













                                  """
                                  To fix this problem, I needed to split out the PATH settings from my .zshrc and move them to .zshenv.
                                  """



                                  it works! fix my problem!





                                  share








                                  New contributor




                                  wallen wan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                  Check out our Code of Conduct.



















                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote









                                    """
                                    To fix this problem, I needed to split out the PATH settings from my .zshrc and move them to .zshenv.
                                    """



                                    it works! fix my problem!





                                    share








                                    New contributor




                                    wallen wan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.









                                    """
                                    To fix this problem, I needed to split out the PATH settings from my .zshrc and move them to .zshenv.
                                    """



                                    it works! fix my problem!






                                    share








                                    New contributor




                                    wallen wan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.








                                    share


                                    share






                                    New contributor




                                    wallen wan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.









                                    answered 5 mins ago









                                    wallen wan

                                    1




                                    1




                                    New contributor




                                    wallen wan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.





                                    New contributor





                                    wallen wan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.






                                    wallen wan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.



























                                         

                                        draft saved


                                        draft discarded















































                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f23947%2fssh-command-not-found-for-zsh%23new-answer', 'question_page');

                                        );

                                        Post as a guest













































































                                        Popular posts from this blog

                                        How to check contact read email or not when send email to Individual?

                                        Bahrain

                                        Postfix configuration issue with fips on centos 7; mailgun relay