Repository: pypa/pipenv

Issue:
subdirectory fragment of git located Dependencies of Packages (sub-dependency) aren't added to Pipfile.lock
### Issue description

When installing a package that has a git dependency with a subdirectory, the subdirectory isn't added to the Pipfile.lock.

Manually adding the subdirectory to the Pipfile.lock entry for that dependency fixes the issue.

Installing the library with `python -m pip install` works as well.

### Expected result

Subdirectory is added to that dependency's Pipfile.lock

```
"namespace-library": {
	"git": "git+https://github.com/AlexandreArpin/pipenv-repro.git",
	"ref": "2aed74cbc5110e21c3218f281f676f314f50d829",
	"subdirectory": "namespace-library-gitssh"
},
"namespace-utils": {
	"git": "git+https://github.com/AlexandreArpin/pipenv-repro.git",
	"ref": "2aed74cbc5110e21c3218f281f676f314f50d829",
        "subdirectory": "namespace-utils"
},
```

### Actual result

Pipfile.lock has the following entry:

```
"namespace-library": {
	"git": "git+https://github.com/AlexandreArpin/pipenv-repro.git",
	"ref": "2aed74cbc5110e21c3218f281f676f314f50d829",
	"subdirectory": "namespace-library-gitssh"
},
"namespace-utils": {
	"git": "git+https://github.com/AlexandreArpin/pipenv-repro@main#subdirectory=namespace-utils",
	"ref": "2aed74cbc5110e21c3218f281f676f314f50d829"
},
```

pipenv lock --verbose

