Skip to content
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

Installing a local package without setup.py, by file://, deletes the project directory #4152

Closed
jingxue opened this issue Mar 15, 2020 · 3 comments

Comments

@jingxue
Copy link

jingxue commented Mar 15, 2020

Issue description

I forgot to configure setup.py in a new project proj1, then tried to do pipenv install -e file:///path/to/proj1, from under another project directory. The command returned with a FileNotFoundError: [Errno 2] No such file or directory: '/path/to/proj1' error, and deleted the entire proj1 directory.

Expected result

I would have expected an error message along the lines of "setup.py is not found in proj1".

Actual result

➜  workspace/pipenv-test/proj2 pipenv install -e file://$HOME/workspace/pipenv-test/proj1
Installing -e file:///home/jingxue/workspace/pipenv-test/proj1…
Traceback (most recent call last):
  File "/home/jingxue/.local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/cli/command.py", line 254, in install
    editable_packages=state.installstate.editables,
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/core.py", line 1909, in do_install
    pkg_requirement = Requirement.from_line(pkg_line)
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 1092, in from_line
    r = FileRequirement.from_line(line_with_prefix, extras=extras)
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 548, in from_line
    return cls.create(**arg_dict)
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 477, in create
    setup_info = SetupInfo.from_ireq(ireq)
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 422, in from_ireq
    progress_bar="off",
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/patched/notpip/_internal/download.py", line 824, in unpack_url
    unpack_file_url(link, location, download_dir, hashes=hashes)
  File "/home/jingxue/.local/lib/python3.7/site-packages/pipenv/patched/notpip/_internal/download.py", line 700, in unpack_file_url
    shutil.copytree(link_path, location, symlinks=True)
  File "/usr/lib/python3.7/shutil.py", line 318, in copytree
    names = os.listdir(src)
FileNotFoundError: [Errno 2] No such file or directory: '/home/jingxue/workspace/pipenv-test/proj1'

pipenv support file attached.
support.txt

@jingxue
Copy link
Author

jingxue commented Mar 15, 2020

Just to add that running pipenv install -e ../proj1 gives the error below, but at least does not delete proj1.

Installing -e ../proj1…
WARNING: Invalid requirement, parse error at "'../proj1'"
✘ Installation Failed 

@amhrasmussen
Copy link

Hi @jingxue

I've been able to succesfully reproduce your bug with the below Dockerfile, I think. The good news is that the pipenv master branch doesn't appear to have this bug (as you can see by switching between the versions in the Dockerfile). So until #3369, It seems like installing pipenv from github is the way to go...

FROM ubuntu

ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

RUN apt-get update && apt-get -y install
python3
python3-pip
git

WORKDIR /app

RUN pip3 install -U pip
#Switch pipenv version here:
#RUN pip3 install -e git+https:/pypa/pipenv.git@d10b2a216a25623ba9b3e3c4ce4573e0d764c1e4#egg=pipenv
RUN pip3 install -e git+https:/pypa/[email protected]#egg=pipenv

RUN mkdir /testproj
RUN touch /testproj/somefile

RUN echo "ls -la /testproj && pipenv install -e file:///testproj || ls -la /testproj" > run.sh

CMD [ "sh", "run.sh"]

@techalchemy
Copy link
Member

@jingxue Sincere apologies for any trouble this might have caused you :| just so you are aware, pip install --upgrade --pre pipenv will get you a version of pipenv that does not cause this issue.

I'll close this for now as it's been fixed on master, even though it's not yet released -- the official release will be out soon. Thanks for reporting this and for your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants