Skip to content

Getting "Template directory must be inside of the repository directory." error when not specifying template_dir option. #994

@Wiley-Black

Description

@Wiley-Black

Bug Report

Description

Running "semantic-release --noop version --print" to try and verify my configuration and see the next version number.

I have no template_dir in my pyproject.toml, so using the default template.

Expected behavior

Would not expect this error message since I'm using the default templates and don't have a template directory specified.

Actual behavior

The following error:

🛡  You are running in no-operation mode, because the '--noop' flag was supplied
[18:51:22] WARNING  [semantic_release.cli.config] WARNING config.from_raw_config: Token value is missing!                                                              config.py:558
Template directory must be inside of the repository directory.

Environment

Windows 11
Python 3.9
Semantic-Release 9.8.6
Poetry 1.8.2

Configuration

Semantic Release Configuration
...
[tool.semantic_release]
version_variables = [
  "src/project/__init__.py:__version__"
]
version_toml = ["pyproject.toml:tool.poetry.version"]
changelog_file = "CHANGELOG.md"
build_command = "poetry build"
dist_path = "dist/"
upload_to_vcs_release = false
upload_to_pypi = false
remove_dist = false
patch_without_tag = true
major_on_zero = true

[tool.semantic_release.commit_parser_options]
allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "style", "refactor", "test"]
minor_tags = ["feat"]
patch_tags = ["fix", "perf"]

[tool.semantic_release.branches.main]
match = "develop"
prerelease = false

[tool.semantic_release.branches.others]
match = "^(?!develop$)"
prerelease = true
prerelease_token = "alpha"

Execution Log

semantic-release -vv command
[18:52:55] DEBUG    [semantic_release.cli.commands.main] DEBUG main.main: logging level set to: DEBUG                                                                    main.py:123
🛡  You are running in no-operation mode, because the '--noop' flag was supplied
           DEBUG    [semantic_release.cli.commands.main] DEBUG main.main: global cli options: GlobalCommandLineOptions(noop=True, verbosity=2,                           main.py:135
                    config_file='pyproject.toml', strict=False)
           INFO     [semantic_release.cli.util] INFO util.load_raw_config_file: Loading configuration from pyproject.toml                                                 util.py:79
           DEBUG    [semantic_release.cli.util] DEBUG util.load_raw_config_file: Trying to parse configuration pyproject.toml in TOML format                              util.py:82
           DEBUG    [semantic_release.cli.config] DEBUG config.select_branch_options: Rejecting group 'main' as 'develop' doesn't match 'fix/deploy2'                  config.py:421
           INFO     [semantic_release.cli.config] INFO config.select_branch_options: Using group 'others' options, as '^(?!develop$)' matches 'fix/deploy2'            config.py:414
           DEBUG    [semantic_release.cli.config] DEBUG config.from_raw_config: hvcs token is not set                                                                  config.py:555
           WARNING  [semantic_release.cli.config] WARNING config.from_raw_config: Token value is missing!                                                              config.py:558
Template directory must be inside of the repository directory.

Additional context

The following check in cli/config.py:582 triggers the error:

if raw.repo_dir not in template_dir.parents:

I added some debug outputs and observe that raw.repo_dir is giving a full path, e.g. "C:\Code\project" whereas the default template_dir is "templates"- not an absolute path. template_dir.parents then comes out to ['.']. I believe the lack of resolving the path to an absolute path might be to blame here. repo_dir gets resolved to an absolute path by the field_validator in RawConfig, here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working properlyconfirmedPrevent from becoming stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions