| Q | A
| ----------------- | ---
| Issue Type | Question
Hello,
I am getting this error whit upload function:
scp: ambiguous target
How can I solve this?
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
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?