Installing sqlite driver in Haskell using stack - sqlite

I have sqlite3 installed in Ubuntu.
$ which sqlite3
/home/user/anaconda3/bin/sqlite3
I'm trying to install the sqlite driver in Haskell and see the following error:
$ stack install sqlite
sqlite-0.5.5: configure
sqlite-0.5.5: build
-- While building custom Setup.hs for package sqlite-0.5.5 using:
/tmp/stack16820/sqlite-0.5.5/.stack-work/dist/x86_64-linux/Cabal-2.2.0.1/setup/setup --builddir=.stack-work/dist/x86_64-linux/Cabal-2.2.0.1 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Logs have been written to: /home/user/.stack/global-project/.stack-work/logs/sqlite-0.5.5.log
[1 of 2] Compiling Main ( /tmp/stack16820/sqlite-0.5.5/Setup.hs, /tmp/stack16820/sqlite-0.5.5/.stack-work/dist/x86_64-linux/Cabal-2.2.0.1/setup/Main.o )
[2 of 2] Compiling StackSetupShim ( /home/user/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /tmp/stack16820/sqlite-0.5.5/.stack-work/dist/x86_64-linux/Cabal-2.2.0.1/setup/StackSetupShim.o )
Linking /tmp/stack16820/sqlite-0.5.5/.stack-work/dist/x86_64-linux/Cabal-2.2.0.1/setup/setup ...
Configuring sqlite-0.5.5...
Preprocessing library for sqlite-0.5.5..
Building library for sqlite-0.5.5..
[1 of 5] Compiling Database.SQL.Types ( Database/SQL/Types.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Database/SQL/Types.o )
/tmp/stack16820/sqlite-0.5.5/Database/SQL/Types.hs:481:37: error:
Ambiguous occurrence ‘<>’
It could refer to either ‘Prelude.<>’,
imported from ‘Prelude’ at Database/SQL/Types.hs:15:8-25
(and originally defined in ‘GHC.Base’)
or ‘Text.PrettyPrint.HughesPJ.<>’,
imported from ‘Text.PrettyPrint.HughesPJ’ at Database/SQL/Types.hs:56:1-32
|
481 | FunSQLExpr f es -> text f <> parens (commaH ppSQLExpr es)
| ^^
Which of ghc, stack, cabal, anaconda, sqlite should I interrogate to figure out what is failing?

I'm trying to install the sqlite driver in Haskell and see the following error
The sqlite package is deprecated in favour of sqlite-simple So, I would recommend you to not use this. If you are looking for a much higher level of interface to sqlite, I would recommend persistent library.
If you want to still make it work, the easiest way is to just fix the compile errors by forking the code and make it work with the required GHC version.

TL;DR
stack install sqlite --resolver=lts-11.22 should work
First of all i would follow sibi advise and install the maintaned package sqlite-simple.
But if you want to use the deprecated one we could analyze the error:
The error is thrown in the haskell part, the combination of stack and haskell. No mention about c code so the sqlite lib (or anaconda) is not involved here
Ambiguous occurrence ‘<>’ It could refer to either ‘Prelude.<>’, or ‘Text.PrettyPrint.HughesPJ.<>’: The simbol <> is defined in two modules and the client code doesn't disambiguate them (surely cause it was only in one module at the time)
So we have to compile with a version of Prelude or Text.PrettyPrint.HughesPJ without the definition of <>
Text.PrettyPrint.HughesPJ is a module from the pretty package and all versions of the package have the operator exported
The Prelude is defined in the base library and it is fixed for each version of ghc, that in turn is fixed for each major version of the stackage resolver. You can set the global stack resolver in ~/stack/global-project/stack.yaml or in each call to stack with the option --resolver=
The package sqlite accepts base versions in the range >=3 && <5 (in fact that is the cause of the problem, it is too flexible)
If we search for <> in the changelog of base we can see it was exported since version 4.11.0. And that version was shipped with ghc-8.4.1 (you can see the matrix between versions here). So we have to choose a stackage resolver linked to a previous version of ghc: f.e. lts-11.22 with ghc-8.2.2

