Cabal install criterion out of memory - haskell

I'm running on a container with 768MB ram and 512 MB swap space. I can't increase either of this. cabal install criterion always gives
Failed during the building phase.
The exception was: ExitFailure (-9)
This may be due to an out-of-memory condition.
during Compiling Criterion.Types. Is there any way around this or do I have to make do without criterion?

Set RTS flags on GHC to limit its memory usage (--ghc-options="+RTS -M600M") and avoid running multiple jobs in parallel (-j1).

Answer to #DavidAzar's comment on the answer:
#Li-yaoXia's solution worked, but then I had more problems. This is all from my rough notes as I tracked my way through the problem. So there might be a more streamlined solution.
Well, actually it compiled everything, but cabal --version still says 2.4, not 3.4. Maybe it's not in the path?
Warning: could not create a symlink in /root/.cabal/bin for cabal because
the file exists there already but is not managed by cabal. You can create a symlink for
this executable manually if you wish. The executable file has been installed at /root/.cabal/bin/cabal
There appears to be a solution here: https://stackoverflow.com/a/17030330/52236
But I have to figure out how to remove the existing symlink before redoing the cabal install and doing the recompile process all over again.
There is also this solution here, which I will try first:
updating cabal-install, but version is not changed
Ran unminimize from bash, which installs all the normal stuff to ubuntu.
First, in /bin, create a folder called /cabal-old, then copy the cabal executable to the cabal-old folder. Then remove cabal from the /bin folder.
Then create a new symlink pointing to the new cabal executable:
ln -s /root/.cabal/bin/cabal cabal
This gets cabal 3.4 to show up when doing cabal --version.
Next, install git: apt-get install git
Then go to plutus-pioneer-program/code/week01/ folder and enter cabal build
This downloads a lot of stuff from git, and then fails.
Warning: Requested index-state 2021-02-24T00:00:00Z is newer than
'hackage.haskell.org'! Falling back to older state (2021-02-23T23:53:53Z).
Resolving dependencies...cabal: Could not resolve dependencies:
[__0] trying: Win32-network-0.1.0.0 (user goal)
[__1] trying: base-4.12.0.0/installed-4.12.0.0 (dependency of Win32-network)
[__2] next goal: plutus-pioneer-program-week01 (user goal)
[__2] rejecting: plutus-pioneer-program-week01-0.1.0.0
(conflict:base==4.12.0.0/installed-4.12.0.0, plutus-pioneer-program-week01 =>base^>=4.14.1.0)
[__2] fail (backjumping, conflict set: base, plutus-pioneer-program-week01)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, Win32-network,plutus-pioneer-program-week01
I got a suggestion from someone on Stackoverflow that the
Plutus-Pioneer code might need ghc 8.10, and I'm on a version of
8.6.5, so next step is to figure out how to update that.
Before getting ghc 8.10, I apparently need to have ghcup installed,
run this as non-root user?:
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
this started the install, but failed because I don't have 'make' installed. Run this:
apt-get install make
then re-run the curl command. The curl installer output shows ghc 8.10 being installed, but after it's done, ghc --version outputs 8.6.5 still. Another symlink issue?
I found this issue in the output:
In order to run ghc and cabal, you need to adjust your PATH variable.
You may want to source '/root/.ghcup/env' in your shell
configuration to do so (e.g. ~/.bashrc).
It also might require figuring out how to specify which version of ghc to use.
I need to update the simlink in the bin folder in order to get the correct version of ghc being used, and there are the following other links to update:
lrwxrwxrwx 1 root root 9 Mar 24 2020 ghc -> ghc-8.6.5
-rwxr-xr-x 1 root root 226 Mar 24 2020 ghc-8.6.5
lrwxrwxrwx 1 root root 13 Mar 24 2020 ghc-pkg -> ghc-pkg-8.6.5
-rwxr-xr-x 1 root root 258 Mar 24 2020 ghc-pkg-8.6.5
lrwxrwxrwx 1 root root 10 Mar 24 2020 ghci -> ghci-8.6.5
-rwxr-xr-x 1 root root 55 Mar 24 2020 ghci-8.6.5
First, created a new symlink for ghcup:
ln -s /root/.ghcup/bin/ghcup ghcup
(Although I can't remember what I needed ghcup for.)
Next, update the ghc symlinks for all 3 symlinks listed above in the /bin folder:
mv -T ghc ghc-old-link
ln -s /root/.ghcup/bin/ghc ghc
This works to get the newer version of ghc showing up in the bash shell.
Now trying to build, and it downloads and starts building a lot of stuff, but now this error happens:
cabal: Failed to build cborg-0.2.4.0 (which is required by
plutus-pioneer-program-week01-0.1.0.0). The build process was killed (i.e.SIGKILL).
The typical reason for this is that there is not enough memory
available (e.g. the OS killed a process using lots of memory).
Solution for this:
Docker -> Preferences -> Resources -> increase RAM, and swap space. In my case from 2-8GB RAM, and from 1 to 2 GB swap space.
Now it builds the Plutus Pioneer code for week 1.

Related

Automake-1.14 is failing at make

I downloaded automake-1.14 by following this tutorial on Ubuntu 16.04
./configure passed without any error. But the moment I ran make it gave an error.
I actually removed automake-1.15 from linux because when I was
installing protobuf 2.6.1 it says that i can't find automake-1.14. Therefore I remove automake by apt-get autoremove automake. And ran the following commands
$ wget http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz
$ tar xvzf automake-1.14.tar.gz
$ cd automake-1.14
$ ./configure
$ make # FAIL HERE
$ sudo make install
The Error is the following:
anybody#anywhere:~/anyshare/automake-1.14$ make
GEN t/testsuite-part.am
GEN m4/amversion.m4
CDPATH="${ZSH_VERSION+.}:" && cd . && "/home/anybody/anyshare/automake-1.14/t/wrap/aclocal-1.14"
Can't locate /home/anybody/anyshare/automake-1.14/bin/aclocal in #INC (#INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /home/anybody/anyshare/automake-1.14/t/wrap/aclocal-1.14 line 29.
Makefile:2494: recipe for target 'aclocal.m4' failed
make: *** [aclocal.m4] Error 2
Apparently, the original problem -- and likely the problem building Automake -- was an incorrect appearance that the packages' Autotools-based build systems were out of date.
Generally speaking, Autotools-based packages should be distributed with the Autotools outputs pre-built, even though technically, they are derived files. This avoids any need for the Autotools themselves to be installed on the build system for people who are just building the package on a supported system, not modifying or porting it. Distribution packages built by an Autotools-based build system via make dist will in fact include them.
By default and typically, Autotools-based build systems include rules for rebuilding the build system itself if it is out of date. This is a convenience for package maintainers. Autoconf has a built-in mechanism to provide an option for disabling those rules (so-called "maintainer mode") at configuration time, though not all packages make use of it.
Normal operation of tar preserves file timestamps, but if your particular tar fails to do so, whether in general or in your particular case, or if your filesystem's timestamps have poor resolution, then unpacking the source tarballs may produce a result in which the Autotools outputs appear to be out of date. In that case, unless suppressed, the rules for rebuilding the build system will be triggered when you run make.
If this happens to you, and the package's configure script supports the maintainer-mode option, then you can suppress the build-system rebuilding rules by including the --disable-maintainer-mode option when you configure the package. Hindsight being 20/20, I can confidently state that this solves the Protobuf-building problem for you.

Running out of memory while compiling with GHC [duplicate]

I'm running on a container with 768MB ram and 512 MB swap space. I can't increase either of this. cabal install criterion always gives
Failed during the building phase.
The exception was: ExitFailure (-9)
This may be due to an out-of-memory condition.
during Compiling Criterion.Types. Is there any way around this or do I have to make do without criterion?
Set RTS flags on GHC to limit its memory usage (--ghc-options="+RTS -M600M") and avoid running multiple jobs in parallel (-j1).
Answer to #DavidAzar's comment on the answer:
#Li-yaoXia's solution worked, but then I had more problems. This is all from my rough notes as I tracked my way through the problem. So there might be a more streamlined solution.
Well, actually it compiled everything, but cabal --version still says 2.4, not 3.4. Maybe it's not in the path?
Warning: could not create a symlink in /root/.cabal/bin for cabal because
the file exists there already but is not managed by cabal. You can create a symlink for
this executable manually if you wish. The executable file has been installed at /root/.cabal/bin/cabal
There appears to be a solution here: https://stackoverflow.com/a/17030330/52236
But I have to figure out how to remove the existing symlink before redoing the cabal install and doing the recompile process all over again.
There is also this solution here, which I will try first:
updating cabal-install, but version is not changed
Ran unminimize from bash, which installs all the normal stuff to ubuntu.
First, in /bin, create a folder called /cabal-old, then copy the cabal executable to the cabal-old folder. Then remove cabal from the /bin folder.
Then create a new symlink pointing to the new cabal executable:
ln -s /root/.cabal/bin/cabal cabal
This gets cabal 3.4 to show up when doing cabal --version.
Next, install git: apt-get install git
Then go to plutus-pioneer-program/code/week01/ folder and enter cabal build
This downloads a lot of stuff from git, and then fails.
Warning: Requested index-state 2021-02-24T00:00:00Z is newer than
'hackage.haskell.org'! Falling back to older state (2021-02-23T23:53:53Z).
Resolving dependencies...cabal: Could not resolve dependencies:
[__0] trying: Win32-network-0.1.0.0 (user goal)
[__1] trying: base-4.12.0.0/installed-4.12.0.0 (dependency of Win32-network)
[__2] next goal: plutus-pioneer-program-week01 (user goal)
[__2] rejecting: plutus-pioneer-program-week01-0.1.0.0
(conflict:base==4.12.0.0/installed-4.12.0.0, plutus-pioneer-program-week01 =>base^>=4.14.1.0)
[__2] fail (backjumping, conflict set: base, plutus-pioneer-program-week01)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base, Win32-network,plutus-pioneer-program-week01
I got a suggestion from someone on Stackoverflow that the
Plutus-Pioneer code might need ghc 8.10, and I'm on a version of
8.6.5, so next step is to figure out how to update that.
Before getting ghc 8.10, I apparently need to have ghcup installed,
run this as non-root user?:
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
this started the install, but failed because I don't have 'make' installed. Run this:
apt-get install make
then re-run the curl command. The curl installer output shows ghc 8.10 being installed, but after it's done, ghc --version outputs 8.6.5 still. Another symlink issue?
I found this issue in the output:
In order to run ghc and cabal, you need to adjust your PATH variable.
You may want to source '/root/.ghcup/env' in your shell
configuration to do so (e.g. ~/.bashrc).
It also might require figuring out how to specify which version of ghc to use.
I need to update the simlink in the bin folder in order to get the correct version of ghc being used, and there are the following other links to update:
lrwxrwxrwx 1 root root 9 Mar 24 2020 ghc -> ghc-8.6.5
-rwxr-xr-x 1 root root 226 Mar 24 2020 ghc-8.6.5
lrwxrwxrwx 1 root root 13 Mar 24 2020 ghc-pkg -> ghc-pkg-8.6.5
-rwxr-xr-x 1 root root 258 Mar 24 2020 ghc-pkg-8.6.5
lrwxrwxrwx 1 root root 10 Mar 24 2020 ghci -> ghci-8.6.5
-rwxr-xr-x 1 root root 55 Mar 24 2020 ghci-8.6.5
First, created a new symlink for ghcup:
ln -s /root/.ghcup/bin/ghcup ghcup
(Although I can't remember what I needed ghcup for.)
Next, update the ghc symlinks for all 3 symlinks listed above in the /bin folder:
mv -T ghc ghc-old-link
ln -s /root/.ghcup/bin/ghc ghc
This works to get the newer version of ghc showing up in the bash shell.
Now trying to build, and it downloads and starts building a lot of stuff, but now this error happens:
cabal: Failed to build cborg-0.2.4.0 (which is required by
plutus-pioneer-program-week01-0.1.0.0). The build process was killed (i.e.SIGKILL).
The typical reason for this is that there is not enough memory
available (e.g. the OS killed a process using lots of memory).
Solution for this:
Docker -> Preferences -> Resources -> increase RAM, and swap space. In my case from 2-8GB RAM, and from 1 to 2 GB swap space.
Now it builds the Plutus Pioneer code for week 1.

libpng12.so.0: cannot open shared object file: wrong ELF class: ELFCLASS64

I'm trying to install Quartus 13.0 on a docker container but I have a trouble with libpng12 lib.
builder#580847ded665:~$ ls -ld $(locate -r libpng.*\.so.*)
lrwxrwxrwx. 1 root root 18 Jan 6 2016 /lib/x86_64-linux-gnu/libpng12.so.0 -> libpng12.so.0.54.0
-rw-r--r--. 1 root root 149904 Jan 6 2016 /lib/x86_64-linux-gnu/libpng12.so.0.54.0
lrwxrwxrwx. 1 root root 35 Jan 6 2016 /usr/lib/x86_64-linux-gnu/libpng12.so.0 -> /lib/x86_64-linux-gnu/libpng12.so.0
builder#580847ded665:~$ xvfb-run -a /home/builder/altera/13.0/quartus/bin/tb2_install --enable
tb2_install: error while loading shared libraries: libpng12.so.0: cannot open shared object file: wrong ELF class: ELFCLASS64
The problem is I have a 32 bit application trying to use a 64 bit library and it is not understanding it. Could anyone please help me to figure out how to fix this issue?
Here's what you can do.
Download libpng12-0 package from
here.
Now head over to the folder where you've downloaded it and open the terminal from there. Switch to super user using:
sudo su
Install the downloaded package with the following command:
dpkg -i libpng12-0_1.2.50-1ubuntu2.14.04.3_amd64.deb; apt-get install -f
(The package name can change, make sure to change it accordingly).
If you get an error like this:
dpkg: error processing archive libpng12-0_1.2.50-1ubuntu2.14.04.3_amd64.deb (--install): trying to overwrite shared '/usr/share/doc/libpng12-0/changelog.Debian.gz'
This means that you might have an existing libpng package installed on your system which is causing a conflict.
Do this:
mv /usr/share/doc/libpng12-0 /usr/share/doc/libpng12-0.backup
This means that you are moving the conflict causing directory to another location.
Finally,
dpkg -i libpng12-0_1.2.50-1ubuntu2.14.04.3_amd64.deb; apt-get install -f
My answer is specific to Bionic beaver and *64 architecture. You can checkout the link provided above to download other architecture-specific packages.
Hope this helps!
Try installing 32-bit version of libpng. On Debian it should be something like apt-get install libpng16-16:i386. If tb2_install keeps picking 64-bit version you might need to update LD_LIBRARY_PATH to put 32-bit paths in front of 64-bit ones.
Another solution is to use 64-bit Quartus installer.

Can I access Postgre database on another machine using Perl, DBI, and DBD::Pg?

My machine: Linux RHEL 5.5.56 (64-bit), Perl 5.8.8. Postgres is not on this machine. But I can ping the Postgres machine no problem. And my machine can obviously install Perl modules from CPAN on the internet.
'uname -a' returns: Linux xxx 2.6.18-371.8.1.el5PAE #1 SMP Fri Mar 28 06:00:03 EDT 2014 i686 i686 i386 GNU/Linux
Other machine has Postgres 8.4.
I'm new to installing and using any DBI module. Detailed beginner instructions are needed.
I have root access to my Linux machine.
I think yum reports that I have 'postgresql-libs.i386' installed. `yum install | grep postgres` returns: 'postgresql-libs.i386 8.1.23-10.el5_10 installed'
Is this what I need? This is on my system.
lrwxrwxrwx 1 root root 12 May 1 20:05 /usr/lib/libpq.so.4 -> libpq.so.4.1*
-rwxr-xr-x 1 root root 130K Feb 27 07:36 /usr/lib/libpq.so.4.1*
Goal: I want to grab data from a Postgres server on another machine. I already have a db username, password, IP for the db machine.
Using cpanm I installed DBI just fine, no errors. When I installed DBD::Pg I got an error. CPAN error log follows:
cpanm (App::cpanminus) 1.6941 on perl 5.008008 built for i386-linux-thread-multi
Work directory is /root/.cpanm/work/1405531191.27414
You have make /usr/bin/make
You have LWP 6.04
You have /bin/tar: tar (GNU tar) 1.15.1
You have /usr/bin/unzip
Searching DBD::Pg on cpanmetadb ...
--> Working on DBD::Pg
Fetching http://www.cpan.org/authors/id/T/TU/TURNSTEP/DBD-Pg-3.3.0.tar.gz
-> OK
Unpacking DBD-Pg-3.3.0.tar.gz
Entering DBD-Pg-3.3.0
Checking configure dependencies from META.yml
Checking if you have version 0 ... Yes (0.88)
Checking if you have DBI 1.614 ... Yes (1.631)
Configuring DBD-Pg-3.3.0
Running Makefile.PL
Path to pg_config?
No POSTGRES_HOME defined, cannot find automatically
Configuring DBD::Pg 3.3.0
-> N/A
-> FAIL Configure failed for DBD-Pg-3.3.0. See /root/.cpanm/work/1405531191.27414/build.log for details.
Is it even possible for me to get data from the Postgres db on another machine?
Does anyone have a link to instructions on how to do this? I've already been googling stuff, reading stuff on CPAN, Stackoverflow and Perlmonks with no results.
FAQ at http://dbi.tiddlyspot.com/ has no info specific to installing DBD::Pg.
If I install Postgres via yum, will the installation overwrite any files, like libraries? If so, which ones? We do have other applications we use on this machine.
If I get this working, my first step is to show just very basic info about the DBI driver. Next step would be to show a few fields from one table in a SELECT statement.
I won't be returning millions of records, but returning 100 records is certainly in the ballpark.
Thank you!
If you use the package that is already built and available for your system, then you won't have any of these problems.
$ sudo yum install perl-DBD-Pg
... Lots of output snipped ...
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
perl-DBD-Pg x86_64 1.49-4.el5_8 centos-update 115 k
Installing for dependencies:
postgresql-libs x86_64 8.1.23-6.el5_8 centos-update 197 k
Transaction Summary
================================================================================
Install 2 Package(s)
Upgrade 0 Package(s)
Total download size: 312 k
Is this ok [y/N]:
My example uses Centos 5.8.8, but it should work just the same for RHEL.
Of course you can; it's a client/server architecture, after all!
The error in your log is due to a missing libpq5.

Node.js source code build giving segmentation fault on ARM

tl;dr: I tried to install node.js on my ARMv7-based Cubox running Ubuntu 12.10 (quantal). When compiling node.js from source (see "Second attempt" below), node produces a segmentation fault. What can I do here?
First attempt
First of all, I tried to install node.js via the package manager, following the instructions for Ubuntu that are given here: Installing Node.js via package manager: Ubuntu, Mint
Adding the repository mentioned there using sudo add-apt-repository ppa:chris-lea/node.js seems to work fine:
You are about to add the following PPA to your system:
Evented I/O for V8 javascript. Node's goal is to provide an easy way to build scalable network programs
More info: https://launchpad.net/~chris-lea/+archive/node.js
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmpp0owib/secring.gpg' created
gpg: keyring `/tmp/tmpp0owib/pubring.gpg' created
gpg: requesting key C7917B12 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpp0owib/trustdb.gpg: trustdb created
gpg: key C7917B12: public key "Launchpad chrislea" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
However, sudo apt-get install nodejs gives me the error:
E: Unable to locate package nodejs
I assume this is because I have an ARM-based system. As far as I can tell from the package details, the repo only contains builds for i386 and amd64. Is my assumption right?
Second attempt
So my next attempt was to install node.js from source. I used the instructions given in the following gist: Node.js and NPM in 30 seconds. Everything seems to work, including make install. But the execution of the install.sh script in the last line of the gist fails since node produces a segmentation fault. Now I wonder what I can do to properly install node.js on my machine?
In order to illustrate my problem, here is some output:
install.sh output
This is the ouput of install.sh after running make install, as described in the gist installation instructions mentioned above.
cyroxx#cubox:~/node-latest-install$ curl https://npmjs.org/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7882 100 7882 0 0 11251 0 --:--:-- --:--:-- --:--:-- 14984
tar=/bin/tar
version:
tar (GNU tar) 1.26
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
install npm#latest
fetching: http://registry.npmjs.org/npm/-/npm-1.2.21.tgz
Segmentation fault
Segmentation fault
You need node to run this program.
node --version reports: v0.10.7
Please upgrade node before continuing.
It failed
node output
cyroxx#cubox:~/node-latest-install$ node
Segmentation fault
make Debug build
Running make with BUILDTYPE=Debug produces this output:
cyroxx#cubox:~/node-latest-install$ make -C out BUILDTYPE=Debug
make: Entering directory `/home/cyroxx/node-latest-install/out'
CXX(target) /home/cyroxx/node-latest-install/out/Debug/obj.target/v8_base/deps/v8/src/arm/stub-cache-arm.o
../deps/v8/src/arm/stub-cache-arm.cc: In function 'void v8::internal::ProbeTable(v8::internal::Isolate*, v8::internal::MacroAssembler*, v8::internal::Code::Flags, v8::internal::StubCache::Table, v8::internal::Register, v8::internal::Register, v8::internal::Register, v8::internal::Register, v8::internal::Register, v8::internal::Register)':
../deps/v8/src/arm/stub-cache-arm.cc:106:15: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
cc1plus: all warnings being treated as errors
make: *** [/home/cyroxx/node-latest-install/out/Debug/obj.target/v8_base/deps/v8/src/arm/stub-cache-arm.o] Error 1
make: Leaving directory `/home/cyroxx/node-latest-install/out'
What's wrong here? Is this a bug in the ARM implementation of V8? Maybe any compiler flags that are not (properly) set? Anything else? I am totally stuck.
I had this problem too on a few different ARM computers. Compiling without the snapshot feature worked for me. Snapshot is a V8 feature that allows node to start faster, and there seems to be a bug for ARM.
./configure --without-snapshot
make
sudo make install
http://www.armhf.com/index.php/node-js-for-the-beaglebone-black/
I had trouble building on a Samsung Chromebook XE303C12I with Crouton running Unity, even with --without-snapshot and --with-arm-float-abi=hard, so I used the precompiled binaries for Linux ARM devices.
Binaries can be found in the release directory at nodejs.org/dist/{version number}
For example, the ARM binary for v0.10.24 can be downloaded [here].(http://nodejs.org/dist/v0.10.24/node-v0.10.24-linux-arm-pi.tar.gz)
Here's a script to download and install a binary. Once you have node installed, make sure to add path/to/bin/node to your $PATH.

Resources