Skip to content

Commit

Permalink
Restore windows symlink scanning and recreation, fixes #3254 (#3255)
Browse files Browse the repository at this point in the history
* Restore windows/composer/symlink section to docs
* Restore ReplaceSimulatedLinks operations for ddev composer
  • Loading branch information
rfay committed Sep 23, 2021
1 parent 1225cae commit 9700d58
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
8 changes: 6 additions & 2 deletions cmd/ddev/cmd/composer-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"path"
"path/filepath"
"runtime"
"strings"

"github.com/drud/ddev/pkg/ddevapp"
Expand Down Expand Up @@ -75,8 +76,8 @@ ddev composer create --prefer-dist --no-interaction --no-dev psr/log
}

for _, o := range objs {
// Preserve .ddev/
if o == ".ddev" || o == ".git" {
// Preserve .ddev, .git. .tarballs
if o == ".ddev" || o == ".git" || o == ".tarballs" {
continue
}

Expand Down Expand Up @@ -134,6 +135,9 @@ ddev composer create --prefer-dist --no-interaction --no-dev psr/log
if err != nil {
util.Warning("Failed to restart project after composer create: %v", err)
}
if runtime.GOOS == "windows" {
fileutil.ReplaceSimulatedLinks(app.AppRoot)
}
},
}

Expand Down
16 changes: 16 additions & 0 deletions docs/users/developer-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ If your composer.json is not in the project root, you'll need to provide the `-d

Note: if you run `ddev composer global require`, (or run `composer global require` inside the web container) the global packages will be installed in the in-container user's home directory ( ~/.composer) and will disappear on the next container restart, requiring rerun of the command. You may need an additional step of synchronizing created composer configuration and installed packages with the DDEV's [homeadditions folder](extend/in-container-configuration.md) on the host.

<a name="windows-os-and-ddev-composer"></a>

#### Windows OS and `ddev composer`

Both composer and some configurations of Docker Desktop for Windows introduce quite complex filesystem workarounds. DDEV attempts to help you with each of them.

You generally don't have to worry about any of this, but it does keep things cleaner. Mostly just a few of the more complex TYPO3 projects have been affected.

* On some configurations of Docker Desktop for Windows, symlinks are created in the container as "simulated symlinks", or XSym files. These are special text files that behave as symlinks inside the container (on CIFS filesystem), but appear as simple text files on the Windows host. (on the CIFS filesystem used by Docker for Windows inside the container there is no capability to create real symlinks, even though Windows now has this capability.)
* DDEV-Local attempts to clean up for this situation. Since Windows 10+ (in developer mode) can create real symlinks, DDEV-Local scans your repository after a `ddev composer` command and attempts to convert XSym files into real symlinks. It can only do this if your Windows 10 host is set to Developer Mode.
* On Windows 10+, to set your computer to developer mode, search for "developer" in settings. Screenshots are below.

![finding developer mode](images/developer_mode_1.png)

![setting developer mode](images/developer_mode_2.png)

#### Limitations with `ddev composer`

* Using `ddev composer --version` or `ddev composer -V` will not work, since `ddev` tries to utilize the command for itself. Use `ddev exec composer --version` instead.
Expand Down
2 changes: 1 addition & 1 deletion docs/users/extend/custom-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ tail -f /opt/solr/server/logs/solr.log

### Global commands

Global commands work exactly the same as project-level commands, you just have to put them in your global .ddev directory. Your home directory has a .ddev/commands in it; there you can add host or web or db commands.
Global commands work exactly the same as project-level commands, you just have to put them in your global .ddev directory. Your home directory has a .ddev/commands in it; there you can add host or web or db commands.

### Environment variables provided

Expand Down
5 changes: 5 additions & 0 deletions pkg/ddevapp/composer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package ddevapp

import (
"fmt"
"github.com/drud/ddev/pkg/fileutil"
"github.com/mattn/go-isatty"
"os"
"runtime"
"strings"
)

Expand All @@ -29,6 +31,9 @@ func (app *DdevApp) Composer(args []string) (string, string, error) {
if err != nil {
return stdout, stderr, err
}
if runtime.GOOS == "windows" {
fileutil.ReplaceSimulatedLinks(app.AppRoot)
}
err = app.ProcessHooks("post-composer")
if err != nil {
return "", "", fmt.Errorf("Failed to process post-composer hooks: %v", err)
Expand Down

0 comments on commit 9700d58

Please sign in to comment.