-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Make assets:install smarter with symlinks #11312
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
Conversation
rvanginneken
commented
Jul 5, 2014
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Tests pass? | - |
Fixed tickets | #11297 |
License | MIT |
Doc PR | - |
$output->writeln('Installing assets.'); | ||
|
||
$symLink = function_exists('symlink'); | ||
if ( !$symLink ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the extra spaces here - fabbot.io
is reporting this as well :)
We may need to move this into a new command or only activate this new "figure out the best option" behavior with a new flag (e.g. |
Actually, yes - Fabien just commented about the BC break. Let's try that |
…PHP 5.3 symlink function always exists.
Added the --auto option and removed function_exists checks for symlink function. |
$filesystem->symlink($relativeOriginDir, $targetDir); | ||
} catch (IOException $e) { | ||
if ($input->getOption('auto')) { | ||
$hardCopy = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This $hardCopy
logic is a little hard to read. It might be easier to read if the actual "hard copy" logic below were moved into a new private function makeHardCopy
and then called from here and called from below. But that's minor - if you try it, make sure it does in fact seem clearer to you
👍 awesome! I'm on windows and this will be nice. |
@Richtermeister Would you be able to test this? With and without the permissions setup to allow to create symlinks on windows (see comments on #11297). |
@pborreli Can you try it on your Windows machine? |
/** | ||
* Create hardcopy for targetDir | ||
*/ | ||
private function hardCopy($originDir, $targetDir, \Traversable $iterator = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the iterator seems unused
@fabpot sure I'll test that with multiple env (pure windows, vagrant on windows with and without permissions) |
try { | ||
$filesystem->symlink($relativeOriginDir, $targetDir); | ||
} catch (IOException $e) { | ||
if (!$input->getOption('auto')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean if ($input->getOption('auto')) {
, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes , seem to have looked over that one
it doesn't work as expected right now :
I added a note in the PR which could explain it. |
Works now like expected for Windows machine, give me some time to test it from a vagrant machine on Windows host. On Windows without any rights
On Windows machine with admin right :
|
Btw, does it make sense to think about combination of --auto and --relative as well here or is only absolute links supported on Windows? (Advantage og relative symlinks is transportability, however it seems to work poorly with archive formats and maybe also other operations, so might be something to avoid to make it clear they need to be regenerated on move.) |
@andrerom you are totally right, if symlink is correctly dealt with, relative option should too. Tested on Windows:tm: with Admin rights
Removing the try catch block to have the error message:
|
ok, nice to know.. If it is confirmed/decided to not work, then maybe it should throw early saying the combination is not supported. |
@andrerom looks like it's possible http://superuser.com/questions/361826/how-do-you-make-a-symbolic-link-with-a-relative-path-using-mklink indicating the path should be relative to user's working directory instead of related path, worth the try |
I will give it a try tomorrow, can't get to my src atm. Don't have a windows machine to test BTW. Pascal Borreli notifications@github.comschreef:
|
@andrerom Yes, happy to join the testers. |
…ve function mklink instead of symlink
@weaverryan sorry my bad 👊 i edited a file to add a throw and didn't removed it. |
@pborreli You rock man! Thanks for the fast response! Ok, I think we just need someone to test with a Vagrant setup. The expected behavior is for the failure of the symlinks to be detected and to fallback to hard-copy with a message. Anyone have Vagrant setup from a Windows host that can try this? Thanks! |
Oh wow, dropped the ball on this, sorry all :( @weaverryan @andrerom I got through the installation without asset and symlink problems. Looks like we're golden. I'll test further and report my findings, but so far so good. I've got some other DX feedback but I'll shoot that over to Ryan directly. |
@Swader yea, thanks for checking! Was your setup, by chance, a Windows host with Vagrant? That's the last combination that hasn't been tried (but I'm hoping this is what you had). Thanks for coming back to this - very awesome. |
Yup, Win 8.1 host, Vagrant guest
|
Brilliant! We've tested with every reasonable setup that I can think of. I think this PR is ready! |
👍 |
IMO we can just change the |
Reading the comments, I don't see the reasoning behind being a bc break. It would mean a deploy script relied on the command to raise an error when the symlink failed. But when it expects that it fails, it would not have used the --symlink option. |
@Swader did you run vagrant as an admin ? or with simple user ? |
Simple user, non elevated
|
@Swader great then 👍 |
@Tobion idea looks like a good one. If we can avoid creating an option, it's even better. |
Maybe rather a --no-auto-symlink option to opt out. |
ok |
@rvanginneken Can you update the PR so that the nice new behavior happens automatically with the Thanks! |
@weaverryan Yep, I'm still following the thread. I don't have time right now but I'll update it in 1 or 2 days. |
@rvanginneken Perfect, thanks :) |
…ality into --symlink
👍 |
Thank you @rvanginneken. |
…neken) This PR was squashed before being merged into the 2.6-dev branch (closes #11312). Discussion ---------- Make assets:install smarter with symlinks | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | - | Fixed tickets | #11297 | License | MIT | Doc PR | - Commits ------- 6537333 Make assets:install smarter with symlinks
…l_extensions smarter with symlinks Mostly same change as in: symfony/symfony#11312 The Symfony change was not backported, so this works best in combination with Symfony 2.6, but will also slightly benefit users on Symfony 2.3 (at least for these commands)