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

后端 未结 9 1844
别那么骄傲
别那么骄傲 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:39

    My problem is:

    DEBUG [3132b2c2]    /usr/bin/env: ‘bundle’: No such file or directory
    DEBUG [3132b2c2] 
    

    I solved it this way:

    In Debian, there is a block of code in your ~/.bashrc that says:

    # If not running interactively, don't do anything
    
    case $- in
       *i*) ;;
         *) return;;
    esac
    

    When you run Capistrano, it will actually use your ~/.bashrc but it will not run any command below that block of code.

    So, I fixed the problem adding the lines of code that were required by load ruby environment above that block of code, so Capistrano could load bundle.

    source /usr/local/share/chruby/chruby.sh
    source /usr/local/share/chruby/auto.sh
    

    PS:I use chruby in my server.

    0 讨论(0)
  • 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!

    0 讨论(0)
  • 2021-02-02 09:50

    Ok, fixed it.

    I added this:

    set :default_env, { path: "~/.rbenv/shims:~/.rbenv/bin:$PATH" }
    

    to my deploy.rb.

    I'm not sure is the best solution, but it worked.

    0 讨论(0)
提交回复
热议问题