Nix Gradle dist - Failed to load native library 'libnative-platform.so' for Linux amd64 - c++

I am trying to build a Freeplane derivation based on Freemind, see: https://github.com/razvan-panda/nixpkgs/blob/freeplane/pkgs/applications/misc/freeplane/default.nix
{ stdenv, fetchurl, jdk, jre, gradle }:
stdenv.mkDerivation rec {
name = "freeplane-${version}";
version = "1.6.13";
src = fetchurl {
url = "mirror://sourceforge/project/freeplane/freeplane%20stable/freeplane_src-${version}.tar.gz";
sha256 = "0aabn6lqh2fdgdnfjg3j1rjq0bn4d1947l6ar2fycpj3jy9g3ccp";
};
buildInputs = [ jdk gradle ];
buildPhase = "gradle dist";
installPhase = ''
mkdir -p $out/{bin,nix-support}
cp -r ../bin/dist $out/nix-support
sed -i 's/which/type -p/' $out/nix-support/dist/freeplane.sh
cat >$out/bin/freeplane <<EOF
#! /bin/sh
JAVA_HOME=${jre} $out/nix-support/dist/freeplane.sh
EOF
chmod +x $out/{bin/freeplane,nix-support/dist/freeplane.sh}
'';
meta = with stdenv.lib; {
description = "Mind-mapping software";
homepage = https://www.freeplane.org/wiki/index.php/Home;
license = licenses.gpl2Plus;
platforms = platforms.linux;
};
}
During the gradle build step it is throwing the following error:
building path(s)
‘/nix/store/9dc1x2aya5p8xj4lq9jl0xjnf08n7g6l-freeplane-1.6.13’
unpacking sources unpacking source archive
/nix/store/c0j5hgpfs0agh3xdnpx4qjy82aqkiidv-freeplane_src-1.6.13.tar.gz
source root is freeplane-1.6.13 setting SOURCE_DATE_EPOCH to timestamp
1517769626 of file freeplane-1.6.13/gitinfo.txt patching sources
configuring no configure script, doing nothing building
FAILURE: Build failed with an exception.
What went wrong: Failed to load native library 'libnative-platform.so' for Linux amd64.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. builder for ‘/nix/store/id4vfk3r6fd4zpyb15dq9xfghf342qaa-freeplane-1.6.13.drv’
failed with exit code 1 error: build of
‘/nix/store/id4vfk3r6fd4zpyb15dq9xfghf342qaa-freeplane-1.6.13.drv’
failed
Running gradle dist from terminal works fine. I'm guessing that maybe one of the globally installed Nix packages provides a fix to the issue and they are not visible during the build.
I searched a lot but couldn't find any working solution. For example, removing the ~/.gradle folders didn't help.
Update
To reproduce the issue just git clone https://github.com/razvan-panda/nixpkgs, checkout the freeplane branch and run nix-build -A freeplane in the root of the repository.
Link to GitHub issue

