How to use django-pipeline in a virtual-env? - java

I have been using django-pipeline successfully for a couple of months. Now I have installed virtual-env for the first time on a clean system. Everything is accordingly set and all pip installs are done within my environment.
python manage.py collectstatic
Now I get an error when I am collecting my static files, it says
File "/vc/cb-env/local/lib/python2.7/site-packages/pipeline/compressors/__init__.py", line 247, in execute_command
raise CompressorError(error)
pipeline.compressors.CompressorError: [warning] /usr/bin/yui-compressor: No java runtime was found
[warning] /usr/bin/yui-compressor: No JAVA_CMD set for run_java, falling back to JAVA_CMD = java
Even though both yui-compressor as well as latest java were installed previously:
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install oracle-java7-installer -y
sudo apt-get install yui-compressor -y
By the look of it, because I had installed java as root, my environment doesn't seem to find it.
What can I do?

Not a direct solution but after some research and chat with the maker of django-pipeline it seems that Yui-Compressor is deprecated anyway and replaced by Yuglify.
Hence its best to keep the django settings.py as it is and simply install Yuglify instead.
sudo apt-get install npm
(switch your virtualenv's environment)
npm install yuglify
The settings.py needs to change only one line:
PIPELINE_YUI_BINARY = '/vc/{your-project-env}/site/{your-project}/node_modules/yuglify/bin/yuglify'
Thats it and it works.
UPDATE:
In the latest django-pipeline You can't set the YUI binary to Yuglify anymore.
You have explicitely declare the yuglify binary. But otherwise nothing changes:
PIPELINE_YUGLIFY_BINARY = "/vc/{yourproject-env}/node_modules/yuglify/bin/yuglify"

Related

update-java-alternatives returns a directory that was removed, and I can't get it back

I'm new to linux, I don't understand symbolic links, how apt-get works or how to get back removed files. Almost all commands here are from searching for a solution to the problem.
When I run update-java-alternatives -l I get
java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.17.0-openjdk-amd64 1711 /usr/lib/jvm/java-1.17.0-openjdk-amd64
But when I attempt to do ls or cd to /usr/lib/jvm/java-1.17.0-openjdk-amd64 I get the error that it doesn't exist.
While I was trying some things I removed the directory, and now I can't get it back, don't know what to install and is not in the recycle bin. Attempted the following commands
sudo apt-get install openjdk-17-jdk // already installed
sudo apt-get install openjdk-17-jre // already installed
I need to get the directory to select it as the home folder for IntelliJ IDEA JRE and be able to run a Spring Boot >6.0 application, since java 11 needs Spring Boot 5.3.
ls /usr/lib/jvm/ returns
default-java java-1.11.0-openjdk-amd64 java-11-openjdk-amd64 java-17-openjdk-amd64 openjdk-17
As you can see I have the directory java-1.11.0-openjdk-amd64 which works fine when selecting it as home directory in the Intellij IDE, but I need the java-1.17
Also did this with JAVA_HOME and attempted sudo apt-get install java-1.17.0-openjdk-devel but no package found.

Installing rJava package with Docker

I am trying to install the 'rJava' package in my RStudio docker image using my Dockerfile:
FROM rocker/tidyverse:3.6.1
RUN mkdir -p /rstudio
RUN mkdir -p /rscripts
RUN apt-get update && \
apt-get install -y openjdk-11-jdk && \
apt-get install -y liblzma-dev && \
apt-get install -y libbz2-dev
RUN R -e "install.packages(c('rJava','mailR'))"
Following this SO post I added the above part with the apt-get commands but still I get the same error:
java libs :
'-L/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server -ljvm'
checking whether Java run-time works... ./configure: line 3766:
/usr/bin/java: No such file or directory no configure: error: Java
interpreter '/usr/bin/java' does not work ERROR: configuration failed
for package ‘rJava’
So there is a missing file or directory but I don't know what changes I should make.
[EDIT 1]:
So, following Dirk's suggestion, I entered in the rstudio container and ran apt-get install r-cran-rjava which seems to work.
But when I install rJava package I get a new error:
error: Cannot compile a simple JNI program. Make sure you have Java
Development Kit installed and correctly registered in R. If in doubt,
re-run "R CMD javareconf" as root.
I tried to enter again in the container and run R CMD javareconf but that did not change the error. I also tried the following commands found on this article:
sudo apt-get install default-jre
sudo apt-get install default-jdk
But I still get:
Cannot compile a simple JNI program.
I found a github repo suggesting to add these steps in the Dockerfile before installing R package rJava and it worked:
RUN apt-get -y update && apt-get install -y \
default-jdk \
r-cran-rjava \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/
This is a duplicate of similar answers I have already given in the Debian / Ubuntu context. The fact that you are using Docker does not matter: you should still simply install the binary!
edd#rob:~$ docker run --rm -ti r-base bash
root#ef4bb9726a21:/# apt update -qq
73 packages can be upgraded. Run 'apt list --upgradable' to see them.
root#ef4bb9726a21:/# apt install --no-install-recommends -y r-cran-rjava
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
ca-certificates-java default-jre default-jre-headless java-common libasound2 libasound2-data libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libdbus-1-3 libdrm-amdgpu1 libdrm-common
libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libedit2 libgif7 libgl1 libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 liblcms2-2 libllvm10 libnspr4 libnss3 libpciaccess0 libpcsclite1
libsensors-config libsensors5 libsqlite3-0 libvulkan1 libx11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-sync1 libxdamage1 libxfixes3 libxi6 libxshmfence1 libxtst6 libxxf86vm1 libz3-4
openjdk-11-jre openjdk-11-jre-headless
[.... many lines skipped ....]
Running hooks in /etc/ca-certificates/update.d...
done.
done.
root#ef4bb9726a21:/# R
R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
[...some lines skipped...]
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(rJava)
>
The reason why Dirk's answer doesn't work for you is because you're using rocker/tidyverse as a base image instead of the r-base that Dirk is using.
In the rocker/tidyverse documentation on Docker Hub they are discouraging the use of apt install --no-install-recommends -y r-cran-rjava:
do not use apt-get install r-cran-* to install R packages on this stack. The requested R version and all R packages are installed from source in the version-stable stack. Installing R packages from apt (e.g. the r-cran-* packages) will install the version of R and versions of the packages that were built for the stable debian release (e.g. debian:stretch), giving you a second version of R and different packages. Please install R packages from source using the install.packages() R function (or the install2.r script), and use apt only to install necessary system libraries (e.g. libxml2). If you would prefer to install only the latest verions of packages from pre-built binaries using apt-get, consider using the r-base stack instead.
Since rJava is supposed to be installed with apt install r-cran-rjava, but the rocker/... base images explicitly tell you not to do that, it looks like you will not be able to use rJava with any of the rocker/... base images..

debian apt cant find openjdk-8-jdk

im trying to install openjdk-8-jdk as suggested here with the command:
sudo apt-get install openjdk-8-jdk
but apt dosnt find the package. i did find it at packages.debian.org manualy and tried to tell apt to also load from there, as suggested on the mirrors page of that package by adding the following line to /etc/apt/sources.list
deb http://ftp.de.debian.org/debian sid main
but apt still cant find the package. i also tried to change the
url to http://deb.debian.org/debian
sid to buster or buster-backports
main to unstable, non-free, contrib (or a list of some or all of those)
combinations of all of the above
still no luck.
add the following line to /etc/apt/sources.list
deb http://deb.debian.org/debian/ sid main
install openjdk8
//Update the repositories
$ sudo apt-get update
$ sudo apt-get install -y openjdk-8-jdk
In fact, I think it is better to search for your question first before ask.
How to install openjdk-8-jdk on Debian 10 (Buster)?

Is it possible to install the JDK on an android device?

I want to be able to compile and run basic java apps within the android terminal termux. I checked out Terminal IDE, but that is incompatible with Android 5.0+. Additionally, I tried to install the arm64 jdk from Oracle's website, which android fails to recognize. I am running CM 13 and to clarify, I want to be able to run commands like javac and java directly from my phone.
If you have Termux, you can download the deb file here, and install it with apt-get install /path/to/deb. A command to download and install the JRE and JDK for arm:
cd ~ # Change to home directory
apt-get install -y wget # BusyBox wget doesn't support HTTPS
hash -d wget # Forgets the BusyBox wget path so new one is used
wget https://archive.org/download/openjdk-9-jre-headless_9.2017.8.20-1_x86_64/openjdk-9-jre-headless_9.2017.8.20-1_arm.deb # Download JRE
wget https://archive.org/download/openjdk-9-jre-headless_9.2017.8.20-1_x86_64/openjdk-9-jdk-headless_9.2017.8.20-1_arm.deb # Download JDK
apt-get install -y ./openjdk-9-jre-headless_9.2017.8.20-1_arm.deb ./openjdk-9-jdk-headless_9.2017.8.20-1_arm.deb # Install the files
rm openjdk-9-*.deb # Remove the files after because they're huge
Or a one-liner to copy and paste:
cd ~ && apt-get install -y wget && hash -d wget && wget https://archive.org/download/openjdk-9-jre-headless_9.2017.8.20-1_x86_64/openjdk-9-jre-headless_9.2017.8.20-1_arm.deb && wget https://archive.org/download/openjdk-9-jre-headless_9.2017.8.20-1_x86_64/openjdk-9-jdk-headless_9.2017.8.20-1_arm.deb && apt-get install -y ./openjdk-9-jre-headless_9.2017.8.20-1_arm.deb ./openjdk-9-jdk-headless_9.2017.8.20-1_arm.deb && rm openjdk-9-*.deb
To install for another architecture, replace occurences of "arm" with the correct architecture. There are files for "arm" (most 32-bit phones), "aarch64" (ARM64/armv8, most 64-bit phones), "i686" (x86), and "x86_64". Most phones have either arm or aarch64. I believe the arm version should at least work on aarch64 (may be wrong?), so arm should work for almost everyone. But if you know what your device has, use that instead.
Edit: to find your device's architecture, run uname -m from Termux.
#moderatelygood Go to Google Play Store and download GNURoot Debian. It is a fakeroot, i.e. terminal emulator. Many other terminal emulators are available in the Play Sore, but this ine is very good. It lives at https://github.com/corbinlc/GNURootDebian and website is http://corbinlc.github.io/GNURootDebian You can download many packages like this:
apt-get update
apt-get install default-jdk
apt-get install python
and so on.
You would be able to compile/run programs in these languages. Use some text editor to write programs, like Jota Text Editor, also available in Play Store.
Actually Terminal can be used if you're only interested in javac , java, jar . That is , you can use these three on Lollipop. I am using Terminal IDE on Android 5.1.1, it works as expected. The usable version can be found at https://www.dropbox.com/s/h2d23ecbrt2akeu/terminalide-2.02-binary-mod-signed.apk?dl=0. If you want to give it a try then open this mod terminal and do : cp /system/lib/libjavacrypto.so ~/system/lib , copying this library should do the job(did for me) leaving java and dx commands working.
Java can installed on termux. INSTALLION of java on termux take very short period of time and install directly from termux-source, this program really work for me, i am dame sure it will also work for you also......
git clone https://github.com/EagleComrade/Termux-java.git
cd Termux-java
chmod +x install.sh
bash install.sh

issue with installing java package on ec2

I was trying to install java using the following command:
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts
during the installation for some reason my micro-instance in EC2 kept on freezing, I guess I am not the only one having this issue as it's posted on the aws forum as well. Now when I try to do the whole thing again I get:
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
However, when I try to run sudo dpkg --configure -a, it is just stuck in here:
Setting up sun-java6-bin (6.26-1lucid1) ...
for about an hour or so... WHat should I do now to get java in place?
It could be that the repository you added doesn't have the 'right' version of java6, personally I would use canonical's repository.
First I would try to uninstall the packages and repo
sudo apt-get remove sun-java6-jre sun-java6-plugin sun-java6-fonts
sudo remove-apt-repository ppa:ferramroberto/java
And then use canonical's aptitude repository.
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jdk
I thinks its the same Bug: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/634487
issue fix
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
pd#admin:~$ sudo dpkg --configure -a
dpkg: error: parsing file '/var/lib/dpkg/updates/0024' near line 0: newline in field name `#padding'
pd#admin:~$ sudo rm /var/lib/dpkg/updates/0024
pd#admin:~$ sudo dpkg --configure -a
pd#admin:~$ sudo apt-get install appname_mention_here
Reading package lists... Done
Building dependency tree
Reading state information... Done
Now its working the installation....!
Simply use Open JDK like so...
sudo apt-get install openjdk-6-jre-headless
since you can only ssh into anyway... :)

Categories