Error: Invalid or corrupt jarfile sbt/sbt-launch-0.13.5.jar - scala

I have been trying to install spark using the tutorial and everytime I run the command sbt/sbt assembly, I get the error "Error: Invalid or corrupt jarfile sbt/sbt-launch-0.13.5.jar"
I have tried everything: seperately adding the sbt file to the sbt folder in the spark folder, installing sbt individually, checking the download and reinstalling it over again, but in vain. Any advice about what I am doing wrong? Thanks.

Ok, After playing around for a while I finally got it and hopefully this will work for you aswell. That tutorial builds spark, where they do provide prebuilt binaries. I'm using Spark 1.2.0 just as a note (1.4.1 wouldn't work for me)
This is on Ubuntu 15.04 but should work on 14.04 the same
1) Remove the following lines from your bashrc
export SCALA_HOME=/usr/local/src/scala/scala-2.10.4
export PATH=$SCALA_HOME/bin:$PATH
2) Remove and reinstall scala
sudo rm -rf /usr/local/src/scala
# The following line is only needed if you installed scala another way, if so remove the #
# sudo apt-get remove scala-library scala
wget http://www.scala-lang.org/files/archive/scala-2.11.7.deb
sudo dpkg -i scala-2.11.7.deb
sudo apt-get update
sudo apt-get install scala
3) Download PreBuilt Spark and extract
wget http://d3kbcqa49mib13.cloudfront.net/spark-1.2.0-bin-hadoop2.4.tgz
tar -xzvf spark-1.2.0-bin-hadoop2.4.tgz
4) Run spark-shell
cd spark-1.2.0-bin-hadoop2.4/
./bin/spark-shell
Sources (basically where I've read from, this solution has been trial and error)
https://chongyaorobin.wordpress.com/2015/07/01/step-by-step-of-installing-apache-spark-on-apache-hadoop/
https://gist.github.com/visenger/5496675

If you have downloaded spark package from http://d3kbcqa49mib13.cloudfront.net/spark-1.1.0.tgz then cross check file - "sbt/sbt-launch-0.13.5.jar". If it just contains small (5-6lines) html content then you need to download jar file manually. This html file just indicate that required jar file was not found. You may use follow following steps for centos:
Download jar manually:
wget http://dl.bintray.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.1/sbt-launch.jar ./sbt/sbt-launch-0.13.5.jar
Prevent automatic downloading of jar file:
sed -i '47,68s/^/#/' sbt/sbt-launch-lib.bash
Install spark again:
sbt/sbt assembly
It worked for me without altering scala installation. Hope it helps.

The sbt script does not download properly sbt-launch-0.13.5.jar because there must be something wrong with the URLs it is using. As a result the file that it downloads contains just an HTML header (wither 400 or 302 codes). Until a better solution becomes available, as a workaround I would download manually sbt-launch-0.13.5.jar beforehand.

In the SPARK_HOME/sbt/sbt-launch-lib.bash script replace line 53 to line 57 with following
if hash curl 2>/dev/null; then
(curl --fail --location --silent ${URL1} > ${JAR_DL} ||\
(rm -f "${JAR_DL}" && curl --fail --location --silent ${URL2} > ${JAR_DL})) && \
mv "${JAR_DL}" "${JAR}"
elif hash wget 2>/dev/null; then
(wget --quiet ${URL1} -O ${JAR_DL} ||\
(rm -f "${JAR_DL}" && wget --quiet ${URL2} -O ${JAR_DL})) &&\
mv "${JAR_DL}" "${JAR}"
else
Then try again, run the sbt assembly command
sbt/sbt assembly
Simplest method is install sbt manually as follows
download sbt deb file
wget http://dl.bintray.com/sbt/debian/sbt-0.13.5.deb
Then run
sudo dpkg -i sbt-0.13.5.deb
sudo apt-get update
sudo apt-get install sbt
then build using
sbt assembly instead of sbt/sbt assembly from spark home folder

#Frozenfire, I'am not sure if it's possible but the Spark documentation Overview says :
For the Scala API, Spark 1.4.1 uses Scala 2.10. You will need to use a
compatible Scala version (2.10.x).
And I wonder if it would be the reason why you have this problem:
I'm using Spark 1.2.0 just as a note (1.4.1 wouldn't work for me)
Because you do :
sudo dpkg -i scala-2.11.7.deb
which downloads and installs scala-2.11.7.
I don't know but this might be a clue !
PS1: this is more a comment to Frozenfire's answer, but I can't comment because of a lack of reputation and I wanted to share this.
PS2: Building for Scala 2.11

Related

Running sbt in a Docker Container

