Repository: spack/spack

Issue:
Installation issue: mxnet
### Steps to reproduce the issue

```console
$ spack spec -I
Input spec
--------------------------------
 -   mxnet+mkldnn cuda_arch=61   # without  +mkldnn the problem remains

Concretized
--------------------------------
 -   mxnet@1.9.1%gcc@10.2.1+cuda+cudnn~ipo+lapack+mkldnn~nccl+opencv~openmp+python build_system=cmake build_type=Distribution cuda_arch=61 generator=ninja patches=7aa526f arch=linux-debian11-skylake
[+]      ^cmake@3.26.3%gcc@10.2.1~doc+ncurses+ownlibs~qt build_system=generic build_type=Release arch=linux-debian11-skylake
[+]          ^ncurses@6.4%gcc@10.2.1~symlinks+termlib abi=none build_system=autotools arch=linux-debian11-skylake
[+]          ^openssl@1.1.1t%gcc@10.2.1~docs~shared build_system=generic certs=mozilla arch=linux-debian11-skylake
[+]              ^ca-certificates-mozilla@2023-01-10%gcc@10.2.1 build_system=generic arch=linux-debian11-skylake
[+]      ^cuda@11.8.0%gcc@10.2.1~allow-unsupported-compilers~dev build_system=generic arch=linux-debian11-skylake
[+]          ^libxml2@2.10.3%gcc@10.2.1~python build_system=autotools arch=linux-debian11-skylake
[+]              ^libiconv@1.17%gcc@10.2.1 build_system=autotools libs=shared,static arch=linux-debian11-skylake
[+]      ^cudnn@8.7.0.84-11.8%gcc@10.2.1 build_system=generic arch=linux-debian11-skylake
[+]      ^ninja@1.11.1%gcc@10.2.1+re2c build_system=generic arch=linux-debian11-skylake
[+]          ^re2c@2.2%gcc@10.2.1 build_system=generic arch=linux-debian11-skylake
[+]      ^onednn@3.0%gcc@10.2.1~ipo build_system=cmake build_type=Release cpu_runtime=omp generator=make gpu_runtime=none arch=linux-debian11-skylake
[+]          ^gmake@4.4.1%gcc@10.2.1~guile build_system=autotools arch=linux-debian11-skylake
[+]      ^openblas@0.3.23%gcc@10.2.1~bignuma~consistent_fpcsr+fortran~ilp64+locking+pic+shared build_system=makefile symbol_suffix=none threads=none arch=linux-debian11-skylake
[+]          ^perl@5.36.0%gcc@10.2.1+cpanm+open+shared+threads build_system=generic arch=linux-debian11-skylake
[+]              ^berkeley-db@18.1.40%gcc@10.2.1+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=linux-debian11-skylake
[+]      ^opencv@4.6.0%gcc@10.2.1~1394~ade~alphamat~android_mediandk~android_native_camera~annotation~aruco~avfoundation~barcode~bgsegm~bioinspired~calib3d~cap_ios~carotene~ccalib~clp+contrib~cpufeatures~createsamples~cublas~cuda~cudaarithm~cudabgsegm~cudacodec~cudafeatures2d~cudafilters~cudaimgproc~cudalegacy~cudaobjdetect~cudaoptflow~cudastereo~cudawarping~cudev~cudnn~cufft~cvv~datasets~directx~dnn~dnn_objdetect~dnn_superres~dpm~dshow~eigen~face~fast-math~features2d~ffmpeg~flann~freetype~fuzzy~gapi~gdal~gtk~hdf~hfs+highgui~hpx~img_hash~imgcodec_hdr~imgcodec_pfm~imgcodec_pxm~imgcodec_sunraster+imgcodecs+imgproc~intensity_transform~interactive-calibration~ipo~ipp~itt~jasper~java~java_bindings_generator~jpeg~lapack~line_descriptor~matlab~mcc~ml~model-diagnostics~msmf~msmf_dxva~nonfree~objc~objc_bindings_generator~objdetect~onnx~opencl~opencl_d3d11_nv~openexr~opengl~openjpeg~openmp~optflow~phase_unwrapping~photo~plaidml~plot~png~powerpc~protobuf~pthreads_pf~python3~python_bindings_generator~python_tests~qt~quality~quirc~rapid~reg~rgbd~saliency~sfm~shape+shared~stereo~stitching~structured_light~superres~surface_matching~tbb~tengine~tesseract~text~tiff~tracking~traincascade~ts~v4l~version~video~videoio~videostab~visualisation~viz~vtk~vulcan~webp~wechat_qrcode~win32ui~world~xfeatures2d~ximgproc~xobjdetect~xphoto build_system=cmake build_type=Release generator=make patches=2aea289,3cab451 arch=linux-debian11-skylake
[+]          ^openjdk@11.0.17_8%gcc@10.2.1 build_system=generic arch=linux-debian11-skylake
[+]          ^zlib@1.2.13%gcc@10.2.1+optimize+pic+shared build_system=makefile arch=linux-debian11-skylake
[+]      ^py-cython@0.29.33%gcc@10.2.1 build_system=python_pip patches=71de066 arch=linux-debian11-skylake
[+]      ^py-graphviz@0.8.4%gcc@10.2.1~dev~docs build_system=python_pip arch=linux-debian11-skylake
[+]      ^py-pip@23.0%gcc@10.2.1 build_system=generic arch=linux-debian11-skylake
[+]      ^py-requests@2.28.2%gcc@10.2.1~socks build_system=python_pip arch=linux-debian11-skylake
[+]          ^py-certifi@2022.12.7%gcc@10.2.1 build_system=python_pip arch=linux-debian11-skylake
[+]          ^py-charset-normalizer@2.0.12%gcc@10.2.1 build_system=python_pip arch=linux-debian11-skylake
[+]          ^py-idna@3.4%gcc@10.2.1 build_system=python_pip arch=linux-debian11-skylake
[+]              ^py-flit-core@3.7.1%gcc@10.2.1 build_system=python_pip arch=linux-debian11-skylake
[+]          ^py-urllib3@1.26.12%gcc@10.2.1~brotli~secure~socks build_system=python_pip arch=linux-debian11-skylake
[+]      ^py-setuptools@67.6.0%gcc@10.2.1 build_system=generic arch=linux-debian11-skylake
[+]      ^py-wheel@0.37.1%gcc@10.2.1 build_system=generic arch=linux-debian11-skylake
[+]      ^python@3.10.10%gcc@10.2.1+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches=0d98e93,7d40923,f2fd060 arch=linux-debian11-skylake
[+]          ^bzip2@1.0.8%gcc@10.2.1~debug~pic+shared build_system=generic arch=linux-debian11-skylake
[+]              ^diffutils@3.9%gcc@10.2.1 build_system=autotools arch=linux-debian11-skylake
[+]          ^expat@2.5.0%gcc@10.2.1+libbsd build_system=autotools arch=linux-debian11-skylake
[+]              ^libbsd@0.11.7%gcc@10.2.1 build_system=autotools arch=linux-debian11-skylake
[+]                  ^libmd@1.0.4%gcc@10.2.1 build_system=autotools arch=linux-debian11-skylake
[+]          ^gdbm@1.23%gcc@10.2.1 build_system=autotools arch=linux-debian11-skylake
[+]          ^gettext@0.21.1%gcc@10.2.1+bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=linux-debian11-skylake
[+]              ^tar@1.34%gcc@10.2.1 build_system=autotools zip=pigz arch=linux-debian11-skylake
[+]                  ^pigz@2.7%gcc@10.2.1 build_system=makefile arch=linux-debian11-skylake
[+]                  ^zstd@1.5.5%gcc@10.2.1+programs build_system=makefile compression=none libs=shared,static arch=linux-debian11-skylake
[+]          ^libffi@3.4.4%gcc@10.2.1 build_system=autotools arch=linux-debian11-skylake
[+]          ^libxcrypt@4.4.33%gcc@10.2.1~obsolete_api build_system=autotools arch=linux-debian11-skylake
[+]          ^pkgconf@1.9.5%gcc@10.2.1 build_system=autotools arch=linux-debian11-skylake
[+]          ^readline@8.2%gcc@10.2.1 build_system=autotools patches=bbf97f1 arch=linux-debian11-skylake
[+]          ^sqlite@3.40.1%gcc@10.2.1+column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=linux-debian11-skylake
[+]          ^util-linux-uuid@2.38.1%gcc@10.2.1 build_system=autotools arch=linux-debian11-skylake
[+]          ^xz@5.4.1%gcc@10.2.1~pic build_system=autotools libs=shared,static arch=linux-debian11-skylake
$ spack install
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/ncurses-6.4-blnczisxu5paitvs57ub4xy2esu4ka7d
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/zlib-1.2.13-7e652p74b4tnhfpcnxvm6nac2qngxmj3
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/libiconv-1.17-2vrwebfgg6t3qvesn23agtl5at3r72kr
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/xz-5.4.1-rmpp24qgmsjmnkaehos3pjmp2by4yj7k
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/ninja-1.11.1-blxucxl5caj6s5gclz6uelvu5axayemp
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/onednn-3.0-3nebrep5opg6nf55dlk5xenxjsfud4ge
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/openblas-0.3.23-zsfv4zzslm5rpb7bsbogawhon4n6qryi
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/bzip2-1.0.8-o3mt2e7vvpwvjtbkw2ogz2aydwek44cm
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/libmd-1.0.4-rosz5s2gvsjyhcrjpsbpbpfz6fpl3soe
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/zstd-1.5.5-khq5q7uwe6fc7vmzqyyt7nbvsnepqzpn
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/libffi-3.4.4-cuyzflvj7vdncr34ee3nfo7sblnliohr
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/libxcrypt-4.4.33-22hmxjduuwh53zs6qxbsqrghohypm7pb
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/util-linux-uuid-2.38.1-p34ziwyhebxkcapyao5wezvtvnse6kmc
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/readline-8.2-fbha3v4r6wrnr5fhtolpb74hiirs4en5
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/openssl-1.1.1t-hhnyjs7qzvqwcvxv77e6dkegtvkrtxf2
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/opencv-4.6.0-nietoa3sthcsrmbhpq7ovph2peexwrdr
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/pigz-2.7-www45yfdokwr3a7hhkmfsxh3m4nyyqnl
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/libxml2-2.10.3-aa2kats5i37sxqbdnfrwg4zuu6q7gyky
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/libbsd-0.11.7-gsxl67v6lz2bqiid55d647nlqs35jllh
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/sqlite-3.40.1-lr7224ra7fauczipvqwqmlb3ujl7qixr
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/gdbm-1.23-33oqrh3i73sulyktcsttvxmbhzfp6oji
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/cmake-3.26.3-fniiauoadhlij5xertcb6lglv7rvogwy
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/tar-1.34-m2o64tm73c6is4td3vlykxmt5m2d4esw
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/cuda-11.8.0-nvwfwavfwwjvwdwnkmp7ql5xtewxz6mg
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/expat-2.5.0-px7kkiiuwiconkygvo5ybby6ix65cil6
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/gettext-0.21.1-bkcdemusppewgv2a4eyzicyiui3kp542
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/cudnn-8.7.0.84-11.8-nv3r5pczxmmhrt4743jn42ygegicx7ty
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/python-3.10.10-3d53t5osjb76vmwsz3xrz52t7lbxkkxg
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/py-wheel-0.37.1-xuhgjwjwct36s75aejxi3ezk46cdropy
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/py-setuptools-67.6.0-bgx62jys4wr4xls2paceqmvopjgfhqhv
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/py-pip-23.0-cb5gftjto76fatxeh4nlr7l6g4amt25d
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/py-charset-normalizer-2.0.12-albkwwdvuxcwhz4ghsfzdx6rxcubqqym
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/py-urllib3-1.26.12-22lxcxh3xxxut7hxlfibxhnr32iqxo4u
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/py-graphviz-0.8.4-rwzr5fwd2drtss67rufsl4tjlqw6rju2
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/py-cython-0.29.33-nssajevyzsmfognzwbokardvlsa2rehj
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/py-certifi-2022.12.7-732t4uj5psv7teydou4aw2kr7hs3kzae
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/py-idna-3.4-k4bg3mkah7xjssqgwi4gvebjwohmvmcf
[+] /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/py-requests-2.28.2-tuaxnt6w2od77ynus7kbnzawynhj7zjm
==> Installing mxnet-1.9.1-lqyfxxajmrpmkroob3qiprim4wbtxoft
==> No binary for mxnet-1.9.1-lqyfxxajmrpmkroob3qiprim4wbtxoft found: installing from source
==> Using cached archive: /home/alexandersn/PROG/spack/var/spack/cache/_source-cache/archive/11/11ea61328174d8c29b96f341977e03deb0bf4b0c37ace658f93e38d9eb8c9322.tar.gz
==> Applied patch /home/alexandersn/PROG/spack/var/spack/repos/builtin/packages/mxnet/openblas-1.7.0.patch
==> mxnet: Executing phase: 'cmake'
==> mxnet: Executing phase: 'build'
==> mxnet: Executing phase: 'install'
==> Error: ProcessError: Command exited with status 1:
    '/home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/ninja-1.11.1-blxucxl5caj6s5gclz6uelvu5axayemp/bin/ninja' '-j12' 'install'

2 errors found in build log:
     58412    -- Installing: /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/mxnet-1.9.1-lqyfxxajmrpmkroob3qiprim4wbtxoft/include/nnvm/symbolic.h
     58413    -- Installing: /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/mxnet-1.9.1-lqyfxxajmrpmkroob3qiprim4wbtxoft/include/nnvm/node.h
     58414    -- Installing: /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/mxnet-1.9.1-lqyfxxajmrpmkroob3qiprim4wbtxoft/include/nnvm/op.h
     58415    -- Installing: /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/mxnet-1.9.1-lqyfxxajmrpmkroob3qiprim4wbtxoft/include/nnvm/pass.h
     58416    -- Installing: /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/mxnet-1.9.1-lqyfxxajmrpmkroob3qiprim4wbtxoft/include/nnvm/graph.h
     58417    -- Installing: /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/mxnet-1.9.1-lqyfxxajmrpmkroob3qiprim4wbtxoft/lib/libdnnl.a
  >> 58418    CMake Error at 3rdparty/mkldnn/src/cmake_install.cmake:68 (file):
     58419      file cannot create directory: /mkldnn.  Maybe need administrative
     58420      privileges.
     58421    Call Stack (most recent call first):
     58422      3rdparty/mkldnn/cmake_install.cmake:47 (include)
     58423      cmake_install.cmake:80 (include)
     58424    
     58425    
  >> 58426    FAILED: CMakeFiles/install.util
     58427    cd /tmp/alexandersn/spack-stage/spack-stage-mxnet-1.9.1-lqyfxxajmrpmkroob3qiprim4wbtxoft/spack-src/build && /home/alexandersn/PROG/spack/opt/spack/linux-debian11-skylake/gcc-10.2.1/cmake-3.26.3-fniiauoadhlij5xertcb6lglv7rvogwy/bin/cmake -P cmake_install.cmake
     58428    ninja: build stopped: subcommand failed.

See build log for details:
  /tmp/alexandersn/spack-stage/spack-stage-mxnet-1.9.1-lqyfxxajmrpmkroob3qiprim4wbtxoft/spack-build-out.txt

...
```


