githubnext / monaspace

An innovative superfamily of fonts for code
https://monaspace.githubnext.com
SIL Open Font License 1.1
13.12k stars 219 forks source link

Fixed install_linux.sh #239

Open geoffreysmith opened 1 week ago

geoffreysmith commented 1 week ago

Thought I submitted this last night, whatever:

Bash 5.2, Ubuntu 24.04

Input from root of ~/Workspaces/monaspace

Input:

sudo bash /util/install_linux.sh

Also tried:

chmod -X install_linux.sh

Though sudo should have overwritten that.

Output (original line 12 & 15, directories created manually and also tried to let the script do its thing made no difference.

Output:

cp: cannot stat {{directory_name}}*': No such file or directory

Edit: I believe context on the terminal is correct, as non root "geoffrey" ... it does some weird things when starting over with original script and deleting /home/geoffrey/share/fonts/

Input:

rm -rf ~/local/share/fonts```` geoffrey@dell:~$ [ -d "/home/geoffrey/.local/share/fonts/" ] && echo "dir exists" || echo "dir does not exist"```

Output:

```dir does not exist````

Input (original install_linux.sh):

cd geoffrey@dell:~/Workspaces/monaspace$ echo ~

Output: `/home/geoffrey

Run command with debug:

[sudo] password for geoffrey: 
+ mkdir -p /root/.local/share/fonts
+ rm -rf '/root/.local/share/fonts/Monaspace*'
+ mkdir -p /root/.local/share/fonts/Monaspace/
+ cp ./fonts/otf/MonaspaceArgon-BoldItalic.otf ``` (ommitting all the fonts)```

It will see me as root, install it into root the root user's ```/root/.local/share/fonrts``` then install the rest into ```/home/geoffrey/fonts```

Which I'm not going to type out anymore exact commands I think it is obvious what is happening. I also didn't know I had Starship installed but that didn't matter. The script needs a major overhaul.  Running my script produces somehow different results (Starship remove/purge just to make sure):

Input/Output:
``` bash
geoffrey@dell:~/Workspaces/github-forks/monaspace$ sudo bash -x util/install_linux.sh 
+ set -e
+ set -u
+ set -o pipefail
+ echo 'Starting font installation script...'
Starting font installation script...
+ echo 'Creating directory: ~/.local/share/fonts'
Creating directory: ~/.local/share/fonts
+ mkdir -p /root/.local/share/fonts
+ echo 'Removing existing Monaspace fonts from ~/.local/share/fonts'
Removing existing Monaspace fonts from ~/.local/share/fonts
+ rm -rf /root/.local/share/fonts/Monaspace
+ echo 'Creating directory: ~/.local/share/fonts/Monaspace/'
Creating directory: ~/.local/share/fonts/Monaspace/
+ mkdir -p /root/.local/share/fonts/Monaspace/
+ '[' -d ./fonts/otf ']'
+ echo 'Copying fonts from ./fonts/otf/ to ~/.local/share/fonts/Monaspace/'
Copying fonts from ./fonts/otf/ to ~/.local/share/fonts/Monaspace/`

Take my word for it but it does not install /home/geoffrey/fonts but it puts it all under root. Coming from Debian/Fedora I don't think this would have happened. It would have kept my username, but I'd be in an admin group so I think my PID would be the same but would run through the wheel group. The differences in the scripts with no changes except conditionals impacting globbing is really strange.

I am going to update this script, then try to run under a cross-compile matrix. I do not know why the differences are happening.

geoffreysmith commented 1 week ago

I don't want to recreate the repository right now but changing from WHOAMI to LOGNAME is showing the user invoking the script:

Fonts copied to /home/geoffrey/.local/share/fonts/Monaspace and font cache updated.

I'm downloading Fedora to make sure but I'm not worried about it. The deno dependency is ... odd. All I know is that I only have these kerning fonts and my command line is jacked but that was to be expected. It solved the immediate error until someone wants to take the time to create a cross-compile test-suite for this. It'd not be a big effort but definitely uh summer intern work.

Thanks.