sbt failed to download launcher - linux

When I am trying to run 'sbt' on terminal, it is showing like this:
downloading sbt launcher 1.5.5
cat: /home/knoldus/.cache/sbt/boot/sbt-launch/1.5.5/sbt-launch-1.5.5.jar.sha1: No such file or directory
shasum: standard input: no properly formatted SHA checksum lines found
failed to download launcher jar: https://repo1.maven.org/maven2/org/scala-sbt/sbt-launch/1.5.5/sbt-launch-1.5.5.jar (shasum mismatch)

i had the same error and i just move to the directory and download the file missing manualy
cd ~/.cache/sbt/boot/sbt-launch/1.5.5/
wget https://repo1.maven.org/maven2/org/scala-sbt/sbt-launch/1.5.5/sbt-launch-1.5.5.jar
then i run
sbt package

You need to install curl. It is used in the sbt launcher shell script to download the file sbt-launch-1.5.5.jar.sha1 mentioned in the error message. If curl is missing, that will result in the error you've observed.

SBT package downloaded from the official website includes sbt-launch.jar in <sbt-install-folder>/bin directory. SBT launcher sbt is a shell script that searches for this JAR. If the JAR is not found, it will try to download it from the internet and fail if the machine is behind a proxy.
So, when this happens, first thing is to check the sbt file location and if sbt-launch.jar is present. If the JAR is missing, it can be copied from the official SBT distribution, even if the machine is behind the proxy or offline.

