conda / constructor

tool for creating installers from conda packages
https://conda.github.io/constructor/
Other
457 stars 168 forks source link

Improve disk space check for sh installers #774

Open marcoesters opened 5 months ago

marcoesters commented 5 months ago

Checklist

What is the idea?

The Anaconda QA team has found a few edge cases for when the sh installer checks for remaining disk space, which all lead to different error messages. See "Additional Context" for these edge cases.

I am not sure if the error message when there isn't enough space for displaying the license can be fixed, but the others can improve by:

Why is this needed?

Consistent and clear error messages make it easier for users to understand why the installation failed.

If there is not enough space on disk, the installation should exit cleanly without artifacts.

What should happen?

Ideally, the error messages are consistent and no files should be written before disk space is checked.

Additional Context

If the space is fully consumed already and the user tries to run the installer

root@4b9aad66a111:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay          50G   50G     0 100% /
tmpfs            64M     0   64M   0% /dev
shm              64M     0   64M   0% /dev/shm
/dev/dasda1      50G   50G     0 100% /etc/hosts
tmpfs           2.0G     0  2.0G   0% /proc/scsi
tmpfs           2.0G     0  2.0G   0% /sys/firmware
root@4b9aad66a111:~# bash Miniconda3-py312_24.3.0-0-Linux-s390x.sh

Welcome to Miniconda3 py312_24.3.0-0

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
Miniconda3-py312_24.3.0-0-Linux-s390x.sh: line 148: cannot create temp file for here-document: No space left on device
root@4b9aad66a111:~# ls -la

If the space is fully consumed but able to load the License

root@4b9aad66a111:~# ./Miniconda3-py312_24.3.0-0-Linux-s390x.sh

Welcome to Miniconda3 py312_24.3.0-0

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
END USER LICENSE AGREEMENT

<license details>

Do you accept the license terms? [yes|no]
>>>        yes

Miniconda3 will now be installed into this location:
/root/miniconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/root/miniconda3] >>>
mkdir: cannot create directory ‘/root/miniconda3’: No space left on device
ERROR: Could not create directory: '/root/miniconda3'
root@4b9aad66a111:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay          50G   50G     0 100% /
tmpfs            64M     0   64M   0% /dev
shm              64M     0   64M   0% /dev/shm
/dev/dasda1      50G   50G     0 100% /etc/hosts
tmpfs           2.0G     0  2.0G   0% /proc/scsi
tmpfs           2.0G     0  2.0G   0% /sys/firmware
root@4b9aad66a111:~#

A disk error message appears if the instance has enough space to create an empty folder.

root@4b9aad66a111:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay          50G   48G     0 100% /
tmpfs            64M     0   64M   0% /dev
shm              64M     0   64M   0% /dev/shm
/dev/dasda1      50G   48G     0 100% /etc/hosts
tmpfs           2.0G     0  2.0G   0% /proc/scsi
tmpfs           2.0G     0  2.0G   0% /sys/firmware
root@4b9aad66a111:~# bash Miniconda3-py312_24.3.0-0-Linux-s390x.sh

Welcome to Miniconda3 py312_24.3.0-0

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
END USER LICENSE AGREEMENT

<license details>

Do you accept the license terms? [yes|no]
>>>   yes

Miniconda3 will now be installed into this location:
/root/miniconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/root/miniconda3] >>>
ERROR: Not enough free disk space: -102400 < 931457
root@4b9aad66a111:~# ls -la
total 135616
drwx------ 1 root root      4096 Apr 15 20:34 .
drwxr-xr-x 1 root root      4096 Apr 15 20:31 ..
-rw-r--r-- 1 root root      3106 Dec  5  2019 .bashrc
drwxr-xr-x 2 root root      4096 Apr 15 20:34 miniconda3
-rw-r--r-- 1 root root 138838773 Apr 15 20:24 Miniconda3-py312_24.3.0-0-Linux-s390x.sh
-rw-r--r-- 1 root root       161 Dec  5  2019 .profile
-rw-r--r-- 1 root root       205 Apr 15 20:25 .wget-hsts

Steps to Reproduce:

  1. Download the Miniconda3 installer script for your desired Python version, e.g., Miniconda3-py312_24.3.0-0-Linux-s390x.sh
  2. Utilize the disk up to 100%.
  3. Run the script using bash Miniconda3-py312_24.3.0-0-Linux-s390x.sh.