Nonsensical error message from running `install.sh` with flags

I try to install a fresh SDK, but prevent it from modifying the dotfiles outright. So I run:

./install.sh --set-path=false --bash-completions=false --zsh-completions=false

And this yields the error message:

SDK not installed. Cannot run command without SDK.
To proceed, please install the SDK by running:

    daml install latest

Running install.sh without flags works, but then it also messes with the bash dotfiles.

Observed in DAML SDK 1.18.1 on Linux, daml-sdk-1.18.1-linux.tar.gz.

Is there anything wrong with that intention? The install.sh script forwards its own arguments to daml install, so I assumed it would be alright.

1 Like

Hi @mesch

There are two, good ways to install Daml on GNU/Linux:

  1. A method that installs every package individually, found here, or
  2. The auto_install method from the Daml Documentation

If you are concerned about Curling a Bash file from the Internet, which is understandable, please review the current Bash script using the drop-down menu below.

Current Bash script
#!/bin/sh

# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

#
# Daml is an open-source privacy-aware smart contract language.
# This script downloads and installs the SDK on Linux and macOS.
# This will overwrite any existing installation in ~/.daml
# For more information please visit https://daml.com/ and https://docs.daml.com/
#

#
# USAGE:
#    get-daml.sh            Download and install the latest SDK release.
#    get-daml.sh VERSION    Download and install given version of SDK.
#

set -eu
readonly INSTALL_MINSIZE=1000000
if [ -z "${TEMPDIR:-}" ]; then
  readonly TMPDIR="$(mktemp -d)"
else
  readonly TMPDIR=$TEMPDIR
  if [ ! -d "$TEMPDIR" ] ; then
    mkdir $TEMPDIR
  fi
fi

# Don't remove user specified temporary directory on cleanup.
rmTmpDir() {
  if [ -z "${TEMPDIR:-}" ]; then
    rm -rf $TMPDIR
  else
    echo "You may now remove the Daml installation files from $TEMPDIR"
  fi
}

cleanup() {
  echo "$(tput setaf 3)FAILED TO INSTALL!$(tput sgr 0)"
  rmTmpDir
}
trap cleanup EXIT


#
# Check that the temporary directory has enough space for the installation
#
if [ -x "$(command -v df)" -a -x "$(command -v awk)" ]; then
  if [ "$(df $TMPDIR | tail -1 | awk '{print $4}')" -lt "$INSTALL_MINSIZE" ]; then
    echo "Not enough disk space available to extract Daml SDK in $TMPDIR."
    echo ""
    echo "You can specify an alternative extraction directory by"
    echo "setting the TEMPDIR environment variable."
    exit 1
  fi
fi

#
# Check if curl and tar are available.
#
if [ -x "$(command -v curl)" ]; then
  MISSING=""
else
  MISSING="curl"
fi
if [ -x "$(command -v tar)" ]; then
  MISSING="$MISSING"
elif [ -n "$MISSING" ]; then
  MISSING="$MISSING, tar"
else
  MISSING="tar"
fi
if [ -n "$MISSING" ]; then
  echo "Missing tools required for Daml installation: $MISSING"
  exit 1
fi

#
# Determine SDK version
#
if [ -z "${1:-}" ] ; then
  echo "Determining latest SDK version..."
  readonly VERSION="$(curl -sS https://docs.daml.com/latest)"
  if [ -z "$VERSION" ] ; then
    echo "Failed to determine latest SDK version."
    exit 1
  fi
  echo "Latest SDK version is $VERSION"
else
  readonly VERSION="$1"
fi

#
# Determine operating system.
#
readonly OSNAME="$(uname -s)"
if [ "$OSNAME" = "Linux" ] ; then
  OS="linux"
elif [ "$OSNAME" = "Darwin" ] ; then
  OS="macos"
else
  echo "Operating system not supported:"
  echo "  OSNAME = $OSNAME"
  exit 1
fi

#
# Download SDK tarball
#
readonly TARBALL="daml-sdk-$VERSION-$OS.tar.gz"
readonly URL="https://github.com/digital-asset/daml/releases/download/v$VERSION/$TARBALL"