Related

Julia - how to update WinRPM in julia version 0.6.4

I'm new to Julia and I want to use COBRA Package.
For adding COBRA I use command :
Pkg.add("COBRA")
But when running, I get these errors:
INFO: Building WinRPM
WARNING: skipping repodata/repomd.xml, not in cache -- call WinRPM.update() to download
WARNING: skipping repodata/repomd.xml, not in cache -- call WinRPM.update() to download
INFO: Downloading https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Leap_42.2/repodata/repomd.xml
WARNING: Unknown download failure, error code: 2148270086
WARNING: Retry 1/5 downloading: https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Leap_42.2/repodata/repomd.xml
until:
WARNING: Unknown download failure, error code: 2148270086
WARNING: Retry 5/5 downloading: https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Leap_42.2/repodata/repomd.xml
WARNING: received error 0 while downloading
https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Leap_42.2/repodata/repomd.xml
After these errors, I have checked the link and I've found out the source is not there, anymore.
So then I ran this command as said above:
WinRPM.update()
But it has thrown this error:
ERROR: UndefVarError: WinRPM not defined
Please Help me to add COBRA to Julia. I'm using version 0.6.4 because Cobra does not work on the next versions.(Windows 10)
Any help would be appreciated.
The problem, as you've mentioned, is that the original sources used by the package aren't valid URLs anymore. The proper way to solve this is to open a pull request with the package to change the URLs (which I've now done here ). As a stopgap measure, here's a hacky way to work around this issue for now:
Do a Pkg.add("WinRPM"). This might trigger the same warnings as above, ignore these.
Next, using WinRPM to load the package we added
Now, the source URLs are read from the sources.list file (linked above) into a global WinRPM.sources variable. We're going to edit this variable's contents to point to new working URLs. (This is generally a terrible idea, to directly poke into the internals of a module and change things.)
julia> WinRPM.sources[:] = replace.(WinRPM.sources, "Leap_42.3" => "Leap_15.3")
2-element Vector{String}:
"https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Leap_15.3"
"https://cache.julialang.org/http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_Leap_15.3"
A WinRPM.update() should now work, and download things into a local cache.
I'm using version 0.6.4 because Cobra does not work on the next versions.
I hope you mean Julia 1.6.4 here, or version 0.6.4 of something else in the stack. If you mean Julia version 0.6.4, you might face further problems down the road and find it hard to get support for such an old version.

How to solve ModuleNotFoundError: No module named 'stanfordnlp' in R

While executing cnlp_download_corenlp() command in R, I get the following error..
Error in py_module_import(module, convert = convert) : ModuleNotFoundError: No module named 'stanfordnlp'
From the cleanNLP documentation :
There are four backends currently available, each with their own pros and cons. They are:
stringi: a fast parser that only requires the stringi package, but produces only tokenized text
udpipe: a parser with no external dependencies that produces tokens, lemmas, part of speech tags, and dependency relationships. The recommended starting point given its balance between ease of use and functionality. It also supports the widest range of natural languages.
spacy: based on the Python library, a more feature complete parser that included named entity recognition and word embeddings. It does require a working Python installation and some other set-up. Recommended for users who are familiar with Python or plan to make heavy use of the package.
corenlp: another Python library (formally Java) that is an official port of the Java library of the same name.
If you didn't install the corenlp Python library, you could try to switch to stringi or udpipe:
library(stringi)
cnlp_init_stringi(locale="en_GB")
Or
library(udpipe)
cnlp_init_udpipe(model_name="english")

How to check what cpu features can be used in my current system image?

I found on the internet a performance tip for Julia: compile the system image for your architecture.
Besides the fact, that the process gives an error
julia> include(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "build_sysimg.jl"))
julia> build_sysimg()
ERROR: UndefVarError: Libdl not defined
I am wondering, how to check all the supported instruction sets that my current system image is using? (i.e. can it use avx2?)
I use Julia 1.0.0
I don't know that Julia has an out-of-the box function for this, but if you add the CpuId.jl package via ]add CpuId in the REPL, you can call using CpuId; cpufeaturetable(), as stated in their README.md.
(Note - we are in the process of upgrading it to 1.0 - so do file an issue/PR if you run into bugs.)

