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

'charm-strict-dependencies' requires at least one requirements file. in field 'parts.charm.charm-strict-dependencies' #1389

Open
carlcsaposs-canonical opened this issue Nov 24, 2023 · 14 comments
Assignees
Labels
Bug Something isn't working triaged

Comments

@carlcsaposs-canonical
Copy link
Contributor

carlcsaposs-canonical commented Nov 24, 2023

Bug Description

I'm guessing charm-strict-dependencies defaults to requirements.txt during charmcraft pack? Looks like the same default doesn't apply to charmcraft clean

To Reproduce

charmcraft installed from edge (rev 1824 2.5.0.post16+git23bf390)

  1. clone https://github.com/canonical/mysql-router-k8s-operator
  2. charmcraft pack
  3. charmcraft clean
Bad charmcraft.yaml content:
- 'charm-strict-dependencies' requires at least one requirements file. in field 'parts.charm.charm-strict-dependencies'                                                                                                                              
Full execution log: '/home/ubuntu/.local/state/charmcraft/log/charmcraft-20231124-090230.749172.log'    

Environment

Ubuntu 22.04

charmcraft.yaml

# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.

type: charm
bases:
  - build-on:
      - name: "ubuntu"
        channel: "22.04"
    run-on:
      - name: "ubuntu"
        channel: "22.04"
parts:
  charm:
    override-pull: |
      craftctl default
      if [[ ! -f requirements.txt ]]
      then
          echo 'ERROR: Use "tox run -e build" instead of calling "charmcraft pack" directly' >&2
          exit 1
      fi
    charm-entrypoint: src/kubernetes_charm.py
    prime:
      - charm_version
      - workload_version
      - scripts
    charm-strict-dependencies: true
    build-packages:
      - libffi-dev
      - libssl-dev
      - pkg-config
      - rustc
      - cargo

Relevant log output

charmcraft-20231124-090230.749172.log
charmcraft-20231124-084822.286563.log

@carlcsaposs-canonical carlcsaposs-canonical added the Bug Something isn't working label Nov 24, 2023
@carlcsaposs-canonical carlcsaposs-canonical changed the title - 'charm-strict-dependencies' requires at least one requirements file. in field 'parts.charm.charm-strict-dependencies' 'charm-strict-dependencies' requires at least one requirements file. in field 'parts.charm.charm-strict-dependencies' Nov 24, 2023
@carlcsaposs-canonical
Copy link
Contributor Author

Issue also on charmcraft latest/candidate (rev 1790 2.5.0.post1+gitf5558b8)

@lengau
Copy link
Collaborator

lengau commented Nov 29, 2023

Thanks for the report! This bug is actually in the pack command, as when charm-strict-dependencies: true is set it shouldn't be magicking up requirements.txt for you (instead requiring an explicit list of requirements files).

@lengau lengau added the triaged label Nov 29, 2023
@lengau
Copy link
Collaborator

lengau commented Dec 7, 2023

The only way I've been able to reproduce this is by deleting requirements.txt, but then both pack and clean complain about the lack of a requirements file. Could you check the state of the requirements.txt file when this happens?

Since this behaviour already infers a requirements.txt file (if it exists), I'm going to leave it that way.

@lengau lengau added the needs info Requires further clarification to understand the issue. label Dec 7, 2023
@lengau lengau self-assigned this Dec 7, 2023
@carlcsaposs-canonical
Copy link
Contributor Author

The only way I've been able to reproduce this is by deleting requirements.txt, but then both pack and clean complain about the lack of a requirements file. Could you check the state of the requirements.txt file when this happens?

Since this behaviour already infers a requirements.txt file (if it exists), I'm going to leave it that way.

oh sorry, I think that might be because of this

    override-pull: |
      craftctl default
      if [[ ! -f requirements.txt ]]
      then
          echo 'ERROR: Use "tox run -e build" instead of calling "charmcraft pack" directly' >&2
          exit 1
      fi

on mysql-router-k8s, we're using a wrapper around charmcraft to generate requirements.txt from poetry.lock

you can run tox run -e build instead of charmcraft pack
or run tox run -e pack-wrapper and mv requirements-last-build.txt requirements.txt before charmcraft pack

lengau added a commit to lengau/mysql-router-k8s-operator that referenced this issue Dec 8, 2023
Fixes canonical/charmcraft#1389

Signed-off-by: Alex Lowe <alex.lowe@canonical.com>
lengau added a commit to lengau/mysql-router-k8s-operator that referenced this issue Dec 8, 2023
Fixes canonical/charmcraft#1389

Signed-off-by: Alex Lowe <alex.lowe@canonical.com>
@lengau
Copy link
Collaborator

lengau commented Dec 8, 2023

Ah, looking at tox.ini I've figured it out. The commands_post includes moving requirements.txt. I've made a PR to create a clean environment to work around these conflicting requirements for now.

