Cannot use remote repository in a composer on windows Cannot use remote repository in a composer on windows windows windows

Cannot use remote repository in a composer on windows


Composer will be able to work out what kind of VCS you're using, so instead of "type": "git", try "type": "vcs" (see Composer docs and this SO answer).

Rather than using a git clone, you could use it by path reference if you just want to point to the local repository instead of cloning it or using git-specific operations (like version tags, etc).

Also on Windows you may need to use Windows-style formatting for the repository/library path (see Composer - using a local repository SO comment), and if it's a Windows shared drive you may need to check permissions.

EDIT

I had a more in-depth look at this, and was able to reproduce both the git clone and composer install behavior pretty easily even by just looking at the network name of my own PC.

Attempting to use Windows-style syntax (i.e. file://\\\\remote\\repo\\library) did not work for me, as it fell over in the middle of the git process somewhere.

It looks like there are some issues around named network drives interacting inside composer itself: since you can load repositories on local disks using the file:// syntax described and it's possible to correctly clone and fetch files from a networked drive using the normal //drive/repo syntax and command-line git I'm not sure if this is necessarily solvable without delving into the composer source (which was what needed to happen for someone to get local Windows drive support).

This means that setting up your network drive location to map to a letter on your local machine (as per smcjones' answer) will work as well since it would be treated the same as a local windows drive. You can also add hooks as @smcjones points out if you want to automatically map/unmap the drive (although you'd have to remember not to assign that drive letter to anything else).

Assuming you have access to the relevant computer, setting up a git daemon on the local network computer you wish to serve it up from (using this answer is pretty straightforward) so you can use the git:// protocol version works pretty well, although depending on your setup you also may need to make sure that your "minimum-stability" flag is set to "dev" and if you're not transporting over HTTPS you may need to look up your local composer config file (probably in C:\Users\Username\AppData\Roaming\Composer\config.json) and add "secure-http": false to it to serve up over the network without setting up an SSL certificate (unless you want to set that up).


You can try and add a package repository similar to this one

Basically, you define the same information that is included in the composer repository's packages.json, but only for a single package.
Again, the minimum required fields are name, version, and either of dist or source.

(See also this example)

Then check if the issue persists.

Just in case, check first if:


If you are planning on using this share as a repo server, or pull this repo from multiple locations, you may want to go with Leith's answer on setting up a Git daemon, or you could look at setting up SSH server on Windows 10. These require additional work on the network to set up.

The method below can be useful for someone who is simply trying to patch something together and doesn't want to deal with server configuration or daemons. It does not require access to server privileges, and just requires you to have access to the location on your network.

The quickest course of action will be to map your network drive, manually or automatically. In the command line, if you want to map to "R":

net use R: \\remote\repo

Alternatively, you can automatically set this up by using composer's script functionality and build a small .cmd file to be executed on pre-update-cmd and post-update-cmd:

map_drive.cmd:

if not exist r: (    net use R: "\\remote\path\to\repo")

You can do the same thing for post-update-cmd and post-install-cmd to unmap the network drive.

unmap_drive.cmd

if exist r: (    net use R: /delete)

composer.json:

\.."scripts": {    "pre-install-cmd": [        "map_drive.cmd"    ],    "pre-update-cmd": [        "map_drive.cmd"    ],    "post-install-cmd": [        "unmap_drive.cmd"    ],    "post-update-cmd" [        "unmap_drive.cmd"    ]}...

Now you can access directly.

\..."repositories": [    {        "type": "git",        "url": "R:/library"    }] ...

Please note that, although @Leith has pointed out that you must use file://r/ in place of R:/, I found that the file protocol was not working on my setup of Windows. Use whichever syntax works for you!

Whether you go with this patch method or a more complex method depends on your application and use. Running a git daemon or SSH server might be viewed as an annoyance in certain circumstances, and adds more overhead. If you only intend to use this temporarily or sporadically, the scripts above should get you running.