/usr/bin/env ruby no such file or directory: Using capistrano 3, capistrano/rbenv, capistrano/bundler and capistrano/rails (using rails 4)

后端 未结 9 1850
别那么骄傲
别那么骄傲 2021-02-02 08:45

I\'m using capistrano, capistrano/rbenv, capistrano/bundler and capistrano/rails. I get this error in the step where capistrano compiles the assets:

DEBUG [49a50         


        
9条回答
  •  醉话见心
    2021-02-02 09:50

    Okay, as I had the same issue and it took me quite a while to resolve it:

    You are probably wondering why this command is not working while it IS working when you log into with you shell using ssh.

    I am not an expert (so correct me when I am wrong): The thing is there are several differences in logging in on a remote server using ssh. To quote the documentation of capistrano:

    It's really a question of which kind of shell Capistrano is using, it's a matrix of possibilities concerning login, non-login, interactive, or non-interactive.

    They have a fancy graphic here (at the bottom) where they illustrate the path of files that are executed in login process. - the given source is also interesting if you want to continue reading on this topic.

    What is going wrong?

    When YOU log in using ssh you are (on login) executing several files (for example .bash_profile when you using the bash). Commonly your $PATH variable is extended with several paths to important functions in your envirement. BUT different login "styles" include different files.

    As the documentation says again:

    By default Capistrano always assigns a non-login, non-interactive shell.

    In my case this lead to a case where my login file .bash_profile is not included BUT it included the settings for my rvm. The result that the capistrano login session didnt know about my rvm path.

    How can I fix this?

    For me it turned out to just be the uncommenting of the require 'capistrano/rvm' (As I am using RVM) line in the Capfile (located in the root of your rails-project.

    Hope to help someone.

    EDIT:

    And for sure include gem 'capistrano-rvm' in the Gemfile!

提交回复
热议问题