echo "$(tput setaf 3)Downloading SDK $VERSION. This may take a while.$(tput sgr 0)"
curl -SLf $URL --output $TMPDIR/$TARBALL --progress-bar
if [ ! -f $TMPDIR/$TARBALL ] ; then
  echo "Failed to download SDK tarball."
  exit 1
fi

#
# Remove existing installation.
#
readonly DAML_HOME="$HOME/.daml"
if [ -d $DAML_HOME ] ; then
  echo "Removing existing installation: $DAML_HOME"
  chmod -R u+w $DAML_HOME
  rm -rf $DAML_HOME
fi

#
# Remove existing cache.
#
readonly DAML_CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/daml"
if [ -d $DAML_CACHE ] ; then
  echo "Removing existing cache: $DAML_CACHE"
  rm -rf $DAML_CACHE
fi

#
# Extract and install SDK tarball.
#
echo "Extracting SDK release tarball."
mkdir -p $TMPDIR/sdk
tar xzf $TMPDIR/$TARBALL -C $TMPDIR/sdk --strip-components 1
$TMPDIR/sdk/install.sh
if [ ! -d $DAML_HOME ] ; then
  exit 1
fi

#
# Done.
#
trap - EXIT
echo "$(tput setaf 3)Successfully installed Daml.$(tput sgr 0)"
rmTmpDir

Either method works, but Method 2 is fast and the only resulting issue may be the placement of the required $PATH env, in either ~/.bash_profile or ~/.bashrc

I prefer settings path variables in ~/.bashrc, however you may not.

Thanks a lot for the response.

You mention

A method that installs every package individually, found [here](https://discuss.daml.com/t/overview-installing-daml-vs-code-on-xubuntu-focal-20-04-2-lts/2266) .

However, the linked post does not contain any actual instructions, just the results of the steps described elsewhere:

Refer to the previous Debian Buster tutorial for all the steps.

However, that previous tutorial is not linked and I don’t know where to find it. From what you describe, it’s more like what I would like to do, unless of course it also involves the execution of install.sh at some point, which I don’t know. Can you point me to it?

Btw. I agree the modifications to the dotfiles are useful. FWIW, there are two motivations on our side to separate the steps of installing the sdk itself from setting up a user’s dotfiles:

  1. We do use the SDK in non-interactive contexts, specifically as a hermetic toolchain for bazel, and in a container of a continuous build. In those cases updating dotfiles is pointless, albeit admittedly not harmful, once we have figured out where to direct the modifications to.

  2. We install the SDK as part of the setup of a larger development environment, and want to impose some structure for understandability. Specifically, we want to separate the “install” phase, which only moves files into place, from the “setup” phase, which configures those files for use.

1 Like

Sorry, I assumed prior knowledge.

The tutorials Daml on Debian and Daml on Ubuntu may be found in the forum Tutorial section.

The versions listed in the Debian tutorial will be a few out as that document was written halfway through last year, and even though it is titled Debian, as you know most of the commands and packages will be easily interchangeable.

Your needs re “Install and Setup” are a good point. The basic install that Daml actions on Linux using most methods, is quite benign & friendly, as it uses the $USERs directory as the default location.

Personally I create another directory titled ~/opt/ and extract/install the Daml SDK into there, totally away from everything else. That way if I misconfigure or misuse, it is easy to delete with zero issues.

I hope this helps.

Alright, for the record, this is what I do now to prevent install.sh from touching dotfiles:

# working dir is where the daml-sdk tarball was unpacked
declare -r DAML_HOME=${HOME}/.daml
declare -r HOME_TMP=$(mktemp -d)
mkdir -p $DAML_HOME
mkdir -p $HOME/.cache
ln -s $DAML_HOME $HOME_TMP
ln -s $HOME/.cache $HOME_TMP
HOME=$HOME_TMP "./sdk-${DAML_SDK_VERSION}/install.sh"
rm -rf $HOME_TMP

Cheers,
mesch.

1 Like

Nice solution. Mind if I use that?

Please use, I’m glad if it’s useful.

Cheers,
mesch.

1 Like

As a way to help the community, if you ask a question and it gets solved to your personal or functional satisfaction, either by yourself or someone else, if you can mark the best answer as a solution, that would be great.

To do that, select the Three Dots ... at the bottom of each post, choose Solution.

Thanks again for your question, that was interesting :+1:t2: