Deployer: upload function error: scp: ambiguous target

Created on 14 Feb 2017  路  9Comments  路  Source: deployphp/deployer

| Q | A
| ----------------- | ---
| Issue Type | Question

Description

Hello,

I am getting this error whit upload function:

scp: ambiguous target

How can I solve this?

bug

Most helpful comment

Thanks @elfet for your response,

I get this error where when I try to upload files containing spaces in the name. Example:

file name.txt cause error(scp: ambiguous target)
filename.txt is uploaded without error

I looked for information about this and talk about to put a backslash in front of every space.

I tried this in my task but the error continues:

task('deploy:update_assets', function () {
$files = get('assets_dirs');
$deployPath = get('deploy_path');

foreach ($files as $file)
{
$file = str_replace(" ", "\ ", $file);
upload($file, "{$deployPath}/shared/{$file}");
}
});

Any suggestions?

All 9 comments

Need more info.

Thanks @elfet for your response,

I get this error where when I try to upload files containing spaces in the name. Example:

file name.txt cause error(scp: ambiguous target)
filename.txt is uploaded without error

I looked for information about this and talk about to put a backslash in front of every space.

I tried this in my task but the error continues:

task('deploy:update_assets', function () {
$files = get('assets_dirs');
$deployPath = get('deploy_path');

foreach ($files as $file)
{
$file = str_replace(" ", "\ ", $file);
upload($file, "{$deployPath}/shared/{$file}");
}
});

Any suggestions?

Please show content of deploy.php

This is my deploy.php:

` namespace Deployer;
require 'recipe/codeigniter.php';

// Configuration

set('ssh_type', 'native');
set('ssh_multiplexing', true);

set('repository', 'git@repo');

add('shared_files', ['application/config/database.php', 'application/config/config.php', 'index.php', '.htaccess']);
add('shared_dirs', ['assets']);
add('writable_dirs', ['assets/uploads', 'assets/tmp']);

set('assets_dirs', ['assets/dist', 'assets/images', 'assets/js', 'assets/templates', 'assets/third_party']);

// Servers

server('production', '..*.')
->user('root')
->forwardAgent()
//->identityFile()
->set('deploy_path', '/var/www/html/domain.com/public_html')
->set('branch', 'new_master2')
->pty(true);

// Tasks

desc('Restart PHP-FPM service');
task('php-fpm:restart', function () {
// The user must have rights for restart service
// /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service
//run('sudo systemctl restart php-fpm.service');
});

desc('Update assets');
task('deploy:update_assets', function () {
$files = get('assets_dirs');
$deployPath = get('deploy_path');

foreach ($files as $file)
{
$file = str_replace(" ", "\ ", $file);
upload($file, "{$deployPath}/shared/{$file}");
}
});

after('deploy:symlink', 'php-fpm:restart');
after('deploy', 'deploy:update_assets');

// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');`

$file = str_replace(" ", "\ ", $file);

Why you need this? Show output of dep run with -vvv.

@elfet The root cause is space symbols in file path as exec() can't process it correctly. For example http://stackoverflow.com/questions/5489613/php-exec-and-spaces-in-paths. So I str_replace'd spaces and it works fine (the bug is reproduced only on NativeSsh).

@fernaog could you please try my solution?

@pluseg i see

Fixed in master.

Thank you very much. Sorry for the delay in answering, I was a long time without internet connection.
Regards

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jolipixel picture jolipixel  路  4Comments

osbulbul picture osbulbul  路  3Comments

dima-stefantsov picture dima-stefantsov  路  5Comments

minkbear picture minkbear  路  4Comments

JonasDoebertin picture JonasDoebertin  路  4Comments