conda/menuinst

problem with conda build, Failed validating 'type' in schema - tried on linux

Closed this issue · 8 comments

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

I setup a menu.json

{
  "$schema": "https://json-schema.org/draft-07/schema",
  "$id": "https://schemas.conda.io/menuinst-1.schema.json",
  "menu_name": "Mission Support System",
  "menu_items": [
    {
      "name": "MSUI",
      "description": "Mission Support System UI",
      "activate": true,
      "command": ["{{ PREFIX }}/bin/msui.py"],
      "icon": "{{ MENU_DIR }}/msui.{{ ICON_EXT }}",
      "platforms": {
        "linux": {
          "Categories": ["Science", "Education"],
          "Keywords": ["documentation", "information"],
          "StartupNotify": true,
          "command": ["{{ PREFIX }}/bin/msui.py"],
          "MimeType": ["application/x-menuinst"],
          "glob_patterns": {
            "application/x-menuinst": ["*.menuinst"]
          }
        },
        "osx": {
          "CFBundleDocumentTypes": [
            {
              "CFBundleTypeName": "org.conda.menuinst.opener",
              "CFBundleTypeRole": "Viewer",
              "LSItemContentTypes": ["org.conda.menuinst.main-file-uti"],
              "LSHandlerRank": "Default"
            }
          ],
          "UTExportedTypeDeclarations": [
            {
              "UTTypeConformsTo": ["public.data", "public.content"],
              "UTTypeIdentifier": "org.conda.menuinst.main-file-uti",
              "UTTypeTagSpecification": [
                {
                  "public.filename-extension": ["menuinst"]
                }
              ]
            }
          ]
        },
        "windows": {
          "command": ["{{ SCRIPTS_DIR }}/msui.py"],
          "desktop": true,
          "quicklaunch": true
        }
      }
    }
  ]
}

Using conda build . I am able to build a wheel
Building wheel for mss (setup.py): finished with status 'done'

But with the menu entries something is wrong

Validating Menu/*.json files
WARNING: 'Menu/mss_menu.json' is not a valid menuinst JSON document!
Traceback (most recent call last):
  File "/home/user/Miniforge/lib/python3.11/site-packages/conda_build/post.py", line 1776, in check_menuinst_json
    validator.validate(json.loads(text))
  File "/home/user/Miniforge/lib/python3.11/site-packages/jsonschema/validators.py", line 438, in validate
    raise error
jsonschema.exceptions.ValidationError: ['*.menuinst'] is not of type 'string'

Failed validating 'type' in schema['properties']['menu_items']['items']['properties']['platforms']['properties']['linux']['properties']['glob_patterns']['additionalProperties']:
    {'pattern': '.*\\*.*', 'type': 'string'}

On instance['menu_items'][0]['platforms']['linux']['glob_patterns']['application/x-menuinst']:
    ['*.menuinst']
Fixing permissions
Packaged license file/s.
INFO :: Time taken to mark (prefix)
        0 replacements in 0 files was 0.01 seconds

also it always shows a Warning

ClobberWarning: This transaction has incompatible packages due to a shared path.
  packages: local/linux-64::mss-beta-py311_1000, local/linux-64::mss-beta-py311_1000
  path: 'Menu/mss_menu.json'

my tests also fail

Conda Info

active environment : base
    active env location : /home/user/Miniforge
            shell level : 1
       user config file : /home/user/.condarc
 populated config files : /home/user/Miniforge/.condarc
          conda version : 24.1.2
    conda-build version : 3.28.4
         python version : 3.11.6.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=skylake
                          __conda=24.1.2=0
                          __glibc=2.35=0
                          __linux=6.5.0=0
                          __unix=0=0
       base environment : /home/user/Miniforge  (writable)
      conda av data dir : /home/user/Miniforge/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /home/user/Miniforge/pkgs
                          /home/user/.conda/pkgs
       envs directories : /home/user/Miniforge/envs
                          /home/user/.conda/envs
               platform : linux-64
             user-agent : conda/24.1.2 requests/2.31.0 CPython/3.11.6 Linux/6.5.0-10027-tuxedo tuxedo/22.04 glibc/2.35 solver/libmamba conda-libmamba-solver/24.1.0 libmambapy/1.5.7
                UID:GID : 1000:1000
             netrc file : None

Conda Config

==> /home/reimarb/Miniforge/.condarc <==
channels:
  - conda-forge


### Conda list

```shell
conda list --show-channel-urls
# packages in environment at /home/reimarb/Miniforge:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
anyio                     3.7.1              pyhd8ed1ab_0    conda-forge
archspec                  0.2.3              pyhd8ed1ab_0    conda-forge
attrs                     23.2.0             pyh71513ae_0    conda-forge
beautifulsoup4            4.12.3             pyha770c72_0    conda-forge
boa                       0.16.0             pyhd8ed1ab_1    conda-forge
boltons                   23.1.1             pyhd8ed1ab_0    conda-forge
brotli-python             1.1.0           py311hb755f60_1    conda-forge
bzip2                     1.0.8                hd590300_5    conda-forge
c-ares                    1.27.0               hd590300_0    conda-forge
ca-certificates           2024.2.2             hbcca054_0    conda-forge
certifi                   2024.2.2           pyhd8ed1ab_0    conda-forge
cffi                      1.16.0          py311hb3a22ac_0    conda-forge
chardet                   5.2.0           py311h38be061_1    conda-forge
charset-normalizer        3.3.2              pyhd8ed1ab_0    conda-forge
click                     8.1.7           unix_pyh707e725_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
conda                     24.1.2          py311h38be061_0    conda-forge
conda-build               3.28.4          py311h38be061_0    conda-forge
conda-index               0.4.0              pyhd8ed1ab_0    conda-forge
conda-libmamba-solver     24.1.0             pyhd8ed1ab_0    conda-forge
conda-package-handling    2.2.0              pyh38be061_0    conda-forge
conda-package-streaming   0.9.0              pyhd8ed1ab_0    conda-forge
conda-verify              3.1.1           py311h38be061_1006    conda-forge
cryptography              42.0.5          py311h63ff55d_0    conda-forge
distro                    1.9.0              pyhd8ed1ab_0    conda-forge
exceptiongroup            1.2.0              pyhd8ed1ab_2    conda-forge
filelock                  3.13.1             pyhd8ed1ab_0    conda-forge
fmt                       10.2.1               h00ab1b0_0    conda-forge
future                    1.0.0              pyhd8ed1ab_0    conda-forge
icu                       73.2                 h59595ed_0    conda-forge
idna                      3.6                pyhd8ed1ab_0    conda-forge
importlib_resources       6.3.2              pyhd8ed1ab_0    conda-forge
jinja2                    3.1.3              pyhd8ed1ab_0    conda-forge
joblib                    1.3.2              pyhd8ed1ab_0    conda-forge
json5                     0.9.24             pyhd8ed1ab_0    conda-forge
jsonpatch                 1.33               pyhd8ed1ab_0    conda-forge
jsonpointer               2.4             py311h38be061_3    conda-forge
jsonschema                4.21.1             pyhd8ed1ab_0    conda-forge
jsonschema-specifications 2023.12.1          pyhd8ed1ab_0    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
krb5                      1.21.2               h659d440_0    conda-forge
ld_impl_linux-64          2.40                 h41732ed_0    conda-forge
libarchive                3.7.2                h2aa1ff5_1    conda-forge
libcurl                   8.6.0                hca28451_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libev                     4.33                 hd590300_2    conda-forge
libexpat                  2.6.2                h59595ed_0    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 13.2.0               h807b86a_5    conda-forge
libgomp                   13.2.0               h807b86a_5    conda-forge
libiconv                  1.17                 hd590300_2    conda-forge
liblief                   0.12.3               h27087fc_0    conda-forge
libmamba                  1.5.7                had39da4_0    conda-forge
libmambapy                1.5.7           py311hf2555c7_0    conda-forge
libnghttp2                1.58.0               h47da74e_1    conda-forge
libnsl                    2.0.1                hd590300_0    conda-forge
libsolv                   0.7.28               hfc55251_0    conda-forge
libsqlite                 3.45.2               h2797004_0    conda-forge
libssh2                   1.11.0               h0841786_0    conda-forge
libstdcxx-ng              13.2.0               h7e041cc_5    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libxcrypt                 4.4.36               hd590300_1    conda-forge
libxml2                   2.12.6               h232c23b_0    conda-forge
libzlib                   1.2.13               hd590300_5    conda-forge
lz4-c                     1.9.4                hcb278e6_0    conda-forge
lzo                       2.10              h516909a_1000    conda-forge
mamba                     1.5.7           py311h3072747_0    conda-forge
markdown-it-py            3.0.0              pyhd8ed1ab_0    conda-forge
markupsafe                2.1.5           py311h459d7ec_0    conda-forge
mdurl                     0.1.2              pyhd8ed1ab_0    conda-forge
menuinst                  2.0.2           py311h38be061_0    conda-forge
more-itertools            10.2.0             pyhd8ed1ab_0    conda-forge
ncurses                   6.4.20240210         h59595ed_0    conda-forge
openssl                   3.2.1                hd590300_1    conda-forge
packaging                 24.0               pyhd8ed1ab_0    conda-forge
patch                     2.7.6             h7f98852_1002    conda-forge
patchelf                  0.17.2               h58526e2_0    conda-forge
pip                       24.0               pyhd8ed1ab_0    conda-forge
pkginfo                   1.10.0             pyhd8ed1ab_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_1    conda-forge
platformdirs              4.2.0              pyhd8ed1ab_0    conda-forge
pluggy                    1.4.0              pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.42             pyha770c72_0    conda-forge
prompt_toolkit            3.0.42               hd8ed1ab_0    conda-forge
psutil                    5.9.8           py311h459d7ec_0    conda-forge
py-lief                   0.12.3          py311ha362b79_0    conda-forge
pybind11-abi              4                    hd8ed1ab_3    conda-forge
pycosat                   0.6.6           py311h459d7ec_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pygments                  2.17.2             pyhd8ed1ab_0    conda-forge
pyopenssl                 24.0.0             pyhd8ed1ab_0    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.11.6          hab00c5b_0_cpython    conda-forge
python-libarchive-c       5.1             py311h38be061_0    conda-forge
python_abi                3.11                    4_cp311    conda-forge
pytz                      2024.1             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0.1           py311h459d7ec_1    conda-forge
readline                  8.2                  h8228510_1    conda-forge
referencing               0.34.0             pyhd8ed1ab_0    conda-forge
reproc                    14.2.4.post0         hd590300_1    conda-forge
reproc-cpp                14.2.4.post0         h59595ed_1    conda-forge
requests                  2.31.0             pyhd8ed1ab_0    conda-forge
rich                      13.7.1             pyhd8ed1ab_0    conda-forge
ripgrep                   14.1.0               he8a937b_0    conda-forge
rpds-py                   0.18.0          py311h46250e7_0    conda-forge
ruamel.yaml               0.18.6          py311h459d7ec_0    conda-forge
ruamel.yaml.clib          0.2.8           py311h459d7ec_0    conda-forge
setuptools                69.2.0             pyhd8ed1ab_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sniffio                   1.3.1              pyhd8ed1ab_0    conda-forge
soupsieve                 2.5                pyhd8ed1ab_1    conda-forge
tk                        8.6.13          noxft_h4845f30_101    conda-forge
toolz                     0.12.1             pyhd8ed1ab_0    conda-forge
tqdm                      4.66.2             pyhd8ed1ab_0    conda-forge
truststore                0.8.0              pyhd8ed1ab_0    conda-forge
typing_extensions         4.10.0             pyha770c72_0    conda-forge
tzdata                    2024a                h0c530f3_0    conda-forge
urllib3                   2.2.1              pyhd8ed1ab_0    conda-forge
watchgod                  0.8.2              pyhd8ed1ab_0    conda-forge
wcwidth                   0.2.13             pyhd8ed1ab_0    conda-forge
wheel                     0.42.0             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
yaml                      0.2.5                h7f98852_2    conda-forge
yaml-cpp                  0.8.0                h59595ed_0    conda-forge
zipp                      3.17.0             pyhd8ed1ab_0    conda-forge
zstandard                 0.22.0          py311haa97af0_0    conda-forge
zstd                      1.5.5                hfc55251_0    conda-forge


### Additional Context

I  know that I can add this to the recipe, but currently I don't know if I could test it locally. If it is possible to try this locally I would prefer this.

https://github.com/Open-MSS/MSS/pull/2281/files
- "application/x-menuinst": ["*.menuinst"]
+ "application/x-menuinst": "*.menuinst"

I think this is the change you need. Maybe this should be a list in general, but for your use case this should work with the current schema.

Now it shows ['platforms']['properties']['**osx**'], but I am still on linux. I would expect it ignores that section.

Packaging mss-alpha-py311_1000
number of files: 8
Validating Menu/*.json files
WARNING: 'Menu/mss_menu.json' is not a valid menuinst JSON document!
Traceback (most recent call last):
  File "/home/user/Miniforge/lib/python3.11/site-packages/conda_build/post.py", line 1776, in check_menuinst_json
    validator.validate(json.loads(text))
  File "/home/user/Miniforge/lib/python3.11/site-packages/jsonschema/validators.py", line 438, in validate
    raise error
jsonschema.exceptions.ValidationError: [{'public.filename-extension': ['menuinst']}] is not of type 'object'

Failed validating 'type' in schema['properties']['menu_items']['items']['properties']['platforms']['properties']['osx']['properties']['UTExportedTypeDeclarations']['items']['properties']['UTTypeTagSpecification']:
    {'additionalProperties': {'items': {'type': 'string'}, 'type': 'array'},
     'title': 'Uttypetagspecification',
     'type': 'object'}

On instance['menu_items'][0]['platforms']['osx']['UTExportedTypeDeclarations'][0]['UTTypeTagSpecification']:
    [{'public.filename-extension': ['menuinst']}]
Fixing permissions
Packaged license file/s.
INFO :: Time taken to mark (prefix)

when I remove the osx and windows section also the failure is gone

 Packaging mss
Packaging mss-alpha-py311_1000
number of files: 8
Validating Menu/*.json files
'Menu/mss_menu.json' is a valid menuinst JSON document
Fixing permissions
Packaged license file/s.

Removing all other OS's it builds now.

{
  "$schema": "https://json-schema.org/draft-07/schema",
  "$id": "https://schemas.conda.io/menuinst-1.schema.json",
  "menu_name": "Mission Support System",
  "menu_items": [
    {
      "name": "MSUI",
      "description": "Mission Support System UI",
      "activate": true,
      "icon": "{{ MENU_DIR }}/msui.{{ ICON_EXT }}",
      "command": ["{{ PREFIX }}/bin/msui.py"],
      "platforms": {
        "linux": {
          "Categories": ["Science", "Education"],
          "Keywords": ["documentation", "information"],
          "StartupNotify": true,
          "MimeType": ["application/x-menuinst"],
          "glob_patterns": {
            "application/x-menuinst": "*.menuinst"
          }
        }
      }
    }
  ]
}

The validation happens for the whole JSON document. You can have a single JSON for all OSs in your noarch package, or if you prefer it this way, have a per-arch package with a dedicated JSON.

              "UTTypeTagSpecification": [
                {
                  "public.filename-extension": ["menuinst"]
                }

should be a plain dict:

              "UTTypeTagSpecification": {
                  "public.filename-extension": ["menuinst"]
              }

I realized now the docs are out of date. Source of truth for now should be this test file. I'll update the docs. Sorry for the trouble!

#190 should point to the right examples now.

this helped, thx.

#190 is merged, so closing here. Thanks for the report!