```
Building requirements...
Resolving dependencies...
INFO:pipenv.patched.pip._internal.operations.prepare:Collecting namespace-library@ 
git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh (from -r 
C:\Users\Alex\AppData\Local\Temp\pipenv-tps7cx8p-requirements\pipenv-c4eg00es-constraints.txt (line 2))
INFO:pipenv.patched.pip._internal.vcs.git:Cloning https://github.com/AlexandreArpin/pipenv-repro.git (to revision main)
to c:\users\alex\appdata\local\temp\pip-temp-5xnhml7o\namespace-library_adf87b4cbd4f44c5921a6e1a280f07ad
INFO:pip.subprocessor:Running command git clone --filter=blob:none --quiet 
https://github.com/AlexandreArpin/pipenv-repro.git 
'C:\Users\Alex\AppData\Local\Temp\pip-temp-5xnhml7o\namespace-library_adf87b4cbd4f44c5921a6e1a280f07ad'
INFO:pipenv.patched.pip._internal.vcs.git:Resolved https://github.com/AlexandreArpin/pipenv-repro.git to commit 
4bdcda021e6d84173eb379bbeea59be12285f287
INFO:pipenv.patched.pip._internal.cli.spinners:Installing build dependencies: started
INFO:pipenv.patched.pip._internal.cli.spinners:Installing build dependencies: finished with status 'done'
INFO:pipenv.patched.pip._internal.cli.spinners:Getting requirements to build wheel: started
INFO:pipenv.patched.pip._internal.cli.spinners:Getting requirements to build wheel: finished with status 'done'
INFO:pipenv.patched.pip._internal.cli.spinners:Installing backend dependencies: started
INFO:pipenv.patched.pip._internal.cli.spinners:Installing backend dependencies: finished with status 'done'
INFO:pipenv.patched.pip._internal.cli.spinners:Preparing metadata (pyproject.toml): started
INFO:pipenv.patched.pip._internal.cli.spinners:Preparing metadata (pyproject.toml): finished with status 'done'
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.starting()
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.adding_requirement(ExplicitRequirement(LinkCa
ndidate('git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh')), None)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.starting_round(0)
INFO:pipenv.patched.pip._internal.operations.prepare:Collecting namespace-utils@ 
git+https://github.com/AlexandreArpin/pipenv-repro@main#subdirectory=namespace-utils (from namespace-library@ 
git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh->-r 
C:\Users\Alex\AppData\Local\Temp\pipenv-tps7cx8p-requirements\pipenv-c4eg00es-constraints.txt (line 2))
INFO:pipenv.patched.pip._internal.vcs.git:Cloning https://github.com/AlexandreArpin/pipenv-repro (to revision main) to 
c:\users\alex\appdata\local\temp\pip-temp-5xnhml7o\namespace-utils_443f92012fee48ef91dbc2dcc0145459
INFO:pip.subprocessor:Running command git clone --filter=blob:none --quiet 
https://github.com/AlexandreArpin/pipenv-repro 
'C:\Users\Alex\AppData\Local\Temp\pip-temp-5xnhml7o\namespace-utils_443f92012fee48ef91dbc2dcc0145459'
INFO:pipenv.patched.pip._internal.vcs.git:Resolved https://github.com/AlexandreArpin/pipenv-repro to commit 
4bdcda021e6d84173eb379bbeea59be12285f287
INFO:pipenv.patched.pip._internal.cli.spinners:Installing build dependencies: started
INFO:pipenv.patched.pip._internal.cli.spinners:Installing build dependencies: finished with status 'done'
INFO:pipenv.patched.pip._internal.cli.spinners:Getting requirements to build wheel: started
INFO:pipenv.patched.pip._internal.cli.spinners:Getting requirements to build wheel: finished with status 'done'
INFO:pipenv.patched.pip._internal.cli.spinners:Installing backend dependencies: started
INFO:pipenv.patched.pip._internal.cli.spinners:Installing backend dependencies: finished with status 'done'
INFO:pipenv.patched.pip._internal.cli.spinners:Preparing metadata (pyproject.toml): started
INFO:pipenv.patched.pip._internal.cli.spinners:Preparing metadata (pyproject.toml): finished with status 'done'
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.adding_requirement(SpecifierRequirement('aioh
ttp<4.0.0,>=3.8.3'), 
LinkCandidate('git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh'))
INFO:pipenv.patched.pip._internal.operations.prepare:Collecting aiohttp<4.0.0,>=3.8.3 (from namespace-library@ 
git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh->-r 
C:\Users\Alex\AppData\Local\Temp\pipenv-tps7cx8p-requirements\pipenv-c4eg00es-constraints.txt (line 2))
INFO:pipenv.patched.pip._internal.network.download:Using cached aiohttp-3.9.3-cp39-cp39-win_amd64.whl.metadata (7.6 kB)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.adding_requirement(ExplicitRequirement(LinkCa
ndidate('git+https://github.com/AlexandreArpin/pipenv-repro@main#subdirectory=namespace-utils')), 
LinkCandidate('git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.pinning(LinkCandidate('git+https://github.com
/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.ending_round(0, state)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.starting_round(1)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.adding_requirement(SpecifierRequirement('aios
ignal>=1.1.2'), 
LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e9216b59
10/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)'))
INFO:pipenv.patched.pip._internal.operations.prepare:Collecting aiosignal>=1.1.2 (from 
aiohttp<4.0.0,>=3.8.3->namespace-library@ 
git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh->-r 
C:\Users\Alex\AppData\Local\Temp\pipenv-tps7cx8p-requirements\pipenv-c4eg00es-constraints.txt (line 2))
INFO:pipenv.patched.pip._internal.network.download:Using cached aiosignal-1.3.1-py3-none-any.whl.metadata (4.0 kB)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.adding_requirement(SpecifierRequirement('attr
s>=17.3.0'), 
LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e9216b59
10/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)'))
INFO:pipenv.patched.pip._internal.operations.prepare:Collecting attrs>=17.3.0 (from 
aiohttp<4.0.0,>=3.8.3->namespace-library@ 
git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh->-r 
C:\Users\Alex\AppData\Local\Temp\pipenv-tps7cx8p-requirements\pipenv-c4eg00es-constraints.txt (line 2))
INFO:pipenv.patched.pip._internal.network.download:Using cached attrs-23.2.0-py3-none-any.whl.metadata (9.5 kB)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.adding_requirement(SpecifierRequirement('froz
enlist>=1.1.1'), 
LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e9216b59
10/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)'))
INFO:pipenv.patched.pip._internal.operations.prepare:Collecting frozenlist>=1.1.1 (from 
aiohttp<4.0.0,>=3.8.3->namespace-library@ 
git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh->-r 
C:\Users\Alex\AppData\Local\Temp\pipenv-tps7cx8p-requirements\pipenv-c4eg00es-constraints.txt (line 2))
INFO:pipenv.patched.pip._internal.network.download:Using cached frozenlist-1.4.1-cp39-cp39-win_amd64.whl.metadata (12 
kB)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.adding_requirement(SpecifierRequirement('mult
idict<7.0,>=4.5'), 
LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e9216b59
10/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)'))
INFO:pipenv.patched.pip._internal.operations.prepare:Collecting multidict<7.0,>=4.5 (from 
aiohttp<4.0.0,>=3.8.3->namespace-library@ 
git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh->-r 
C:\Users\Alex\AppData\Local\Temp\pipenv-tps7cx8p-requirements\pipenv-c4eg00es-constraints.txt (line 2))
INFO:pipenv.patched.pip._internal.network.download:Using cached multidict-6.0.5-cp39-cp39-win_amd64.whl.metadata (4.3 
kB)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.adding_requirement(SpecifierRequirement('yarl
<2.0,>=1.0'), 
LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e9216b59
10/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)'))
INFO:pipenv.patched.pip._internal.operations.prepare:Collecting yarl<2.0,>=1.0 (from 
aiohttp<4.0.0,>=3.8.3->namespace-library@ 
git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh->-r 
C:\Users\Alex\AppData\Local\Temp\pipenv-tps7cx8p-requirements\pipenv-c4eg00es-constraints.txt (line 2))
INFO:pipenv.patched.pip._internal.network.download:Using cached yarl-1.9.4-cp39-cp39-win_amd64.whl.metadata (32 kB)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.adding_requirement(SpecifierRequirement('asyn
c-timeout<5.0,>=4.0; python_version < "3.11"'), 
LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e9216b59
10/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)'))
INFO:pipenv.patched.pip._internal.operations.prepare:Collecting async-timeout<5.0,>=4.0 (from 
aiohttp<4.0.0,>=3.8.3->namespace-library@ 
git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh->-r 
C:\Users\Alex\AppData\Local\Temp\pipenv-tps7cx8p-requirements\pipenv-c4eg00es-constraints.txt (line 2))
INFO:pipenv.patched.pip._internal.network.download:Using cached async_timeout-4.0.3-py3-none-any.whl.metadata (4.2 kB)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.pinning(LinkCandidate('https://files.pythonho
sted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e9216b5910/aiohttp-3.9.3-cp39-cp39-win_amd64.
whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.ending_round(1, state)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.starting_round(2)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.pinning(LinkCandidate('git+https://github.com
/AlexandreArpin/pipenv-repro@main#subdirectory=namespace-utils'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.ending_round(2, state)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.starting_round(3)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.adding_requirement(SpecifierRequirement('froz
enlist>=1.1.0'), 
LinkCandidate('https://files.pythonhosted.org/packages/76/ac/a7305707cb852b7e16ff80eaf5692309bde30e2b1100a1fcacdc8f731d
97/aiosignal-1.3.1-py3-none-any.whl (from https://pypi.org/simple/aiosignal/) (requires-python:>=3.7)'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.pinning(LinkCandidate('https://files.pythonho
sted.org/packages/76/ac/a7305707cb852b7e16ff80eaf5692309bde30e2b1100a1fcacdc8f731d97/aiosignal-1.3.1-py3-none-any.whl 
(from https://pypi.org/simple/aiosignal/) (requires-python:>=3.7)'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.ending_round(3, state)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.starting_round(4)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.pinning(LinkCandidate('https://files.pythonho
sted.org/packages/a7/fa/e01228c2938de91d47b307831c62ab9e4001e747789d0b05baf779a6488c/async_timeout-4.0.3-py3-none-any.w
hl (from https://pypi.org/simple/async-timeout/) (requires-python:>=3.7)'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.ending_round(4, state)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.starting_round(5)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.pinning(LinkCandidate('https://files.pythonho
sted.org/packages/e0/44/827b2a91a5816512fcaf3cc4ebc465ccd5d598c45cefa6703fcf4a79018f/attrs-23.2.0-py3-none-any.whl 
(from https://pypi.org/simple/attrs/) (requires-python:>=3.7)'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.ending_round(5, state)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.starting_round(6)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.pinning(LinkCandidate('https://files.pythonho
sted.org/packages/29/eb/2110c4be2f622e87864e433efd7c4ee6e4f8a59ff2a93c1aa426ee50a8b8/frozenlist-1.4.1-cp39-cp39-win_amd
64.whl (from https://pypi.org/simple/frozenlist/) (requires-python:>=3.8)'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.ending_round(6, state)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.starting_round(7)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.pinning(LinkCandidate('https://files.pythonho
sted.org/packages/58/a3/4d2c1b4d1859c89d9ce48a4ae410ee019485e324e484b0160afdba8cc42b/multidict-6.0.5-cp39-cp39-win_amd6
4.whl (from https://pypi.org/simple/multidict/) (requires-python:>=3.7)'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.ending_round(7, state)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.starting_round(8)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.adding_requirement(SpecifierRequirement('idna
>=2.0'), 
LinkCandidate('https://files.pythonhosted.org/packages/a4/e0/5b4376d7361fe09a46dbb206131e8d85b1cb845da03c212a620d5b6b98
d8/yarl-1.9.4-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/yarl/) (requires-python:>=3.7)'))
INFO:pipenv.patched.pip._internal.operations.prepare:Collecting idna>=2.0 (from 
yarl<2.0,>=1.0->aiohttp<4.0.0,>=3.8.3->namespace-library@ 
git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh->-r 
C:\Users\Alex\AppData\Local\Temp\pipenv-tps7cx8p-requirements\pipenv-c4eg00es-constraints.txt (line 2))
INFO:pipenv.patched.pip._internal.network.download:Using cached idna-3.6-py3-none-any.whl.metadata (9.9 kB)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.adding_requirement(SpecifierRequirement('mult
idict>=4.0'), 
LinkCandidate('https://files.pythonhosted.org/packages/a4/e0/5b4376d7361fe09a46dbb206131e8d85b1cb845da03c212a620d5b6b98
d8/yarl-1.9.4-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/yarl/) (requires-python:>=3.7)'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.pinning(LinkCandidate('https://files.pythonho
sted.org/packages/a4/e0/5b4376d7361fe09a46dbb206131e8d85b1cb845da03c212a620d5b6b98d8/yarl-1.9.4-cp39-cp39-win_amd64.whl
 (from https://pypi.org/simple/yarl/) (requires-python:>=3.7)'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.ending_round(8, state)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.starting_round(9)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.pinning(LinkCandidate('https://files.pythonho
sted.org/packages/c2/e7/a82b05cf63a603df6e68d59ae6a68bf5064484a0718ea5033660af4b54a9/idna-3.6-py3-none-any.whl (from 
https://pypi.org/simple/idna/) (requires-python:>=3.5)'))
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.ending_round(9, state)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.starting_round(10)
INFO:pipenv.patched.pip._internal.resolution.resolvelib.reporter:Reporter.ending(State(mapping=OrderedDict([('namespace
-library', 
LinkCandidate('git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh')), 
('aiohttp', 
LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e9216b59
10/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)')), 
('namespace-utils', 
LinkCandidate('git+https://github.com/AlexandreArpin/pipenv-repro@main#subdirectory=namespace-utils')), ('aiosignal', 
LinkCandidate('https://files.pythonhosted.org/packages/76/ac/a7305707cb852b7e16ff80eaf5692309bde30e2b1100a1fcacdc8f731d
97/aiosignal-1.3.1-py3-none-any.whl (from https://pypi.org/simple/aiosignal/) (requires-python:>=3.7)')), 
('async-timeout', 
LinkCandidate('https://files.pythonhosted.org/packages/a7/fa/e01228c2938de91d47b307831c62ab9e4001e747789d0b05baf779a648
8c/async_timeout-4.0.3-py3-none-any.whl (from https://pypi.org/simple/async-timeout/) (requires-python:>=3.7)')), 
('attrs', 
LinkCandidate('https://files.pythonhosted.org/packages/e0/44/827b2a91a5816512fcaf3cc4ebc465ccd5d598c45cefa6703fcf4a7901
8f/attrs-23.2.0-py3-none-any.whl (from https://pypi.org/simple/attrs/) (requires-python:>=3.7)')), ('frozenlist', 
LinkCandidate('https://files.pythonhosted.org/packages/29/eb/2110c4be2f622e87864e433efd7c4ee6e4f8a59ff2a93c1aa426ee50a8
b8/frozenlist-1.4.1-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/frozenlist/) (requires-python:>=3.8)')), 
('multidict', 
LinkCandidate('https://files.pythonhosted.org/packages/58/a3/4d2c1b4d1859c89d9ce48a4ae410ee019485e324e484b0160afdba8cc4
2b/multidict-6.0.5-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/multidict/) (requires-python:>=3.7)')), 
('yarl', 
LinkCandidate('https://files.pythonhosted.org/packages/a4/e0/5b4376d7361fe09a46dbb206131e8d85b1cb845da03c212a620d5b6b98
d8/yarl-1.9.4-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/yarl/) (requires-python:>=3.7)')), ('idna', 
LinkCandidate('https://files.pythonhosted.org/packages/c2/e7/a82b05cf63a603df6e68d59ae6a68bf5064484a0718ea5033660af4b54
a9/idna-3.6-py3-none-any.whl (from https://pypi.org/simple/idna/) (requires-python:>=3.5)'))]), 
criteria={'namespace-library': 
Criterion((ExplicitRequirement(LinkCandidate('git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=
namespace-library-gitssh')), via=None)), 'aiohttp': Criterion((SpecifierRequirement('aiohttp<4.0.0,>=3.8.3'), 
via=LinkCandidate('git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh'))
), 'namespace-utils': 
Criterion((ExplicitRequirement(LinkCandidate('git+https://github.com/AlexandreArpin/pipenv-repro@main#subdirectory=name
space-utils')), 
via=LinkCandidate('git+https://github.com/AlexandreArpin/pipenv-repro.git@main#subdirectory=namespace-library-gitssh'))
), 'aiosignal': Criterion((SpecifierRequirement('aiosignal>=1.1.2'), 
via=LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e921
6b5910/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)'))), 
'attrs': Criterion((SpecifierRequirement('attrs>=17.3.0'), 
via=LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e921
6b5910/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)'))), 
'frozenlist': Criterion((SpecifierRequirement('frozenlist>=1.1.1'), 
via=LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e921
6b5910/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)')), 
(SpecifierRequirement('frozenlist>=1.1.0'), 
via=LinkCandidate('https://files.pythonhosted.org/packages/76/ac/a7305707cb852b7e16ff80eaf5692309bde30e2b1100a1fcacdc8f
731d97/aiosignal-1.3.1-py3-none-any.whl (from https://pypi.org/simple/aiosignal/) (requires-python:>=3.7)'))), 
'multidict': Criterion((SpecifierRequirement('multidict<7.0,>=4.5'), 
via=LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e921
6b5910/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)')), 
(SpecifierRequirement('multidict>=4.0'), 
via=LinkCandidate('https://files.pythonhosted.org/packages/a4/e0/5b4376d7361fe09a46dbb206131e8d85b1cb845da03c212a620d5b
6b98d8/yarl-1.9.4-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/yarl/) (requires-python:>=3.7)'))), 'yarl': 
Criterion((SpecifierRequirement('yarl<2.0,>=1.0'), 
via=LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e921
6b5910/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)'))), 
'async-timeout': Criterion((SpecifierRequirement('async-timeout<5.0,>=4.0; python_version < "3.11"'), 
via=LinkCandidate('https://files.pythonhosted.org/packages/28/03/c81f6d4ea89326b182b2e31e83388734ccae07b18d573e45f7e921
6b5910/aiohttp-3.9.3-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/aiohttp/) (requires-python:>=3.8)'))), 
'idna': Criterion((SpecifierRequirement('idna>=2.0'), 
via=LinkCandidate('https://files.pythonhosted.org/packages/a4/e0/5b4376d7361fe09a46dbb206131e8d85b1cb845da03c212a620d5b
6b98d8/yarl-1.9.4-cp39-cp39-win_amd64.whl (from https://pypi.org/simple/yarl/) (requires-python:>=3.7)')))}, 
backtrack_causes=[]))
INFO:pipenv.patched.pip._internal.network.download:Using cached aiohttp-3.9.3-cp39-cp39-win_amd64.whl (366 kB)
INFO:pipenv.patched.pip._internal.network.download:Using cached aiosignal-1.3.1-py3-none-any.whl (7.6 kB)
INFO:pipenv.patched.pip._internal.network.download:Using cached async_timeout-4.0.3-py3-none-any.whl (5.7 kB)
INFO:pipenv.patched.pip._internal.network.download:Using cached attrs-23.2.0-py3-none-any.whl (60 kB)
INFO:pipenv.patched.pip._internal.network.download:Using cached frozenlist-1.4.1-cp39-cp39-win_amd64.whl (50 kB)
INFO:pipenv.patched.pip._internal.network.download:Using cached multidict-6.0.5-cp39-cp39-win_amd64.whl (28 kB)
INFO:pipenv.patched.pip._internal.network.download:Using cached yarl-1.9.4-cp39-cp39-win_amd64.whl (76 kB)
INFO:pipenv.patched.pip._internal.network.download:Using cached idna-3.6-py3-none-any.whl (61 kB)
INFO:pipenv.patched.pip._internal.vcs.git:Cloning https://github.com/AlexandreArpin/pipenv-repro.git (to revision main)
to c:\users\alex\appdata\local\temp\tmp3k0xli_5
INFO:pip.subprocessor:Running command git clone --filter=blob:none https://github.com/AlexandreArpin/pipenv-repro.git 
'C:\Users\Alex\AppData\Local\Temp\tmp3k0xli_5'
INFO:pip.subprocessor:Cloning into 'C:\Users\Alex\AppData\Local\Temp\tmp3k0xli_5'...
INFO:pipenv.patched.pip._internal.vcs.git:Resolved https://github.com/AlexandreArpin/pipenv-repro.git to commit 
4bdcda021e6d84173eb379bbeea59be12285f287
INFO:pipenv.patched.pip._internal.vcs.git:Cloning https://github.com/AlexandreArpin/pipenv-repro (to revision main) to 
c:\users\alex\appdata\local\temp\tmp0sld_1dt
INFO:pip.subprocessor:Running command git clone --filter=blob:none https://github.com/AlexandreArpin/pipenv-repro 
'C:\Users\Alex\AppData\Local\Temp\tmp0sld_1dt'
INFO:pip.subprocessor:Cloning into 'C:\Users\Alex\AppData\Local\Temp\tmp0sld_1dt'...
INFO:pipenv.patched.pip._internal.vcs.git:Resolved https://github.com/AlexandreArpin/pipenv-repro to commit 
4bdcda021e6d84173eb379bbeea59be12285f287
Success!

```

### Steps to replicate

I have created a repository that has a reproduction case.

1. Clone https://github.com/AlexandreArpin/pipenv-repro
2. Go to `my-app-gitssh-dep` subdirectory
4. Run `pipenv lock`

Provide the steps to replicate (which usually at least includes the commands and the Pipfile).

-------------------------------------------------------------------------------
Pipenv version: `'2023.12.1'`

Pipenv location: `'C:\\Users\\Alex\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\pipenv'`

Python location: `'C:\\Users\\Alex\\AppData\\Local\\Programs\\Python\\Python310\\python.exe'`

OS Name: `'nt'`

User pip version: `'23.3.2'`

user Python installations found:


PEP 508 Information:
```
{'implementation_name': 'cpython',
 'implementation_version': '3.10.9',
 'os_name': 'nt',
 'platform_machine': 'AMD64',
 'platform_python_implementation': 'CPython',
 'platform_release': '10',
 'platform_system': 'Windows',
 'platform_version': '10.0.22631',
 'python_full_version': '3.10.9',
 'python_version': '3.10',
 'sys_platform': 'win32'}
 ```


Discussion:
I did some more digging - sorry for not catching the previous reported issues, search wasn't turning up anything with my keywords.

A PR in 2020 added support for direct VCS subdependencies support (#4259) after a few reported issues - the behavior was to keep the link "mostly" as is (it's even tested in `test_lock_nested_vcs_direct_url`), resulting in the Pipfile.lock entry of

```
"sibling-package": {
	"git": "git+https://github.com/techalchemy/test-project.git@master#subdirectory=parent_folder/sibling_package",
	"ref": "4f7b2b05e0c99d79ece1e8cfe5411a0e5a478648"
},
```

In my testing, if I take my repro-case and the test's repro-case, both result in the same error where it's not possible to install with this entry, since the subdirectory fragment is never taken into consideration

```
Installing dependencies from Pipfile.lock (0123e4)...
[pipenv.exceptions.InstallError]: Collecting sibling-package@ git+https://github.com/techalchemy/test-project.git@4f7b2b05e0c99d79ece1e8cfe5411a0e5a478648 (from -r c:\users\alex\appdata\local\temp\pipenv-o1a1m9fl-requirements\pipenv-7cyhz_eh-reqs.txt (line 1))
[pipenv.exceptions.InstallError]:   Cloning https://github.com/techalchemy/test-project.git (to revision 4f7b2b05e0c99d79ece1e8cfe5411a0e5a478648) to c:\users\alex\appdata\local\temp\pip-install-3zufyb1x\sibling-package_10e3adada849486299642ee0338503c8
[pipenv.exceptions.InstallError]:   Resolved https://github.com/techalchemy/test-project.git to commit 4f7b2b05e0c99d79ece1e8cfe5411a0e5a478648
[pipenv.exceptions.InstallError]: Running command git clone --filter=blob:none --quiet https://github.com/techalchemy/test-project.git 'C:\Users\Alex\AppData\Local\Temp\pip-install-3zufyb1x\sibling-package_10e3adada849486299642ee0338503c8'
[pipenv.exceptions.InstallError]:   Running command git rev-parse -q --verify 'sha^4f7b2b05e0c99d79ece1e8cfe5411a0e5a478648'
[pipenv.exceptions.InstallError]:   Running command git fetch -q https://github.com/techalchemy/test-project.git 4f7b2b05e0c99d79ece1e8cfe5411a0e5a478648
[pipenv.exceptions.InstallError]: ERROR: sibling-package@ git+https://github.com/techalchemy/test-project.git@4f7b2b05e0c99d79ece1e8cfe5411a0e5a478648 from git+https://github.com/techalchemy/test-project.git@4f7b2b05e0c99d79ece1e8cfe5411a0e5a478648 (from -r c:\users\alex\appdata\local\temp\pipenv-o1a1m9fl-requirements\pipenv-7cyhz_eh-reqs.txt (line 1)) does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.
ERROR: Couldn't install package: {}
```

I imagine that previously, it used to work though (without the subdirectory key added to the Pipfile.lock entry).

What is the correct fix in this situation @matteius? Should `pipenv lock` create a more detailed entry or should it be able to install and use the subdirectory fragment in the git reference when looking for the package?

I have a patch for `pipenv.utils.locking.format_requirement_for_lockfile` that correctly parses and create a Pipfile.lock entry with subdirectory, but _maybe_ that is breaking behavior if it was previously working at some point.

I'd be super eager to help more, let me know what solution you prefer!
@AlexandreArpin your patch sounds like the right direction to head in -- I'm getting lock resolution errors though with the egg fragment syntax, does your patch resolve for that as well?


Resolving patch:
diff --git a/pipenv/utils/locking.py b/pipenv/utils/locking.py
--- a/pipenv/utils/locking.py
+++ b/pipenv/utils/locking.py
@@ -14,6 +14,7 @@
     clean_resolved_dep,
     determine_vcs_revision_hash,
     expansive_install_req_from_line,
+    normalize_vcs_url,
     pep423_name,
     translate_markers,
 )