The issue is apparently with command curl --output not being able to open the output file. In my /usr/bin/sbt there is a function
download_url () {
local url="$1"
local jar="$2"
mkdir -p $(dirname "$jar") && {
if command -v curl > /dev/null; then
curl -L "$url" --output "$jar"
elif command -v wget > /dev/null; then
wget -O "$jar" "$url"
fi
} && [[ -f "$jar" ]]
Changing the curl line to:
curl -L "$url" > "$jar"
Fixed the issue for me. I have no idea what the underlying problem with curl is, but it happened both when installed with apt and snap.

Related

Error while trying to install Kops on Ubuntu 20 EC2 Instance

I went through the steps listed here: https://kubernetes.io/docs/setup/production-environment/tools/kops/
After moving the kops file to /usr/local/bin/ and renaming to kops, I tried to confirm if it was in fact installed and executable by trying 'kops --help' and 'kops --version'/'kops version' and neither command worked. Any idea what the issue might be?
Edit: Here's what I did step by step
curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-darwin-amd64
sudo chmod +x kops-darwin-amd64
sudo mv kops-darwin-amd64 /usr/local/bin/kops
It's a t2.micro Ubuntu 20.04 EC2 Instance.
Tried to confirm if kops was properly installed and executable by entering 'kops --help' and 'kops --version' and also 'kops version' but they all return this error:
-bash: /usr/local/bin/kops: cannot execute binary file: Exec format error
I think its because you are using kops-darwin-amd64. This is for mac. I think you should be using kops-linux-amd64 instead for linux.

Change directory in a startup script debian

I am running a debian VM Instance using GCP Compute Engine and I have added a automation script to be executed on startup.
There are few tools which will be downloaded on startup. Only issue is, everything is getting downloaded in / directory.
I need to download everything in $HOME directory.
Different ways I have tried
#!/bin/bash
set -x
cd $HOME
mkdir $HOME/test
cd $HOME/test
apt install wget -y
wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz
#!/bin/bash
set -x
source $HOME
mkdir $HOME/something
#!/bin/bash
set -x
cd $HOME
mkdir $HOME/something
exec bash
Still it is downloaded in / directory. What else can be done here?
You are trying to make 2 things : install wget package and download another one.
Why don't you tried to install wget manually ?
apt-get install wget
You have then to store the full path for your script, and download the package needed it it. Try this :
#!/bin/bash
homePath=$HOME
mkdir $HOME/test
wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz -P $homePath/test/

How to change shell of npm install

I'm trying to npm install a package in Ubuntu 16.04. I get the following error message:
npm install
...
> padlock#2.0.0-beta.1 bower-install /home/kent/Documents/padlock
> pushd app && bower install && popd app
sh: 1: pushd: not found
My Research
According to /bin/sh: pushd: not found, my problem is clearly that npm install is trying to execute pushd with sh not bash.
However, my default shell is already bash
$ env | grep SHELL
SHELL=/bin/bash
$ echo $SHELL
/bin/bash
$ echo $0
bash
and I'm not sure what I need to change. I've also tried adding SHELL=/bin/bash before I execute pushd app but I have had no luck with that either.
npm-scripts run using sh
Scripts are run by passing the line as a script argument to sh
https://docs.npmjs.com/misc/scripts#exiting
If you want to use bash for your scripts make the script
bash -c 'pushd app && bower install && popd'
Update: As of November 2017 you can now set script-shell in .npmrc to use a custom shell
I was able to work around a similar situation by creating this file in my project directory:
$ cat .npmrc
script-shell=/bin/bash
FWIW, the issue I stumbled upon was relying on bash-specific "curly-brace expansion" commands in the postinstall section of the package.json file for the offending module. That malformed command works in MacOS, but not Linux.

RVM source as sudo?

I'm installing rvm as part of script. After installed I need to run sudo gem but to do this I first need to source the script.
The recommended way is to use source /home/$USER/.rvm/scripts/rvm, but this is not possible with sudo as described here.
I read that source was equivilent to ./$FILE_NAME but ./home/$USER/.rvm/scripts/rvm didn't solve my issue.
How can I source rvm so ruby and gem can be accessed via sudo?
Restarting or logging out is not possible as this is all done in a single shell script.
I initially tried referencing rvm and gem by the full path to the file. This got me a step further but led to other issues. From what I've read it seems sudo use with rvm isn't recommended.
I decided to not use rvm and download the latest ruby from their official downloads page instead.
My install_ruby.sh script: (run from folder to install in)
# Download ruby
wget https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.gz -P /tmp
# Get SHA256 sum
SHA="$(sha256sum /tmp/ruby-2.4.1.tar.gz | cut -d ' ' -f1)"
# Exit if SHA256 doesn't match expected
[ "$SHA" != "a330e10d5cb5e53b3a0078326c5731888bb55e32c4abfeb27d9e7f8e5d000250" ] && exit;
# Extract and install tar
tar -zxvf /tmp/ruby-2.4.1.tar.gz -C /opt
/opt/ruby-2.4.1/configure
make
sudo make install

some error with the 'ln' scripts

anybody is familiar with the etcd project? Or we'd better forget the project when talk about this issue. The issue is
$ build
ln: `gopath/src/github.com/coreos/etcd': cannot overwrite directory
when exec the build shell
and the content is:
#!/bin/sh -e
if [ ! -h gopath/src/github.com/coreos/etcd ]; then
mkdir -p gopath/src/github.com/coreos/
ln -s ../../../.. gopath/src/github.com/coreos/etcd
fi
export GOBIN=${PWD}/bin
export GOPATH=${PWD}/gopath
export GOFMTPATH="./bench ./config ./discovery ./etcd ./error ./http ./log main.go ./metrics ./mod ./server ./store ./tests"
# Don't surprise user by formatting their codes by stealth
if [ "--fmt" = "$1" ]; then
gofmt -s -w -l $GOFMTPATH
fi
go install github.com/coreos/etcd
go install github.com/coreos/etcd/bench
Some addition:
My system is windows 7
I run the shell on git bash.
issue reproduce:
step1: open the git bash
step2: git clone git#github.com:coreos/etcd.git
step3: cd etcd
step4: build
As mentioned in "Git Bash Shell fails to create symbolic links" (since you are using the script in a git bash on Windows 7)
the ln that shipped with msysGit simply tries to copy its arguments, rather than fiddle with links. This is because links only work (sort of) on NTFS filesystems, and the MSYS team didn't want to reimplement ln.
A workaround is to run mklink from Bash.
This also allows you to create either a Symlink or a Junction.
So 'ln' wouldn't work as expected by default, in the old shell that ships with Git for Windows.
Here's solution. Tbh it is a workaround, but since you're on Windows, I don't see another way.
Start a command line, and enter there to the directory with the script. There should be a path gopath/src/github.com/coreos/ (if no such a path, you must create it). Next issue a command
mklink /D "gopath/src/github.com/coreos/etcd" "../../../../"
Next you should edit the build script to delete a lines with creation symlink and a directory. E.g.
#!/bin/sh -e
export GOBIN=${PWD}/bin
export GOPATH=${PWD}/gopath
export GOFMTPATH="./bench ./config ./discovery ./etcd ./error ./http ./log main.go ./metrics ./mod ./server ./store ./tests"
# Don't surprise user by formatting their codes by stealth
if [ "--fmt" = "$1" ]; then
gofmt -s -w -l $GOFMTPATH
fi
go install github.com/coreos/etcd
go install github.com/coreos/etcd/bench
Note, that I am just removed 4 lines of code. Next you run the script, and this should work.
You shouldn't be using git clone and the build sh script. Use the go get command. For example, on Windows 7,
Microsoft Windows [Version 6.1.7601]
C:\>set gopath
GOPATH=C:\gopath
C:\>go version
go version go1.3 windows/amd64
C:\>go get -v -u github.com/coreos/etcd
github.com/coreos/etcd (download)
github.com/coreos/etcd/third_party/bitbucket.org/kardianos/osext
github.com/coreos/etcd/pkg/strings
github.com/coreos/etcd/error
github.com/coreos/etcd/third_party/github.com/coreos/go-etcd/etcd
github.com/coreos/etcd/http
github.com/coreos/etcd/third_party/github.com/coreos/go-log/log
github.com/coreos/etcd/third_party/github.com/rcrowley/go-metrics
github.com/coreos/etcd/mod/dashboard/resources
github.com/coreos/etcd/log
github.com/coreos/etcd/third_party/github.com/gorilla/context
github.com/coreos/etcd/third_party/github.com/gorilla/mux
github.com/coreos/etcd/mod/dashboard
github.com/coreos/etcd/discovery
github.com/coreos/etcd/pkg/btrfs
github.com/coreos/etcd/pkg/http
github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto
github.com/coreos/etcd/mod/leader/v2
github.com/coreos/etcd/mod/lock/v2
github.com/coreos/etcd/metrics
github.com/coreos/etcd/third_party/github.com/mreiferson/go-httpclient
github.com/coreos/etcd/mod
github.com/coreos/etcd/third_party/github.com/BurntSushi/toml
github.com/coreos/etcd/third_party/github.com/goraft/raft/protobuf
github.com/coreos/etcd/third_party/github.com/goraft/raft
github.com/coreos/etcd/store
github.com/coreos/etcd/server/v1
github.com/coreos/etcd/server/v2
github.com/coreos/etcd/store/v2
github.com/coreos/etcd/server
github.com/coreos/etcd/config
github.com/coreos/etcd/etcd
github.com/coreos/etcd
C:\>

Resources