I am trying to use Github actions for my scala project and created a Docker workflow for it. Basically, I am trying to install sbt into my container and run the project.
Dockerfile looks like this:
FROM centos:centos8
ENV SCALA_VERSION 2.13.1
ENV SBT_VERSION 1.5.2
RUN yum install -y epel-release
RUN yum update -y && yum install -y wget
# INSTALL JAVA
RUN yum install -y java-11-openjdk
# INSTALL SBT
RUN wget http://dl.bintray.com/sbt/rpm/sbt-${SBT_VERSION}.rpm
RUN yum install -y sbt-${SBT_VERSION}.rpm
RUN wget -O /usr/local/bin/sbt-launch.jar http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/$SBT_VERSION/sbt-launch.jar
WORKDIR /root
EXPOSE 8080
RUN sbt compile
CMD sbt run
But when I push anything, I get the following error:
The command '/bin/sh -c wget http://dl.bintray.com/sbt/rpm/sbt-${SBT_VERSION}.rpm' returned a non-zero code: 8
When I check the link manually (by setting the sbt version), I see indeed bintray responds with 403 forbidden error but status.bintray.com tells all systems are operational.
Am I doing something wrong or is something wrong with bintray?
Forbidden doesnt mean non operational.
I think that url is incorrect as its not hosted on bintray rather jfrog, please see section on Centos which states
remove old Bintray repo file
https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Linux.html

How to download packages from pypi using Wget?

Where from should I download virtualenv to use locally from source using wget?
I'm having troubles downloading virtualenv from the command line.
Info: if you search for virtualenv you will find the site for the stable version and its installation guide which is just equals to the latest version installation guide.
To install locally it describe this :
To install version X.X globally from source:
$ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-X.X.tar.gz
$ tar xvfz virtualenv-X.X.tar.gz
$ cd virtualenv-X.X
$ [sudo] python setup.py install
To use locally from source:
$ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-X.X.tar.gz
$ tar xvfz virtualenv-X.X.tar.gz
$ cd virtualenv-X.X
$ python virtualenv.py myVE
I'm using wget instead curl but should not be problem at all with this. Am I wrong?
The only place where I can download it (and not from the command line) is from here.
I'm typing the url correctly.
Different virtualenv versions at the url return the same not found:
HTTP request sent, awaiting response... 404 Not Found
2017-07-21 17:53:09 ERROR 404: Not Found.
Please note that I have already downloaded the tar.gz so I don't need it right now but I'm not sure if this is a broken link issue or I'm forgotten something else at the download command. I will not associate an issue to virtualenv just because a broken link but I need to know why this is not working.
EDIT: I can't download it using wget from ..python..packages/source/v/virtualenv etc.
TARGET="https://pypi.python.org/simple/virtualenv/"
PATTERN="virtualenv-15.1.0.tar.gz"
wget --recursive --no-directories --accept=$PATTERN $TARGET
Yes, curl and wget are equivalent for what you're trying.
No, you can download from anywhere. From PyPI, e.g.
There is no functional difference between pip install virtualenv and what you're trying to do but the former is simpler and less error-prone so why bother with manual labour?

Cannot build sbt project due to launcher version

I have a SBT projec on Ubuntu 14.04. When I run sbt I get the following message:
Detected sbt version sbt.version = 0.13.8
Starting sbt: invoke with -help for other options
Cannot find sbt launcher sbt.version = 0.13.8
Please download:
From http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/sbt.version = 0.13.8/sbt-launch.jar
To /home/vagrant/.sbt/.lib/sbt.version/sbt-launch.jar
When I try and download from the above url I am met with a 404 response. In fact even the url http://typesafe.artifactoryonline.com is giving 404.
Any ideas how I can get the correct sbt version on my system?
One solution is not to use the package manager at all. Uninstall sbt, and simply use the sbt shell script by Paul Phillips: https://github.com/paulp/sbt-extras :
curl -s https://raw.githubusercontent.com/paulp/sbt-extras/master/sbt > ~/bin/sbt \
&& chmod 0755 ~/bin/sbt
This is quite up-to-date and should have the correct repositories for the launchers.
How did you install sbt?
If you're using sbt-extras you might be hitting #107. Try upgrading it to a newer version.
An alternative is to switch to the official version of sbt. See Installing sbt on Linux:
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 642AC823
sudo apt-get update
sudo apt-get install sbt
Your installed sbt version is probably a bit older and still refers to the old repository.
Typesafe moved to a bintray repository so the new url would be:
https://dl.bintray.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.8/sbt-launch.jar
or with alias
https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.8/sbt-launch.jar
repo.typesafe.com may be replaced by repo.lightbend.com in the future ;)
Reinstalling the sbt run script would probably help, too.