We might be able to make the clean command less strict about the existence of requirements.txt later, but it's sadly not feasible right now.

@lengau lengau closed this as not planned Won't fix, can't repro, duplicate, stale Dec 8, 2023
@carlcsaposs-canonical
Copy link
Contributor Author

Tried reproducing this & wasn't able to (even with same snap revision)

It appears that charmcraft clean does not require requirements.txt

@carlcsaposs-canonical
Copy link
Contributor Author

Encountering this issue again on 2.5.4 with charmcraft version and charmcraft clean if requirements.txt does not exist

https://github.com/canonical/mysql-router-k8s-operator/ branch wrapper

@carlcsaposs-canonical
Copy link
Contributor Author

carlcsaposs-canonical added a commit to canonical/mysql-router-k8s-operator that referenced this issue Jan 8, 2024
charmcraft bug causes check-lib check to fail
canonical/charmcraft#1389 (comment)
carlcsaposs-canonical added a commit to canonical/mysql-router-k8s-operator that referenced this issue Jan 8, 2024
charmcraft bug causes check-lib check to fail
canonical/charmcraft#1389 (comment)
carlcsaposs-canonical added a commit to canonical/mysql-k8s-operator that referenced this issue Jan 8, 2024
charmcraft bug causes check-lib check to fail
canonical/charmcraft#1389 (comment)
carlcsaposs-canonical added a commit to canonical/mysql-router-k8s-operator that referenced this issue Jan 8, 2024
charmcraft bug causes check-lib check to fail
canonical/charmcraft#1389 (comment)
carlcsaposs-canonical added a commit to canonical/mysql-k8s-operator that referenced this issue Jan 8, 2024
charmcraft bug causes check-lib check to fail
canonical/charmcraft#1389 (comment)
carlcsaposs-canonical added a commit to canonical/mysql-operator that referenced this issue Jan 8, 2024
charmcraft bug causes check-lib check to fail
canonical/charmcraft#1389 (comment)
carlcsaposs-canonical added a commit to canonical/mysql-router-operator that referenced this issue Jan 8, 2024
charmcraft bug causes check-lib check to fail
canonical/charmcraft#1389 (comment)
carlcsaposs-canonical added a commit to canonical/mysql-router-k8s-operator that referenced this issue Jan 8, 2024
charmcraft bug causes check-lib check to fail

canonical/charmcraft#1389 (comment)
carlcsaposs-canonical added a commit to canonical/data-platform-workflows that referenced this issue Jan 9, 2024
@carlcsaposs-canonical
Copy link
Contributor Author

@carlcsaposs-canonical
Copy link
Contributor Author

I'm surprised this affects commands like charmcraft upload, which don't seem to need to be run in a charm directory

carlcsaposs-canonical added a commit to canonical/data-platform-workflows that referenced this issue Jan 9, 2024
carlcsaposs-canonical added a commit to canonical/mysql-router-k8s-operator that referenced this issue Jan 9, 2024
Includes workaround for canonical/charmcraft#1389 to fix release CI
carlcsaposs-canonical added a commit to canonical/mysql-k8s-operator that referenced this issue Jan 9, 2024
Includes workaround for canonical/charmcraft#1389 to fix release CI
carlcsaposs-canonical added a commit to canonical/mysql-operator that referenced this issue Jan 9, 2024
carlcsaposs-canonical added a commit to canonical/mysql-router-k8s-operator that referenced this issue Jan 9, 2024
Includes workaround for
canonical/charmcraft#1389 to fix release CI
carlcsaposs-canonical added a commit to canonical/mysql-k8s-operator that referenced this issue Jan 9, 2024
Includes workaround for canonical/charmcraft#1389 to fix release CI
carlcsaposs-canonical added a commit to canonical/mysql-operator that referenced this issue Jan 9, 2024
@taurus-forever
Copy link

Dear @lengau

Can you please revise your decision to close this without fixing. It affects Data SQL charms... as even charmcraft login or charmcraft upload are causing issues for us, see Carl comments above.

Thank you in advance!

Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-2509.

This message was autogenerated

carlcsaposs-canonical added a commit to canonical/mysql-router-operator that referenced this issue Mar 5, 2024
charmcraft bug causes check-lib check to fail
canonical/charmcraft#1389 (comment)
@lengau lengau reopened this Mar 12, 2024
@lengau lengau removed the needs info Requires further clarification to understand the issue. label Mar 12, 2024
@lengau
Copy link
Collaborator

lengau commented Mar 12, 2024

OK @taurus-forever , @carlcsaposs-canonical , I'm convinced :-)

The fix probably won't make it into 3.0.0, but I'm going to consider options for how to better resolve this in Charmcraft.

@lucasgameiroborges
Copy link
Member

Hello! Just checking in this issue, I faced the same issue during my onboarding tasks.

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

Successfully merging a pull request may close this issue.

4 participants