### Error message

<details><summary>CMake Error at 3rdparty/mkldnn/src/cmake_install.cmake:68 (file):
     58419      file cannot create directory: /mkldnn</summary>

<pre>
/tmp/alexandersn/spack-stage/spack-stage-mxnet-1.9.1-lqyfxxajmrpmkroob3qiprim4wbtxoft/spack-src/build/3rdparty/mkldnn/src/cmake_install.cmake content:
</pre></details>
[cmake_install.cmake.txt](https://github.com/spack/spack/files/11706204/cmake_install.cmake.txt)


### Information on your system

* **Spack:** 0.21.0.dev0 (ac0903ef9f57b0bda1f483fa991bada882d97a1d)
* **Python:** 3.9.2
* **Platform:** linux-debian11-skylake
* **Concretizer:** clingo

### Additional information

[spack-build-env.txt](https://github.com/spack/spack/files/11706229/spack-build-env.txt)
[spack-build-out.txt](https://github.com/spack/spack/files/11706230/spack-build-out.txt)

@adamjstewart 
@pradyunsg 

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [x] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
without  +mkldnn the problem remains
conditionally solved the problem:

$spack edit mxnet

adding the line: "args.append(self.define_from_variant("USE_MKLDNN", "mkldnn"))"
after line "elif self.spec.satisfies("@1.9:"):"
I'd be fine with this change. Want to open a PR?
thanks, but I don't think it's justified since I'm a noob



Resolving patch:
diff --git a/var/spack/repos/builtin/packages/mxnet/package.py b/var/spack/repos/builtin/packages/mxnet/package.py
--- a/var/spack/repos/builtin/packages/mxnet/package.py
+++ b/var/spack/repos/builtin/packages/mxnet/package.py
@@ -92,9 +92,9 @@ def cmake_args(self):
             self.define("BLAS_LIBRARIES", self.spec["blas"].libs[0]),
         ]
 
-        if self.spec.satisfies("@:1.8"):
+        if self.spec.satisfies("@:1"):
             args.append(self.define_from_variant("USE_MKLDNN", "mkldnn"))
-        elif self.spec.satisfies("@1.9:"):
+        elif self.spec.satisfies("@2:"):
             args.append(self.define_from_variant("USE_ONEDNN", "mkldnn"))
             args.append(self.define("USE_CUTENSOR", False))
 


Test patch: