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

Closed
carlcsaposs-canonical opened this issue Nov 24, 2023 · 18 comments · Fixed by #1808 or canonical/mongos-operator#66
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 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.

@taurus-forever
Copy link

@lengau can you please share the plans for the fix here?

We would like to avoid workarounds on our side, ETA will help us a lot. Thank you!

@lengau lengau linked a pull request Aug 12, 2024 that will close this issue
lengau added a commit to lengau/mysql-router-k8s-operator that referenced this issue Aug 12, 2024
This demonstrates using `poetry export` inside the build of the charm,
allowing the user to `git clone` and then `charmcraft pack`.

It also:

- Uses the dump plugin to add extra primed files
- Adds an explicit requirements file (see: canonical/charmcraft#1389)
@lengau
Copy link
Collaborator

lengau commented Aug 12, 2024

This is fixed in #1808. However, the original error message from the sample file will persist, as Charmcraft doesn't assume a requirements file if none exists. The workaround is to add:

charm-requirements:
  - requirements.txt

to your charm part. Files explicitly listed in charm-requirements won't get an existence check until the relevant part of the build is actually running, so they can be created during build. I've put together a demo PR for mysql-router-k8s-operator here.

@carlcsaposs-canonical
Copy link
Contributor Author

@lengau I don't think this is fixed

Files explicitly listed in charm-requirements won't get an existence check until the relevant part of the build is actually running

As of charmcraft 2.7.3, adding a file to charm-requirements doesn't solve this issue

$ charmcraft version --format json
Bad charmcraft.yaml content:
- requirements file '/home/ubuntu/mysql-router-k8s-operator/requirements.txt' not found in field 'parts.charm.charm-requirements'
- '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-20240924-075645.585831.log' 

@carlcsaposs-canonical
Copy link
Contributor Author

same issue when running charmcraft pack instead of charmcraft version

carlcsaposs-canonical added a commit to canonical/data-platform-workflows that referenced this issue Sep 24, 2024
Mehdi-Bendriss pushed a commit to canonical/mongodb-operator that referenced this issue Oct 3, 2024
carlcsaposs-canonical added a commit to canonical/mysql-test-app that referenced this issue Nov 13, 2024
carlcsaposs-canonical added a commit to canonical/charmcraftcache-hub that referenced this issue Nov 13, 2024
…app-charm (#136)"

This reverts commit 6461591.

data-integrator tests/integration/app-charm is affected by canonical/charmcraft#1389 & that issue cannot be worked around on charmcraft 2 with an empty requirements.txt because the charm uses strict deps and binary packages

Suggested temporary workaround: disable caching for data-integrator tests/integration/app-charm until we migrate from charmcraft 2 to 3
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
4 participants