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

upload function error: scp: ambiguous target #1010

Closed
fernaog opened this issue Feb 13, 2017 · 9 comments
Closed

upload function error: scp: ambiguous target #1010

fernaog opened this issue Feb 13, 2017 · 9 comments
Labels

Comments

@fernaog
Copy link

fernaog commented Feb 13, 2017

Q A
Issue Type Question

Description

Hello,

I am getting this error whit upload function:

scp: ambiguous target

How can I solve this?

@antonmedv
Copy link
Member

Need more info.

@fernaog
Copy link
Author

fernaog commented Feb 14, 2017

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?

@antonmedv
Copy link
Member

Please show content of deploy.php

@fernaog
Copy link
Author

fernaog commented Feb 16, 2017

This is my deploy.php:

`<?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');`

@antonmedv
Copy link
Member

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

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

@pluseg
Copy link
Contributor

pluseg commented Feb 24, 2017

@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?

@antonmedv
Copy link
Member

@pluseg i see

@antonmedv
Copy link
Member

Fixed in master.

@fernaog
Copy link
Author

fernaog commented Apr 7, 2017

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

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

No branches or pull requests

3 participants