casperjs unable to run CoffeeScript scripts

I installed casperjs for the first time and ran the sample scripts. The first sample script (javascript) ran without incident. Then i tried running a coffescript sample, which I prefer, and received the following error:
Unable to load script test.coffee; check file syntax
I searched for an answer and the solution in the only related issue didn't work for me. I was able to compile the CoffeeScript (test.coffee) into JavaScript (test.js) and then ran the compiled JavaScript, again, without indecent.
I tried to track down the error by searching for the error message in the casperjs files. I found the error message at the end the ~/.node/lib/node_modules/casperjs/bin/bootstrap.js file where it passes control to phantomjs. I created simple a CoffeeScript: test_phantomjs.coffee:
console.log "hello phantomjs"
phantom.exit()
and ran the script (phantomjs test_phantomjs.coffee) with the following result:
Can't open 'test_phantomjs.coffee'
At this point I'm at loss. The problem is more of an inconvenience than anything since compiling into JavaScript solves the issue. Is their something I'm missing?
In Phantomjs2.0 was removed support of coffee-script
https://github.com/ariya/phantomjs/issues/12410
(disclaimer: i'm/was part of contribution team)
the support of coffee script in CasperJS depends on the version of phantomJs you are using because this is phantomjs that provide coffee script support out of box.
You can also use and install slimerjs (https://slimerjs.org) which - from my point of view - is more performant than phantomjs and supports coffeescript scripts.
Mickaƫl
Works for me. Can you post your PhantomJS version and platform?
Mine on Mac OS X:
$ phantomjs -v
1.9.8
Just works:
$ phantomjs test_phantomjs.coffee
hello phantomjs
As others say, PhantomJS v2.x no longer supports CoffeeScript.
Therefore, now you have 2 options to run PhantomJS with CoffeeScript:
Run plain *.coffee files with PhantomJS v1.9.8
Compile *.coffee files to *.js, and run *.js with PhantomJS v2.x
I recommend the latter up-to-date way, and this is how package.json looks like:
{
"scripts": {
"pretest": "npm install && coffee --compile **/*.coffee",
"test": "casperjs test --fail-fast script/*.js",
"watch": "coffee --watch --compile **/*.coffee"
}
}
See more detail at ymkjp/phantomjs2x_coffee_sample.
Btw, here's the way to install PhantomJS v1.9.8 on Ubuntu.
$ sudo apt-get update
$ sudo apt-get install build-essential g++ flex bison gperf ruby perl \
libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev \
libpng-dev libjpeg-dev python libx11-dev libxext-dev git
$ cd ~
$ wget -O- https://github.com/ariya/phantomjs/archive/1.9.8.tar.gz | tar zxvf -
$ cd ~/phantomjs-1.9.8
$ bash build.sh # It takes 30 min or so (Up to your host machine)
$ sudo ln -s ~/phantomjs-1.9.8/bin/phantomjs /usr/local/bin
$ phantomjs --version
1.9.8
Cheers.

Installing LuaMongo on Ubuntu 11.10

I have researched and viewed the post to install luamongo- http://groups.google.com/group/luamongo/browse_thread/thread/1eaa56974614dc90/c91c842e241aa4de#c91c842e241aa4de
But the installation will not work. I already have mongodb-10gen version 2.0.3 and lua5.1 version 5.1.4.10 installed.
How do I download luamongo from https://github.com/moai/luamongo and install it and get it working as an import statement in a lua script to be able to write to a mongo db? Any suggestions would be helpful, nothing I have tried so far or read has been able to help. If more information is needed I will post it. Thanks in advance.
I got this script from a friend of mine which should be helpful:
# Download mongodb and driver
wget http://downloads.mongodb.org/cxx-driver/mongodb-linux-x86_64-v2.0-latest.tgz
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.2.tgz
# Extract each
tar xvzf mongodb-linux-x86_64-2.0.2.tgz
tar xvzf mongodb-linux-x86_64-v2.0-latest.tgz
# Add mongo bin to PATH
export PATH=$PATH:~/mongodb-linux-x86_64-2.0.2/bin
# Grab dev tools and dependencies (May need to run apt-get update to download all)
sudo apt-get -y install tcsh scons libpcre++-dev libboost-dev libreadline-dev libboost-program-options-dev libboost-thread-dev libboost-filesystem-dev libboost-date-time-dev gcc g++ git lua5.1-dev make
# Grab latest luamongo (will need to add your github ssh key)
git clone git#github.com:moai/luamongo
# Compile mongo driver
cd mongo-cxx-driver-v2.0
sudo scons install
# Install where lua can load it
sudo cp libmongoclient.* /usr/lib