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

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

Closed
3 tasks done
jbzdak opened this issue Nov 29, 2018 · 10 comments
Closed
3 tasks done

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

jbzdak opened this issue Nov 29, 2018 · 10 comments
Labels
area/error-handling Bad error messages/insufficient error handling

Comments

@jbzdak
Copy link

jbzdak commented Nov 29, 2018

  • 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 <[email protected]>"]

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

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
@seansfkelley
Copy link

seansfkelley commented 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...

@stale
Copy link

stale bot commented Nov 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 13, 2019
@seansfkelley
Copy link

This is still an issue, I believe, and is stale waiting on the maintainers.

@stale stale bot removed the stale label Nov 13, 2019
@sdispater
Copy link
Member

Please, can you test with the latest beta version of Poetry?

@finswimmer
Copy link
Member

In the current release, poetry ends up with

[ValueError]
test is not a package.

As all dependencies are installed before, the venv is sane. I wonder if we should just print out a warning instead of raising an exception?

fin swimmer

@finswimmer finswimmer added the area/error-handling Bad error messages/insufficient error handling label Feb 7, 2020
@Arkelis
Copy link

Arkelis commented 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.

@Goldziher
Copy link

issue occurs when --no-root is specified.

My use case: I have a monorepo with multiple packages. At the root level there is a pyproject.toml that has all shared and dev dependencies. Now, all other sub-applications also have pyproject.toml files, but some have no dependencies because they only use the shared dependencies. For example, all fastapi apps use the same dependencies, while the ML apps also have ML dependencies.

Thus, i have a generic docker file, which calls poetry install for each package - but for those that have no dependencies, it fails.

@John15321
Copy link
Contributor

Hi
@jbzdak
@Goldziher
Is this still an issue?
I am on poetry 1.1.13 and I cannot replicate that error:

image

Am I doing something else here than you guys did?

@neersighted
Copy link
Member

This does not reproduce, and the ask to better support non-package/container-first use-cases is tracked in #1132

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/error-handling Bad error messages/insufficient error handling
Projects
None yet
Development

No branches or pull requests

8 participants