Missing symbol on libQt5Dbus.so.5?

I have a python application that uses QT5.
I'm generating a binary for this app with pyinstaller (so that all the dependencies are bundled). This app is built from a Centos6.8 docker instance (for compatibility reasons) with a patched-in GLIBC that QT5 needs.
When I run the application it fails with the bundled libQt5Dbus.so.5 not having the symbol dbus_connection_can_send_type:
symbol lookup error: /tmp/_MEIyxSbsB/libQt5DBus.so.5: undefined symbol: dbus_connection_can_send_type
When I do nm -D /path/to/libQt5Dbus.so.5 on the Centos6.8 docker instance doesn't show the symbol I need (dbus_connection_can_send_type).
What can I do to get the symbol in a libQt5Dbus.so.5?
EDIT:
I have found that one of the libQt5Dbus.so.5 library in my system does actually have dbus_connection_can_send_type symbol. I've replaced all libQt5Dbus.so.5 libraries with the one that does have the symbol and I still get the error.
The problem I had was the minimum GLIBC required by QT5 (GLIBC 14) does not define the symbol dbus_connection_can_send_type (among others).
Upgrading it to GLIBC 17 makes it work again.

Programming Arduino with Ada

I am am unable to get avr-elf-windows and WinAVR to work. I have managed to build the example supplied with avr-elf-windows (ATmega2560). But if I try and expand to use another chip or start using the WinAVR supplied packages and projects I keep getting errors I cannot work out.
Method 1:
Modify the ATmega2560 example to use the WinAVR packages.
Changed:
with Atmega2560; use Atmega2560;
to:
with AVR; use AVR;
with AVR.Atmega328p; use AVR.atmega328p;
Create a project file to include:
with "C:\WinAVR-20100110\lib\gnat\avr.gpr";
with "C:\WinAVR-20100110\lib\gnat\avr_app.gpr";
Running make I get the following error:
avr-gnatmake: "C:\WinAVR-20100110\lib\gnat\avr_lib\avr-int_img.adb" compilation error
Great, I have a compilation issue, but I cannot see the error.
Method 2:
Open the above project file in GPS. Change the build setting to be gnatmake. GPS now starts reporting errors and warnings:
Project warning: object directory "avr_lib/avr5/obj" not found
Project library directory "C:\WinAVR-20100110\lib\gnat\avr_lib\avr5\lib\" does not exist
The latter issue is very clearly the fact that I have not set up GPS correctly to tell it the values of microcontroller and architecture, but I cannot seem to find anything to resolve this.
Method 3:
To use the WinAVR set up directly using makefiles which then gives me the error:
avr-gnatmake: RTS path not valid: missing adainclude and adalib directories
If I follow the instructions I can find by searching the web I can only find details for building the required libraries under Linux.
Platform: Windows 7.
With the combination of the two answers above I have now managed to link my sample code. As to wether it will work on the Arduino, that is a different issue.
Many thanks for the help.
I have found it a bit frustrating to get this far, and I wonder if there are others out there who may just give up on Ada on the Arduino and go back to the Arduino IDE and therefore missing out on the opportunity to learn a language with more structure. There are many misleading pages out there that also do not help.
You might want to take a look in the paper Integrating 8-bit AVR Micro-Controllers in Ada. Basically you can use a GPS project file arduino.gpr like
project Arduino is
for Source_Dirs use (".", "src");
for Object_Dir use "obj";
for Exec_Dir use "bin";
for Main use ("main.adb");
package Compiler is
for Default_Switches ("ada") use ("-mmcu=avr5");
end Compiler;
package Ide is
for Gnat use "avr-gnat";
for Gnatlist use "avr-gnatls";
for Debugger_Command use "avr-gdb";
end Ide;
package Builder is
for Executable_Suffix use ".elf";
for Default_Switches ("ada") use ("--RTS=rts-zfp");
end Builder;
package Linker is
for Default_Switches ("ada") use ("obj\crtm328p._o", "-nostdlib", "-lgcc", "-mavr5", "-Tdata=0x00800200", "-mmcu=avr5");
end Linker;
end Arduino;
and you can code a spec for your ATmega328P like
with Interfaces; use Interfaces;
with System;
package ATmega328P is
-- PORTB: Port B Data Register
PORTB : Unsigned_8;
for PORTB'Address use System'To_Address (16#25#);
-- DDRB: Port B Data Direction Register
DDRB : Unsigned_8;
for DDRB'Address use System'To_Address (16#24#);
-- PINB: Port B Input Pins
PINB : Unsigned_8;
for PINB'Address use System'To_Address (16#23#);
end ATmega328P;
to be imported by your main file or libraries.
Bear with me if this isn't the immediate answer; I have only used the AVR-Ada toolchain on Linux, so we may have to iterate towards a solution unless someone else spots the problem first.
The first thing to decipher is which version of the AVR-Ada tools you have:
your project file USED to need (using avr-ada 1.1)
with "C:\WinAVR-20100110\lib\gnat\avr.gpr";
Now with avr-ada 1.2.1 you need (instead)
with "C:\WinAVR-20100110\lib\gnat\avr_app.gpr";
for building applications, and <same path>/avr_lib.gpr for libraries.
I don't believe you ever need both! And they may conflict with each other.
I don't know the state of the Windows binary build, but if you need the latest version (recommended : it's a real improvement) you may need to build it from source.
Method 1 : were you running Make from a command line? If so, I would expect to see errors in all their gory details.
Method 2 : can't help you here, I don't know GPS well enough. However I can say that on Linux there are no "avr5" folders in [wherever]/avr/lib/gnat/avr_lib. (AVR5 is correct for the 328p)
Instead there IS a [wherever]/avr/lib/avr5 containing libc and other C-related objects - including the crtm328p.o that Rego names in his linker switches, and a [wherever]/lib/gcc/avr/4.7.2/avr5 folder containing libgcc.a. You probably need to find the former and point GPS at it...
Method 3 : This looks the easiest to fix. The "gnatmake" command needs an --RTS= option pointing at the correct RTS for the 328p. This should be --RTS=rts/avr5 assuming the RTS is correctly installed.
Alternatively a full path ought to work. Here, that would be
--RTS=/opt/avr_472_gnat/lib/gcc/avr/4.7.2/rts/avr5
on Windows you may have to poke around to find the correct path.
Using Method 1 this --RTS option is automatically generated by avr_app.gpr.
It appears that having a mix of 3 or 4 tool chains installed that provide one of aspects of WinAvr, AvrAda causes significant problems (these included WinAvr, Avr-Ada, Cygwin, AVR compiler by Adacore and MinWG).
Starting with a brand new Win7 or Win8 installation perform the following:
Install WinAVR-20100110 to C:\WinAVR-20100110
Copy the content of the Avr-Ada-1.2.0_bin to C:\avr-ada-1.2.0
Add C:\avr-ada-1.2.0\bin to the PATH
Compiling the content of each of the examples in C:\avr-ada-1.2.0\share\doc\avr-ada\apps identifies that some DLLs are missing: libiconv-2.dll, libgmp-10.dll, libmpc-2.dll, libmpfr-1.dll
These can be found in a MinGW installtion.
Create a virtual machine to install MinGW on, in order to ensure it did not mess with the main PC.
Copy the missing DLLs in C:\WinAVR-20100110\bin
The example in DS1820 will not compile due to crc_lib being missing.
In order to upload to the Arduino the makefiles must be modified for your local installation, board type etc.

Resources