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

[BUG] Invalid pyproject.toml when project name matches name of project.scripts #1609

Open
nebuk4d opened this issue Nov 14, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@nebuk4d
Copy link

nebuk4d commented Nov 14, 2024

Description

When creating a new project in CrewAI using crewai create crew <project_name> and setting the project name to match any of the script names in project.scripts (e.g., test, run_crew, train, replay), the generated pyproject.toml contains duplicate keys, which leads to parsing errors. This is due to the pyproject.toml template used in the CLI tool, where the project.scripts section assigns the project name as a key, resulting in duplication when the project name conflicts with an existing key.

Steps to Reproduce

  1. Install CrewAI, version 0.80.0.
  2. Create a new project with crewai create crew test (or any project name that matches a key in project.scripts).
  3. Navigate to the created project and attempt to install dependencies with crewai install.

Expected behavior

The pyproject.toml file should be generated without duplicate keys in the project.scripts section, allowing dependencies to install without errors.

Screenshots/Code snippets

Template in CLI Tool:

[project]
name = "{{folder_name}}"
version = "0.1.0"
description = "{{name}} using crewAI"
authors = ["Your Name <[email protected]>"]
requires-python = ">=3.10,<=3.13"
dependencies = [
    "crewai[tools]>=0.79.4,<1.0.0"
]

[project.scripts]
{{folder_name}} = "{{folder_name}}.main:main"
run_crew = "{{folder_name}}.main:main"
train = "{{folder_name}}.main:train"
replay = "{{folder_name}}.main:replay"
test = "{{folder_name}}.main:test"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

Generated pyproject.toml with Project Name test:

[project.scripts]
test = "test.main:test"  # Duplicate key error here
run_crew = "test.main:main"
train = "test.main:train"
replay = "test.main:replay"

Operating System

macOS Sonoma

Python Version

3.12

crewAI Version

0.80.0

crewAI Tools Version

Virtual Environment

Venv

Evidence

(.venv) ~/d/a/test ❯❯❯ crewai install
warning: Failed to parse pyproject.toml during settings discovery:
TOML parse error at line 16, column 1
|
16 | test = "test.main:test"
| ^
duplicate key test in table project.scripts

error: Failed to parse: pyproject.toml
Caused by: TOML parse error at line 16, column 1
|
16 | test = "test.main:test"
| ^
duplicate key test in table project.scripts

image

Possible Solution

Modify the template generation logic in the CLI tool to check for duplicate keys in project.scripts. Alternatively, add a check to prevent project names that would conflict with default script names (e.g., test, run_crew, train, replay).

Additional context

None - reach out if you need more

@nebuk4d nebuk4d added the bug Something isn't working label Nov 14, 2024
@Th3R3p0
Copy link

Th3R3p0 commented Nov 19, 2024

+1. I named my first crew ai directory test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants