stack install elm-export fails - elm

I would like to install elm-export package using stack. It needs to be imported in a servant-elm example.
It's like:
shell> stack install elm-export
shell>
No error message. So I thought it's installed.
But when I stack build,
Error message shows:
test-0.1.0.0: build (exe)
Preprocessing executable 'test' for test-0.1.0.0..
Building executable 'test' for test-0.1.0.0..
[1 of 1] Compiling Main ( src\Main.hs, .stack-
work\dist\5c8418a7\build\test\test-tmp\Main.o )
C:\Code\Haskell\11_Stack-Projects-That-Need-Dependency\test\src\Main.hs:6:1:
error:
Could not find module ▒▒Elm▒▒
Use -v to see a list of the files searched for.
|
6 | import Elm (Spec (Spec), specsToDir, toElmDecoderSource,
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
My question is, Where can I check if the package is installed? And how do I fix this?
ps. Cabal successfully installed elm-export and servant-export and runghc successfully run example code. Now I am trying to use stack to install package to prevent from ruining some dependency.

If you want to use this library in a haskell stack package you don't need to run stack install. Instead you need to add it to your project dependencies.
See the HaskellStack User Guide (adding dependencies)
Depending on the version of stack you have this might be in one of two places I think:
if you have a packages.yaml, add it in the section 'dependencies'
dependencies:
- base >= 4.7 && < 5
- elm-export >= 0.6 && < 1.0
if you don't have packages.yaml, add it to you cabal file directly
library
hs-source-dirs:
src
build-depends:
base >=4.7 && <5
, elm-export >= 0.6 && < 1.0
FYI: stack install is used to install executables which you can then use on the command line. It can be used inside or outside of haskell stack projects.
I don't think elm-export declares any executables, which is why it didn't output anything. Some examples are pandoc, hindent, etc. These are haskell libraries which also provides executables that you can install using stack.
$ stack install pandoc
...
Copied executables to /Users/<me>/.local/bin:
- pandoc
$ pandoc --help
pandoc [OPTIONS] [FILES]
-f FORMAT, -r FORMAT --from=FORMAT, --read=FORMAT

Related

CMake build fails with Xcode 12 and CMAKE_IOS_INSTALL_COMBINED=YES

EDIT This is a known CMake issue.
With Xcode 11 (specifically Xcode 11.2.1) I used to be able to cross-compile my project for iOS with this command:
cd /path/to/project
mkdir build
cd build
cmake .. -G Xcode -DCMAKE_SYSTEM_NAME=iOS \
"-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" \
-DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=NO \
-DCMAKE_IOS_INSTALL_COMBINED=YES \
-DCMAKE_INSTALL_PREFIX=install
cmake --build . --config Release --target install
This created a build with two slices, one slice for the arm64 architecture (for running on a real device) and one slice for the x86_64 architecture (for running in a simulator on an Intel-based dev environment).
After upgrading to Xcode 12 (specifically Xcode 12.3) this no longer works. The build consistently fails with this error message (line break added by me):
error: unable to attach DB: error: accessing build database "/path/to/project/build/ios/build/XCBuildData/build.db":
database is locked Possibly there are two concurrent builds running in the same filesystem location.
The issue seems to be a post-build rule that CMake creates for the install target. In that post-build rule a second build is initiated while the first one is still in progress.
if test "$CONFIGURATION" = "Release"; then :
cd /path/to/project/build/ios
/usr/local/Cellar/cmake/3.19.2/bin/cmake -DBUILD_TYPE=$CONFIGURATION -DEFFECTIVE_PLATFORM_NAME=$EFFECTIVE_PLATFORM_NAME -P cmake_install.cmake
fi
The build succeeds when I no longer set CMAKE_IOS_INSTALL_COMBINED to YES, but then the resulting build only contains one slice (arm64 in my case, presumably because this is the first architecture that is listed in CMAKE_OSX_ARCHITECTURES).
I'm considering making a separate build for each architecture, and then stitching the slices together manually. Before I go down that road, has anyone been able to find a more elegant solution?
Environment: macOS 11.1, Xcode 12.3, CMake 3.19.2
The CMake 3.19 release notes contain this hint:
The Xcode generator now uses the Xcode “new build system” when generating for Xcode 12.0 or higher. See the CMAKE_XCODE_BUILD_SYSTEM variable. One may use -T buildsystem=1 to switch to the legacy build system.
The workaround, for the moment, is therefore to add the -T option to the build system generation command line:
cmake .. -G Xcode -T buildsystem=1
-DCMAKE_SYSTEM_NAME=iOS \
"-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" \
-DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=NO \
-DCMAKE_IOS_INSTALL_COMBINED=YES \
-DCMAKE_INSTALL_PREFIX=install
This should work as long as Xcode still supports the legacy build system. The Xcode 12 Release Notes have this to say on the matter:
The legacy build system is deprecated, and will be removed in a future release. (62742902)
So the -T buildsystem=1 option can only be considered a temporary workaround.

libwebsockets (on ubuntu) - trying compile example "lws minimal ws server + permessage-deflate echo" - can't find libwebsocketsConfig.cmake

I am an (absolute) beginner with libwebsockets (and cmake), and am trying to build one of the minimal examples from libwebsockets.org:
"lws minimal ws server + permessage-deflate echo"
at
https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/ws-server/minimal-ws-server-echo
I have installed libwebsockets-dev (sudo apt install libwebsockets-dev) and cmake (sudo apt install cmake).
The example page tells me to build the example (two .c files and CMakeLists.txt) using
$ cmake . && make
The build fails with the following message:
CMake Error at CMakeLists.txt:3 (find_package):
Could not find a package configuration file provided by "libwebsockets"
with any of the following names:
libwebsocketsConfig.cmake
libwebsockets-config.cmake
Add the installation prefix of "libwebsockets" to CMAKE_PREFIX_PATH or set
"libwebsockets_DIR" to a directory containing one of the above files. If
"libwebsockets" provides a separate development package or SDK, be sure it
has been installed.
-- Configuring incomplete, errors occurred!
See also "/home/user/ws/CMakeFiles/CMakeOutput.log".
I cannot find either of the .cmake files in my system (they are evidently not provided as part of package libwebsockets-dev.)
What am I missing?
Thank you!
Thank you, Tsyvarev, you are correct.
The solution was to build libwebsockets from github repository, use that instead of libwebsocket-dev installed from ubuntu 18.04.

pkg_config_modules dependency fails because version in "Uncontrolled"

The Problem
I've got a CMakeLists.txt file with this content:
pkg_check_modules(FOO REQUIRED foo>=0.1.0.1)
When I run Cmake v3.17.2 with cmake3 -G Ninja . in that directory:
Checking for module 'foo>=0.1.0.1'
Requested 'foo >= 0.1.0.1' but version of foo is Uncontrolled
Details
This is running inside RHEL7
yum info foo | grep Version returns Version : 0.1.0.1.20200417git602d018
The foo module is created by the team I'm on
The Question
How can I tell CMake what version my foo library is so that it isn't "Uncontrolled"?
In the output of the foo project, inside of the generated lib64 directory, there's a pkgconfig directory which contains foo.pc.
Inside of that file, version info is as follows:
Version: HEAD
Change this to be the intended version. In my case this was automated by the build process of foo, so what was required was to add a git tag for the current version and rebuild.

"Requires" entry in .spec file does not work

I was writing an .spec file for a rpm package and I'm having an issue.
I need to install that package with a specific version of another package.
Let's take a python package example. So, I write it:
Requires : bash, grep, python >= 2.6.7-4b
But, the package is installed even if the python package is in the 2.6.6 version.
If I remove python package, the system shows me that my package needs python 2.6.7.
Is there something wrong?
Output from rpm -q --provides python:
Distutils
python(abi) = 2.6
python-abi = 2.6
python-ctypes = 1.0.1
python-hashlib = 20081120
python-sqlite = 2.3.2
python-uuid = 1.31
python-x86_64 = 2.6.6-52.el6
python2 = 2.6.6
python = 2.6.6-52.el6
python(x86-64) = 2.6.6-52.el6
Output from rpm -qpR $yourpackage.rpm:
/bin/sh
python >= 2.6.7-4b
bash
grep
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1
The ''Requires:'' tag is ignored unless you add ''Autoreq: no'' as well.
Newer versions of rpmbuild calculate the requirements automatically and ignore ''Requires:'' unless the feature is turned off.
I have run into this issue multiple times and it is worth noting that you should at first run rpmbuild without ''Autoreq: no'', note the autodetected dependencies, and add them to the ''Required:'' tag before the final run with ''Autoreq: no''.
Is also worth noting that the automatic detection of dependencies is a little buggy and has some issues with comments.
I packaged a perl script with a comment containing " ... then use a module ... " a while ago.
Autoreq detected that as being perl module "perl a" and added it to the dependencies making my rpm useless.

Problems adding DKMS support to kernel module

I'm trying to add DKMS support in a kernel module i'm working on.
I have placed the kernel module source with a static lib to be linked against in the following directory:
/usr/src/dpx/1.0
With the following files:
dkms.conf
Makefile
dpxmtt.c
lib.a
dkms.conf file is like this:
MAKE="make"
CLEAN="make clean"
BUILT_MODULE_NAME=dpx
BUILT_MODULE_LOCATION=src/
DEST_MODULE_LOCATION=/kernel/drivers/input/touchscreen
PACKAGE_NAME=dpxm
PACKAGE_VERSION=1.0
REMAKE_INITRD=yes
And the makefile is like this:
EXTRA_CFLAGS+=-DLINUX_DRIVER -mhard-float
obj-m += dpx.o
dpx-objs:= dpxmtt.o ../source/lib.a
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
The ../source/lib.a is an hack since when the makefile is invoked by the dkms building system it was saying that it couldn't be found in directory (the build directory), but since it was being copied to the source directory, i'm referencing it relatively.
When I call
sudo dkms build -m dpx -v 1.0
The result is almost perfect:
santos#NS-PC:~$ sudo dkms build -m dpx -v 1.0
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area....
make KERNELRELEASE=3.0.0-14-generic....
ERROR (dkms apport): binary package for dpx: 1.0 not found
Error! Build of dpx.ko failed for: 3.0.0-14-generic (i686)
Consult the make.log in the build directory
/var/lib/dkms/dpx/1.0/build/ for more information.
nsantos#NS-PC:~$
And the content of the log file is:
DKMS make.log for dpx-1.0 for kernel 3.0.0-14-generic (i686)
Thu Jan 19 11:07:54 WET 2012
make -C /lib/modules/3.0.0-14-generic/build M=/var/lib/dkms/dpx/1.0/build modules
make[1]: Entering directory `/usr/src/linux-headers-3.0.0-14-generic'
CC [M] /var/lib/dkms/dpx/1.0/build/dpxmtt.o
LD [M] /var/lib/dkms/dpx/1.0/build/dpx.o
Building modules, stage 2.
MODPOST 1 modules
CC /var/lib/dkms/dpx/1.0/build/dpx.mod.o
LD [M] /var/lib/dkms/dpx/1.0/build/dpx.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.0.0-14-generic'
The module was built correctly but it ends with the error:
ERROR (dkms apport): binary package for dpx: 1.0 not found
Error! Build of dpx.ko failed for: 3.0.0-14-generic (i686)
And I don't know what it means. Does anybody know?
Using:
$(shell uname -r)
in the Makefile it might be also wrong! The "shell uname -r" refers to the currently running kernel, but the main reason to use the dkms it's because it offers an automated method to recompile the kernel modules that reside outside of the kernel tree for every newly installed kernel. What i mean is that the Makefile might refers to a different kernel which the dkms is building the module for.
Use:
${kernelver} instead.
I had a similar problem. I think your BUILT_MODULE_LOCATION is set incorrectly to the src directory. It should be set in your example to the current directory, or you can just omit this variable and dkms would default to the current directory.