Maybe you just don't have permission for the folder/file
sudo chmod 777 yourFolderPath
you can also : sudo chmod 777 yourFolderPath/* (All folder)
Folder will not be locked,then You can use it normally
[At least I succeeded。。。]
EX:
sudo chmod 777 Ruby/
now ,that's ok

To fix this error: What went wrong: Failed to load native library 'libnative-platform.so' for Linux amd64. do the following:
Check if your Gradle cache (**~user/.gradle/**native folder exist at all or not).
Check if your Gradle cache (~user/.gradle/native folder exist and the file in question i.e. libnative-platform.so exists in that directory or not).
Check if the above folder ~user/.gradle or ~/.gradle/native or file: ~/.gradle/native/libnative-platform.so has valid permissions (should not be read-only. Running chmod -R 755 ~/.gradle is enough).
IF you don't see native folder at all or if your native folder seems corrupted, run your Gradle task ex: gradle clean build using -g or --gradle-user-home option and pass it's value.
Ex: If I ran mkdir /tmp/newG_H_Folder; gradle clean build -g /tmp/newG_H_Folder, you'll see Gradle will populate all the required folder/files (that it needs to run even before running any task or any option) are now in this new Gradle Home folder (i.e. /tmp/newG_H_Folder/.gradle directory).
From this folder, you can copy - just the native folder to your user's ~/.gradle folder (take backup of existing native folder in ~/.gradle first if you want to) if it already exists -or copy the whole .gradle folder to your ~ (home directory).
Then rerun your Gradle task and it won't error out anymore.
Gradle docs says:
https://docs.gradle.org/current/userguide/command_line_interface.html
-g, --gradle-user-home
Specifies the Gradle user home directory. The default is the .gradle directory in the user’s home directory.

Related

Nix: Write a package that uses waf instead of make

The question
I'm trying to write a package to install libmonome, a toolkit for using the monome hardware (OSC controllers with LEDs, mostly for music).
My efforts are based on these instructions for building libmonome from source. Note that those instructions use waf, not make.
My hello world packages that use make build successfully. But my libmonome package that tries to use python waf analogously is not building:
[jeff#jbb-dell:~/nix/jbb-config/custom-packages/libmonome]$ nix-build
these derivations will be built:
/nix/store/kkf4c8l0njqdapnm2qgk6ffmybmafrpv-libmonome.drv
building '/nix/store/kkf4c8l0njqdapnm2qgk6ffmybmafrpv-libmonome.drv'...
Error: Cannot unpack waf lib into /nix/store/dk3pnwg7z9q14f4yj35y2kaqdmahnhhh-libmonome/.waf-2.0.17-6b308e91b5eb321c61bd5469cd6d43aa
Move waf in a writable directory
builder for '/nix/store/kkf4c8l0njqdapnm2qgk6ffmybmafrpv-libmonome.drv' failed with exit code 1
error: build of '/nix/store/kkf4c8l0njqdapnm2qgk6ffmybmafrpv-libmonome.drv' failed
[jeff#jbb-dell:~/nix/jbb-config/custom-packages/libmonome]$
Some maybe-helpful, maybe-redundant information
If you're cloning the repo, note that you'll need to fetch submodules to get all the libmonome code. Here's one way to do that:
git clone --recurse-submodules https://github.com/JeffreyBenjaminBrown/nixos-experiments
git checkout c20581f839f8e0fb39b2762baeea7d0a7ab10783
I already put absolute links to my code above, but in case you would rather see that code on this page, here is my default.nix file:
{...}:
with (import <nixpkgs> {});
derivation {
name = "libmonome";
builder = "${bash}/bin/bash";
args = [ ./builder.sh ];
buildInputs = [ git
coreutils
liblo
python2
];
# I would like to use fetchGit but haven't gotten it to work.
# src = fetchGit {
# url = "https://github.com/monome/libmonome.git";
# };
repo = ./libmonome;
system = builtins.currentSystem;
}
and here is the builder.sh script it calls:
set -e # Exit the build on any error
unset PATH # because it's initially a non-existant path
for p in $buildInputs; do
export PATH=$p/bin${PATH:+:}$PATH
done
cd $repo
# I've tried with python2 and python3
python2 ./waf configure
python2 ./waf
sudo python2 ./waf install

Adding gradle to PATH variable using python 2.7 on Centos 7

I'm new to python and I've been working on a script that will automatically set up development environments. So i have a laundry list of things I need to add to the script and one of them is the latest gradle-5.4.1. I'm running into an issue when I try to add gradle into $PATH on Centos7. After I run this function and run a gradle -v and check the $PATH, it's never concatenated into PATH variable. We need to be able to run gradle from anywhere and I cant seem to figure out how to do this.
def install_gradle():
print("Initiating gradle 5.4.1 install.....")
os.system("sudo wget https://services.gradle.org/distributions/gradle-5.4.1-bin.zip -P /tmp")
os.system("sudo unzip -d /opt/gradle /tmp/gradle-5.4.1-bin.zip")
os.environ("export PATH=$PATH:/opt/gradle/gradle-5.4.1/bin")
I've tried that last line with both os.system and os.environ, neither worked so not sure how to get this to work using python.
Thanks in advance for any input.
So this is what worked for me, editing the bashrc file seemed to resolve the my question:
def install_gradle():
print("Initiating gradle 5.4.1 install.....")
print("Downloading gradle file to tmp directory")
os.system("sudo wget https://services.gradle.org/distributions/gradle-5.4.1-bin.zip -P /tmp")
print("Unzipping gradle installation to /opt/gradle")
os.system("sudo unzip -d /opt/gradle /tmp/gradle-5.4.1-bin.zip")
print("Changing directories to /etc/bashrc")
bashrc_file = open("/etc/bashrc", "a+")
print("Appending PATH environment variables to bashrc file")
bashrc_file.write("export PATH=/opt/gradle/gradle-5.4.1/bin:$PATH")
bashrc_file.close()

Installed go with hombrew, can find $GOROOT causing package failures

I installed Go with homebrew and it usually works. Following the tutorial here on creating serverless api in Go. When I try to run the unit tests, I get the following error:
# _/Users/pro/Documents/Code/Go/ServerLess
main_test.go:6:2: cannot find package "github.com/strechr/testify/assert" in any of:
/usr/local/Cellar/go/1.9.2/libexec/src/github.com/strechr/testify/assert (from $GOROOT)
/Users/pro/go/src/github.com/strechr/testify/assert (from $GOPATH)
FAIL _/Users/pro/Documents/Code/Go/ServerLess [setup failed]
Pros-MBP:ServerLess Santi$ echo $GOROOT
I have installed the test library with : go get github.com/stretchr/testify
I would appreciate it if anyone could point me in the right direction.
Also confusing is when I run echo $GOPATH it doesnt return anything. same goes for echo $GOROOT
Some things to try/verify:
As JimB notes, starting with Go 1.8 the GOPATH env var is now optional and has default values: https://rakyll.org/default-gopath/
While you don't need to set it, the directory does need to have the Go workspace structure: https://golang.org/doc/code.html#Workspaces
Once that is created, create your source file in something like: $GOPATH/src/github.com/DataKid/sample/main.go
cd into that directory, and re-run the go get commands:
go get -u -v github.com/stretchr/testify
go get -u -v github.com/aws/aws-lambda-go/lambda
Then try running the test command again: go test -v
The -v option is for verbose output, the -u option ensures you download the latest package versions (https://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies).

Emscripten installation error: "./emcc no such file or directory"

I tried installing Emscripten on the latest version Arch Linux but was unsuccessful. I recieved no errors during the installation process, but when I attempted to verify the installation it threw an error: "bash: ./emcc no such file or directory". To the best of my ability I followed the instrcutions at https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html.
Installation Steps:
1) Dependencies (GCC ships complete with Arch, so no need to install)
pacman -S cmake python2 nodejs git
2) Download and unzip emsdk-portable.tar.gz
mkdir emscripten && cd empscripten
tar -xvf emsdk-portable.tar.gz
3) Installation
cd emsdk-portable
./emsdk update
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
source ./emsdk outputs:
Adding directories to PATH:
PATH += /home/myuser/emscripten/emsdk-portable
Setting environment variables:
EMSDK = /home/myuser/emscripten/emsdk-portable
EM_CONFIG = /home/myuser/.emscripten
Running echo $PATH outputs:
/home/myuser/emscripten/emsdk-portable:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
Running ./emcc -v or ./em++ -v outputs:
bash: ./emcc: No such file or directory
Any thoughts?
Here is my ~/.emscripten file:
import os
SPIDERMONKEY_ENGINE = ''
NODE_JS = 'node'
V8_ENGINE = ''
TEMP_DIR = '/tmp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]
Most usually, a current directory (.) is not added to the PATH variable, AFAIK it is for security reasons, so don't add it yourself too. :) When someone executes ./emcc, they specify the relative path to the program to be executed: "a program emcc residing precisely in the current directory".
On the other hand, executing just emcc (without the ./ prefix) means "iterate through the directories from the PATH variable left-to-right and execute the first found emcc executable". When you source the emsdk_env.sh you, among other things, adjust the PATH variable.
In comments you told that which emcc cannot find the emcc executable. It is strange, but even when you manage to fix the installation problem, you have to most usually specify emcc on the command line without the ./ prefix.

building chromium latest release on android

I have to build latest release of chromium browser for android.
I am using the following step,
Create a Chromium root directory
mkdir chromium ; cd chromium
Download and export PATH of depot_tools
export PATH=$PATH:~/path/to/depot_tools/
Checked out the source for build 32.0.1665.2
gclient config https://src.chromium.org/chrome/releases/32.0.1665.2
4 The above command create a .gclient file in chromium root directory, and add the target android in .gclient.
target_os = ['android']
To download the initial code:
gclient sync
Install the Dependencies
6.1) cd /path/to/chromium/src
6.2) ./build/install-build-deps.sh
gclient runhooks call GYP to generate your platform-specific files. This should give you a complete source tree
gclient runhooks
Compile :
To build the ARM Android content shell:
1) cd /path/to/chromium/src
2) . build/android/envsetup.sh
3) android_gyp
4) ninja -C out/Release -j10 content_shell_apk
After following the above command i am getting the content_shell.apk which has version chrome/19.77.34.5, i am checking the version of chromium using the link http://whatsmyuseragent.com,
Please help me to build chromium latest version(32.0.1665.2) on android
Content shell does not display correct user agent version in android as well as linux (right now content_shell displays chrome/19.77.34.5).
This seems to be deliberate from src/content/content_shell.gypi
'variables': {
'content_shell_product_name': 'Content Shell',
# The "19" is so that sites that sniff for version think that this is
# something reasonably current; the "77.34.5" is a hint that this isn't a
# standard Chrome.
'content_shell_version': '**19.77.34.5**',
You can always use chromium_testshell which will give correct version (which is currently Chrome/35.0.1879.0).