Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git password prompt does not work with "mina deploy" #41

Closed
tmak opened this issue Aug 9, 2012 · 7 comments
Closed

Git password prompt does not work with "mina deploy" #41

tmak opened this issue Aug 9, 2012 · 7 comments

Comments

@tmak
Copy link
Contributor

tmak commented Aug 9, 2012

When i run "mina git:clone" the git password prompt works fine. But with "mina deploy" it does not prompt for the git password and the cloning fails.

$ mina git:clone
Password: 
-----> Cloning the Git repository
Cloning into bare repository /.../scm...
Enter passphrase for key '/.../.ssh/id_dsa': 
remote: Counting objects: 7641, done.
remote: Compressing objects: 100% (3050/3050), done.
remote: Total 7641 (delta 4574), reused 7137 (delta 4252)
Receiving objects: 100% (7641/7641), 53.25 MiB | 11.39 MiB/s, done.
Resolving deltas: 100% (4574/4574), done.
-----> Using git branch 'master'
$ mina deploy
Password: 
-----> Creating a temporary build path
-----> Cloning the Git repository
       Cloning into bare repository /.../scm...
       Permission denied (publickey,keyboard-interactive).
       fatal: The remote end hung up unexpectedly
 !     ERROR: Deploy failed.
-----> Cleaning up build
       Unlinking current
       OK

 !     Command failed.
       Failed with status 19

I use revision 2033592

@tmak
Copy link
Contributor Author

tmak commented Aug 9, 2012

It works without the deploy helpers. Maybe it's because of isolate or erb?

desc "Deploys the current version to the server."
task :deploy do
  queue %Q{# Go to the deploy path
    cd "#{settings.deploy_to!}" || (
      echo "! ERROR: not set up."
      echo "The path '#{settings.deploy_to!}' is not accessible on the server."
      echo "You may need to run 'mina setup' first."
      false
    ) || exit 15

    # Check releases path
    if [ ! -d "#{settings.releases_path!}" ]; then
      echo "! ERROR: not set up."
      echo "The directory '#{settings.releases_path!}' does not exist on the server."
      echo "You may need to run 'mina setup' first."
      exit 16
    fi

    # Check lockfile
    if [ -e "#{settings.lock_file!}" ]; then
      echo "! ERROR: another deployment is ongoing."
      echo "The file '#{settings.lock_file!}' was found."
      echo "If no other deployment is ongoing, delete the file to continue."
      exit 17
    fi

    # Determine $previous_path and other variables
    [ -h "#{settings.current_path!}" ] && [ -d "#{settings.current_path!}" ] && previous_path=$(cd "#{settings.current_path!}" >/dev/null && pwd -LP)
    build_path="./tmp/build-`date +%s`$RANDOM"
    version=$((`cat "#{settings.deploy_to!}/last_version" 2>/dev/null`+1))
    release_path="#{settings.releases_path!}/$version"

    # Sanity check
    if [ -e "$build_path" ]; then
      echo "! ERROR: Path already exists."
      exit 18
    fi

    # Bootstrap script (in deployer)
    (
      echo "-----> Creating a temporary build path"
      #{echo_cmd %[touch "#{settings.lock_file!}"]} &&
      #{echo_cmd %[mkdir -p "$build_path"]} &&
      #{echo_cmd %[cd "$build_path"]} &&
      (
  }

  invoke :'git:clone'
  invoke :'deploy:link_shared_paths'
  invoke :'bundle:install'
  #invoke :'rails:db_migrate'

  queue %Q{
      )
    ) &&

    #
    # Rename to the real release path, then symlink 'current'
    (
      echo "-----> Build finished"
      echo "-----> Moving build to $release_path"
      #{echo_cmd %[mv "$build_path" "$release_path"]} &&

      echo "-----> Updating the #{settings.current_path!} symlink" &&
      #{echo_cmd %[ln -nfs "$release_path" "#{settings.current_path!}"]}
    ) &&

    # ============================
    # === Start up serve => (in deployer)
    (
      echo "-----> Launching"
      #{echo_cmd %[cd "$release_path"]}
  }


  queue %Q{
    ) &&

    # ============================
    # === Complete & unlock
    (
      rm -f "#{settings.lock_file!}"
      echo "$version" > "./last_version"
      echo "-----> Done. Deployed v$version"
    ) ||

    # ============================
    # === Failed deployment
    (
      echo "! ERROR: Deploy failed."

  }

  queue %Q{

      echo "-----> Cleaning up build"
      [ -e "$build_path" ] && (
        #{echo_cmd %[rm -rf "$build_path"]}
      )
      [ -e "$release_path" ] && (
        echo "Deleting release"
        #{echo_cmd %[rm -rf "$release_path"]}
      )
      (
        echo "Unlinking current"
        [ -n "$previous_path" ] && #{echo_cmd %[ln -nfs "$previous_path" "#{settings.current_path!}"]}
      )

      # Unlock
      #{echo_cmd %[rm -f "#{settings.lock_file!}"]}
      echo "OK"
      exit 19
    )
  }
end

@rstacruz
Copy link
Member

rstacruz commented Aug 9, 2012

It's because of set :term_mode, :pretty which deploy uses, which colorizes the output, but it doesn't support reading from stdin.

One workaround is to use set :term_mode, :system but you lose the 'pretty' colors and indentation.

@tmak
Copy link
Contributor Author

tmak commented Aug 10, 2012

Ok, thanks.
Don't get me wrong, but do you think that colors and indentation are more important than working password prompts? ;-)

In any case it should be documented somewhere what the different term modes do and what that's means for the deployment helper.

@rstacruz rstacruz closed this as completed Sep 8, 2012
@GaaraLi
Copy link

GaaraLi commented Dec 19, 2014

BTW, without term_mode set to nil, the mina setup may need one more enter press and still show password failed error, could there be a more pretty way for both password input and good-look color?

@ad-novation
Copy link

thanks @rstacruz ! That indeed fixed the issue!

@freehere107
Copy link

set :forward_agent, true

@mafai
Copy link

mafai commented Jul 5, 2023

set :execution_mode, :system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants