Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Parse error for file on Linux #2323

Closed
OrangeDog opened this issue Jun 7, 2018 · 13 comments
Closed

Parse error for file on Linux #2323

OrangeDog opened this issue Jun 7, 2018 · 13 comments
Labels
Type: Regression This issue is a regression of a previous behavior.

Comments

@OrangeDog
Copy link
Contributor

This is almost the same as #2256 except the workaround (use forward slashes) doesn't work.
Pipenv 2018.05.18

This dependency works great on Windows

python-ldap = {platform_system = "== 'Windows'", file = "./python_ldap-3.1.0-cp36-cp36m-win_amd64.whl"}

However, running pipenv install --skiplock --dev on Linux (the Docker image python:3.6 to be exact) gives this error:

Installing dependencies from Pipfile…
WARNING: Invalid requirement, parse error at "'./python'"
ABORTING INSTALL... You will have to reinstall any packages that failed to install.

Is it because the file doesn't exist? I would expect it to not care because the marker doesn't match.

@OrangeDog
Copy link
Contributor Author

Is it because the file doesn't exist?

Yes. If the file exists then it's fine. Should have a better error message at least.

@OrangeDog OrangeDog changed the title File requirement is invalid on Linux Parse error if file requirement not found Jun 7, 2018
@uranusjr
Copy link
Member

uranusjr commented Jun 7, 2018

Contributions are welcomed!

@uranusjr uranusjr added the good first issue Issues suitable as a newcomer to get familiar with Pipenv! label Jun 7, 2018
@techalchemy
Copy link
Member

--skiplock isn't a thing -- --skip-lock however is. And the file instruction is for properly formatted URI requirements, you have supplied a path. You need to use the path key.

@OrangeDog
Copy link
Contributor Author

OrangeDog commented Jun 7, 2018

@techalchemy Sorry, --skiplock was a title typo.

If local files are not allowed, then the bug is that they work on Windows.

@uranusjr
Copy link
Member

uranusjr commented Jun 7, 2018

Well if that works let’s keep it that way. No harm being lenient :) Let’s focus on providing better error messages.

@techalchemy
Copy link
Member

@OrangeDog they are allowed. They are not allowed in a file key. Use a URI in a file key and a relative path in a path key. That is how the spec operates.

@OrangeDog
Copy link
Contributor Author

@techalchemy that's why I said local files, not local paths.

@techalchemy
Copy link
Member

I have no clue why what you call it matters. A relative path goes in a path entry. Local files are completely fine and they work just fine in file keys, but you need to format them as a file uri. It’s possible you are crossing pipenv versions but this library works the same on all platforms in the current release and should fail to parse invalid requirements no matter what.

@OrangeDog
Copy link
Contributor Author

@techalchemy we seem to be talking at cross purposes. I'm calling a path a path and a file a file. Apparently one goes in path and the other goes in file. That's exactly what you said.

this library works the same on all platforms in the current release

That's not what I'm seeing (current release is 2018.05.18), because on Windows a file works without using a URI.

@OrangeDog OrangeDog changed the title Parse error if file requirement not found Parse error for file on Linux Jun 8, 2018
@techalchemy
Copy link
Member

hmmm I see. We must be doing some kind of odd normalization. I'll dig into this before we release

@GPHemsley
Copy link
Contributor

Confirmed that this problem still exists:

$ pipenv install --skip-lock --dev
Installing dependencies from Pipfile…
Traceback (most recent call last):
  File "/home/gphemsley/.local/share/virtualenvs/sandbox-A02kEjjY/bin/pipenv", line 11, in <module>
    load_entry_point('pipenv', 'console_scripts', 'pipenv')()
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/cli/command.py", line 232, in install
    retcode = do_install(
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/core.py", line 2051, in do_install
    do_init(
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/core.py", line 1306, in do_init
    do_install_dependencies(
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/core.py", line 842, in do_install_dependencies
    deps_list = list(lockfile.get_requirements(dev=dev, only=dev_only))
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/requirementslib/models/lockfile.py", line 273, in get_requirements
    yield Requirement.from_pipfile(k, v)
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/requirementslib/models/requirements.py", line 2743, in from_pipfile
    r = FileRequirement.from_pipfile(name, pipfile)
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/requirementslib/models/requirements.py", line 1842, in from_pipfile
    arg_dict["parsed_line"] = Line(line)
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/requirementslib/models/requirements.py", line 178, in __init__
    self.parse()
  File "/home/gphemsley/Development/Python/Code/pypa/pipenv/pipenv/vendor/requirementslib/models/requirements.py", line 1309, in parse
    raise RequirementError(
pipenv.vendor.requirementslib.exceptions.RequirementError: Supplied requirement is not installable: 'file:///home/gphemsley/Development/Python/Code/pypa/sandbox/python_ldap-3.1.0-cp36-cp36m-win_amd64.whl#egg=python-ldap'

@GPHemsley
Copy link
Contributor

If I'm reading this correctly, do_install_dependencies is calling lockfile.get_requirements before resolving markers, thereby failing due to the missing file.

I'm not sure what the right approach to fixing this would be.

@willhoh
Copy link
Contributor

willhoh commented Jan 29, 2022

Hi, I've tested the command pipenv install --skip-lock --dev and get no errors.
Is this issue fixed or do I something wrong?

Test environment

  1. Docker python:3.9
  2. installed pipenv with pip install -e pipenv/
  3. run command pipenv install --skip-lock --dev in empty directory

Output

`root@623cff45dafb:/opt/test# pipenv install --skip-lock --dev
Creating a virtualenv for this project...
Pipfile: /opt/test/Pipfile
Using /usr/local/bin/python (3.9.10) to create virtualenv...
⠇ Creating virtual environment...created virtual environment CPython3.9.10.final.0-64 in 496ms
creator CPython3Posix(dest=/root/.local/share/virtualenvs/test-mkYyOAPV, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
added seed packages: pip==21.3.1, setuptools==60.2.0, wheel==0.37.1
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment!
Virtualenv location: /root/.local/share/virtualenvs/test-mkYyOAPV
Creating a Pipfile for this project...
Installing dependencies from Pipfile...
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
`

@matteius matteius added Type: Regression This issue is a regression of a previous behavior. and removed good first issue Issues suitable as a newcomer to get familiar with Pipenv! labels Sep 7, 2022
@matteius matteius closed this as completed Sep 7, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Type: Regression This issue is a regression of a previous behavior.
Projects
None yet
Development

No branches or pull requests

6 participants