@@ -61,9 +62,16 @@ def format_requirement_for_lockfile(
     if req.link and req.link.is_vcs:
         vcs = req.link.scheme.split("+", 1)[0]
         entry["ref"] = determine_vcs_revision_hash(req, vcs, pipfile_entry.get("ref"))
-        entry[vcs] = original_deps.get(name, req.link.url)
+
+        if name in original_deps:
+            entry[vcs] = original_deps[name]
+        else:
+            vcs_url, _ = normalize_vcs_url(req.link.url)
+            entry[vcs] = vcs_url
         if pipfile_entry.get("subdirectory"):
             entry["subdirectory"] = pipfile_entry["subdirectory"]
+        elif req.link.subdirectory_fragment:
+            entry["subdirectory"] = req.link.subdirectory_fragment
     if req.req:
         entry["version"] = str(req.specifier)
     elif version:


Test patch:
diff --git a/tests/integration/test_lock.py b/tests/integration/test_lock.py
--- a/tests/integration/test_lock.py
+++ b/tests/integration/test_lock.py
@@ -532,7 +532,8 @@ def test_lock_nested_vcs_direct_url(pipenv_instance_pypi):
         assert "git" in p.lockfile["default"]["pep508-package"]
         assert "sibling-package" in p.lockfile["default"]
         assert "git" in p.lockfile["default"]["sibling-package"]
-        assert "subdirectory" in p.lockfile["default"]["sibling-package"]["git"]
+        assert "subdirectory" in p.lockfile["default"]["sibling-package"]
+        assert p.lockfile["default"]["sibling-package"]["subdirectory"] == "parent_folder/sibling_package"
         assert "version" not in p.lockfile["default"]["sibling-package"]