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

Can not share same dirs #995

Closed
greatwitenorth opened this issue Feb 2, 2017 · 8 comments
Closed

Can not share same dirs #995

greatwitenorth opened this issue Feb 2, 2017 · 8 comments
Labels

Comments

@greatwitenorth
Copy link

Q A
Issue Type Bug
Deployer Version 4.2.1
Local Machine OS OSX 10.11.6
Remote Machine OS Centos 6.8

Description

I'm seeing this error when Deployer is trying to create the shared folders:

[Deployer\Exception\ConfigurationException]
Can not share same dirs `img/newsletters` and `img/news`.

Steps to reproduce

I use the following command:
vendor/bin/dep deploy:shared staging -vvv
and I see the error:

[Deployer\Exception\ConfigurationException]
  Can not share same dirs `img/newsletters` and `img/news`.

It appears as though there's a strpos match happening in vendor/deployer/deployer/recipe/deploy/shared.php on line 19. I'm not sure why partial matches should be throwing an exception. Shouldn't it only be exact matches?

Content of deploy.php

namespace Deployer;

require 'vendor/deployer/deployer/recipe/common.php';
require 'vendor/deployer/recipes/phinx.php';

// Set configurations
set('repository', '[email protected]:myuser/myrepo.git');
set('shared_files', [
	'inc/env.php'
]);
set('shared_dirs', [
	'builds',
	'cache',
	'docs',
	'free-ride-html',
	'img/ads',
	'img/awards',
	'img/board',
	'img/congress',
	'img/gallery',
	'img/mailchimp',
	'img/news',
	'img/newsletters',
	'img/raffle',
	'img/sponsors',
	'img/staff',
	'kml',
	'slir/cache/rendered',
	'slir/cache/request',
]);

set('phinx.configuration', './migration/.phinx.yml');

// Configure servers
server('production', 'mysite.com')
    ->user('myuser')
	->identityFile()
	->set('branch', 'master')
	->stage('production')
	->set('phinx.environment', 'development')
    ->set('deploy_path', '/home/myuser/production');

server('staging', 'mysite.com')
	->user('myuser')
	->identityFile()
	->set('branch', 'dev')
	->stage('staging')
	->set('phinx.environment', 'staging')
	->set('deploy_path', '/home/myuser/staging');


task('deploy:set_permissions', function(){
	run("chmod -R go-w {{deploy_path}}");
}); 

task('deploy:empty_slir', function () {
	$sharedPath = "{{deploy_path}}/shared";
	run("rm -rf $sharedPath/slir/cache/rendered");
	run("rm -rf $sharedPath/slir/cache/request");
	run("mkdir -p $sharedPath/slir/cache/rendered");
	run('printf "*\n!.gitignore" > '.$sharedPath.'/slir/cache/rendered/.gitignore');
	run("mkdir -p $sharedPath/slir/cache/request");
	run('printf "*\n!.gitignore" > '.$sharedPath.'/slir/cache/request/.gitignore');
})->desc('Emptying slir cache');

/**
 * Main task
 */
task('deploy', [
	'deploy:prepare',
	'deploy:release',
	'deploy:update_code',
	'deploy:shared',
	'deploy:vendors',
	'deploy:writable',
	'deploy:empty_slir',
	'deploy:set_permissions',
	'deploy:symlink',
	'cleanup',
//	'phinx:migrate'
])->desc('Deploy your project');

after('deploy', 'success');

Output log

Warning: ssh type `phpseclib` will be deprecated in Deployer 5.
Add this lines to your deploy.php file:

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

More info here: https://goo.gl/ya8rKW
➤ Executing task deploy:shared


  [Deployer\Exception\ConfigurationException]
  Can not share same dirs `img/newsletters` and `img/news`.


Exception trace:
 () at /mysite/vendor/deployer/deployer/recipe/deploy/shared.php:20
 Deployer\{closure}() at n/a:n/a
 call_user_func() at /mysite/vendor/deployer/deployer/src/Task/Task.php:85
 Deployer\Task\Task->run() at /mysite/vendor/deployer/deployer/src/Executor/SeriesExecutor.php:40
 Deployer\Executor\SeriesExecutor->run() at /mysite/vendor/deployer/deployer/src/Console/TaskCommand.php:95
 Deployer\Console\TaskCommand->execute() at /mysite/vendor/symfony/console/Command/Command.php:262
 Symfony\Component\Console\Command\Command->run() at /mysite/vendor/symfony/console/Application.php:826
 Symfony\Component\Console\Application->doRunCommand() at /mysite/vendor/symfony/console/Application.php:189
 Symfony\Component\Console\Application->doRun() at /mysite/vendor/symfony/console/Application.php:120
 Symfony\Component\Console\Application->run() at /mysite/vendor/deployer/deployer/src/Deployer.php:186
 Deployer\Deployer->run() at /mysite/vendor/deployer/deployer/bin/dep:114

deploy:shared [-p|--parallel]
@pdbreen
Copy link
Contributor

pdbreen commented Feb 2, 2017

Its trying to insure that you're not sharing both a parent (like 'img/news') and a directory within that parent (like 'img/news/subdir'). Maybe it needs to something like:

if ($a !== $b && strpos(rtrim($a,'/').'/', $b) === 0) {

@antonmedv antonmedv added the bug label Feb 3, 2017
@antonmedv
Copy link
Member

Yes, it's a bug. @pbudzon correct.

@antonmedv
Copy link
Member

Can anybody create PR to fix it?

Ref: https://github.com/deployphp/deployer/blob/master/recipe/deploy/shared.php#L19

@greatwitenorth for temp solution you can change dir name from this:

'img/news',
'img/newsletters',

to this:

'img/news',
'img/_newsletters',

@antonmedv
Copy link
Member

Fixed.

@cve
Copy link

cve commented Mar 8, 2017

I have similar problem with latest version...

My config:

set('shared_dirs', ['web/uploads', 'web/medias', 'web/media']);

And exception says:

[Deployer\Exception\ConfigurationException]            
  Can not share same dirs `web/medias` and `web/media`. 

@greatwitenorth
Copy link
Author

It looks like they haven't tagged a release yet with this change. @Elfet Any word on when this will make it into a release?

@cve
Copy link

cve commented Mar 8, 2017

But in the changelog there is information about this fix

@antonmedv
Copy link
Member

@greatwitenorth will release it today.
@cve in changelog is a master changes.

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

4 participants