question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when running ``poetry install`` in a new (empty) project.

See original GitHub issue
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Debian buster

  • Poetry version: 0.12.10

Issue

I was setting up a project, first I added some dependencies via poetry add (and I didn’t add any actual code). Then I issued poetry install which resulted in stacktrace below.

It turns out I had empty directory named like the package (in poetry.toml below package name is “test” and I had empty directory named test). It looks like it triggered a bug in find_packages. When I added some code to test package bug went away.

Error stacktrace

[IndexError]  
list index out of range    
	                     
Exception trace:
 /opt/venvs/poetry-0.12.10/lib/python3.7/site-packages/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /opt/venvs/poetry-0.12.10/lib/python3.7/site-packages/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /opt/venvs/poetry-0.12.10/lib/python3.7/site-packages/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /opt/venvs/poetry-0.12.10/lib/python3.7/site-packages/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 /opt/venvs/poetry-0.12.10/lib/python3.7/site-packages/cleo/commands/base_command.py in run() at line 146
   status_code = self.execute(input_, output_)
 /opt/venvs/poetry-0.12.10/lib/python3.7/site-packages/cleo/commands/command.py in execute() at line 107
   return self.handle()
 /opt/venvs/poetry-0.12.10/lib/python3.7/site-packages/poetry/console/commands/install.py in handle() at line 86
   f.write(decode(builder.build_setup()))
 /opt/venvs/poetry-0.12.10/lib/python3.7/site-packages/poetry/masonry/builders/sdist.py in build_setup() at line 125
   pkg_dir, _packages, _package_data = self.find_packages(include)
 /opt/venvs/poetry-0.12.10/lib/python3.7/site-packages/poetry/masonry/builders/sdist.py in find_packages() at line 237
   base = str(include.elements[0].parent)

poetry.toml

[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["Jacek Bzdak <jbzdak@gmail.com>"]

[tool.poetry.dependencies]
python = "^3.7"
six = "^1.11"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
seansfkelleycommented, Mar 8, 2019

A use-case for running install in an otherwise empty project is to improve caching behavior of Docker builds: I copy pyproject.toml and poetry.lock, then install, then copy in all the project source. I had to add an extra step to drop an empty file so Poetry wouldn’t explode when I did this:

RUN touch /path/to/project/.empty

Edit: though I guess I could just… not create the empty directory in the first place. That also works…

1reaction
Arkeliscommented, Jan 6, 2021

It seems that this error occurs when Poetry tries to install the current project’s package; a workaround is to specify --no-root when installing the depedencies if the project-named directory is empty. We could raise ModuleOrPackageNotFound instead of ValueError as the former is handled by the install command.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'poetry install' command fails; *.whl files are not found
Specifically I found that deleting the AppData\Local\pypoetry\Cache\artifacts folder (I'm on Windows 10) worked for me. virtualenvs for ...
Read more >
The pyproject.toml file | Documentation
When a script is added or updated, run poetry install to make them available in the project's virtualenv. extras #. Poetry supports extras...
Read more >
Poetry Advance
Poetry Advance. Poetry is the most sofisticated Python dependency system available (up to 2020). It allows you to go beyond simple dependency management, ......
Read more >
Configure a Poetry environment | PyCharm Documentation
You can declare the libraries your project depends on, and Poetry will install and update them for you. Project dependencies are recorded in...
Read more >
Dependency Management With Python Poetry
When your Python project relies on external packages, you need to make sure you're using the right version of each package.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found