Skip to content

Errors & warnings

Nguyễn Hoàng Dương edited this page Jun 9, 2019 · 4 revisions

Seeing warning or error messages? Even if it's a warning, reveal-init is telling you that something has gone wrong and the program will fallback to a safe option, which is probably something you don't want. Let's see how we can deal with warnings and errors in reveal-init.

Table of Content

  1. Specification
  2. Common solutions
  3. Messages
  4. Appendix: Reveal.js repository's Directory Structure

Specification

  • Warning: Something is wrong but fallback options are available or the problem can be manually resolved later
  • Error: A more severe problem has occurred
    • Something is wrong and there's no fallback option
    • Something is wrong and will lead to the program's termination, but is not categorized as fatal in order to provide detailed information
  • Fatal: Something is wrong, making reveal-init unable to perform its specialized task (no new slide deck project will be created)

Common solutions

Just like how you turn a digital gadget off and turn it back on again to fix it, there are common solutions bound to reveal-init's problems. Typically, there shouldn't be any presence of a warning/error/fatal message - as long as you've done the setup correctly.

  1. Make sure that the original directory structure of the Reveal.js repository is preserved (please refer to the appendix).
  2. Some buggy versions of reveal-init output error messages even if you've done nothing wrong. Make sure you are using the latest version of reveal-init.
  3. If you are using a modified version of reveal-init, trace the source code to identify the problem, or if you are using someone else's modified version of reveal-init, consult the modifier.
  4. Try executing reveal-init using bash.

Messages

Click on the warning/error/fatal messages you are receiving. 2 subsections will be displayed: the Solution subsection and the Technical information subsection.

  • The Solution subsection gives you the possible solutions to solve the problem
  • The Technical information shows an excerpt of reveal-init's latest version's source code that triggers the message you're receiving

Warnings

--git: Git is not installed, option ignored

Solution

This means Git - a version control program - is either not installed or cannot be accessed without specifying its full path in the command line.

If it's the former case, install Git on your computer. If it's the latter, try to place the Git executable in a directory in $PATH (e.g. /usr/bin/) or add the directory where the Git executable lies in to $PATH.

Technical information

[ -z $(command -v git) ] \
    && warn "--git: Git is not installed, option ignored" \
    || git="true"
[$REVEAL_PATH] is not set

Solution

That means REVEAL_PATH is either not set or is set to an empty string. A prompt will appear as in the following snippet:

WARNING $REVEAL_PATH is not set.
reveal-init won't work without $REVEAL_PATH, what now?
    1: Use the current directory as $REVEAL_PATH (temporary)
    2: Set a value for $REVEAL_PATH (temporary)
    3: Abort and set a permanent value for $REVEAL_PATH
[1|2|3]

3 values are valid to the prompt:

  • "1": Use the current working directory as $REVEAL_PATH. This applies only for the running execution of reveal-init.
  • "2": Set a value for $REVEAL_PATH. Another prompt will appear and you have to enter the desired value for REVEAL_PATH. If the entered path does not exit, the program stops.
  • "3": Stop the program and set a value for REVEAL_PATH (e.g. with export).

Any invalid value will cause reveal-init to stop running.

Another possible cause for the problem is a change in environment and (as a consequence) the environment variables. The following Shell session demonstrates this (the prompt string is "$"):

$ whoami
you_create
$ echo $REVEAL_PATH
/home/you_create/Projects/Forks/reveal.js
$ sudo whoami
root
$ sudo sh /home/you_create/.local/bin/reveal-init barebone
WARNING REVEAL_PATH is not set.
. . .

Make sure REVEAL_PATH is set when you change to a different terminal environment. When running sudo, for example, the REVEAL_PATH variable can be kept by using the --preserve-env option:

sudo --preserve-env=REVEAL_PATH sh /home/you_create/.local/bin/reveal-init barebone

Technical information

if [ -z "$REVEAL_PATH" ]; then
    warn "\$REVEAL_PATH is not set"
    echo "reveal-init won't work without \$REVEAL_PATH, what now?"
    echo "    1: Use the current directory as \$REVEAL_PATH (temporary)"
    echo "    2: Set a value for \$REVEAL_PATH (temporary)"
    echo "    3: Abort and set a permanent value for \$REVEAL_PATH"
    read -p "[1|2|3] " option
    echo $option

    case "$option" in
        "1")
            echo "Okay, \$REVEAL_PATH is the current directory"
            REVEAL_PATH="."
            ;;
        "2")
            read -p "\$REVEAL_PATH: " REVEAL_PATH
            [ -z "$REVEAL_PATH" ] && fatal "Invalid value for \$REVEAL_PATH"
            ;;
        "3")
            echo "Then go set a value for it with 'export'"
            echo "Aborting..."
            exit 1
            ;;
        *)
            echo "$option"
            fatal "Invalid option, aborting.."
            ;;
    esac
fi
No theme found

Solution

That means, either no theme is presented in $REVEAL_PATH/css/theme, or $REVEAL_PATH/css/theme does not exist. Make sure the directory is presented and there are themes presented in it as CSS files.

Note: The warning may still appear even if you don't choose to have a theme. In such a case, you can ignore the warning. But seriously, what's a slide deck without a theme?

Technical information

! [ -d "$REVEAL_PATH"/css/theme ] || [[ -z $(ls -A "$REVEAL_PATH"/css/theme) ]] && \
    warn "No theme found" && theme="-"
[$REVEAL_PATH]/lib/js/head.min.js not found, plugins won't be loaded

Solution

Make sure $REVEAL_PATH/lib/js/head.min.js is presented. It is included in every untouched clone of the Reveal.js repository. head.min.js is required to get plugins workin'. If it is not presented, reveal-init will ignore the plugins you've listed with --plugin or --plugins.

Technical information

! [ -f "$REVEAL_PATH"/lib/js/head.min.js ] && \
    warn "$REVEAL_PATH/lib/js/head.min.js not found, plugins won't be loaded" && \
    plugins="-"
No plugin found

Solution

Make sure there are plugins presented in $REVEAL_PATH/plugin as directories. In each of those directories, there must be a main JavaScript file to be loaded from in index.html.

Technical information

  • Before reveal-init 2.1:
! [ -d "$REVEAL_PATH"/plugin ]
  • reveal-init 2.1 and beyond:
! [ -d "$REVEAL_PATH"/plugin ] || [[ -z $(ls -A "$REVEAL_PATH/plugin") ]]
Failed to get plugin [plugin]'s JavaScript file to load from, please do this manually

Solution

Every Reveal.js plugin is (and should be) presented as a directory that contains the plugin's JavaScript file to load from (called the main JavaScript file) and possibly other assets like images, README, license, etc.. The warning pops up if reveal-init can't find the main JavaScript file. If you don't ever want to get this warning message, name every plugin's main JavaScript file "index.js", but care should be taken when doing this if there exist other files that refer to the JavaScript file with its original name.

In conclusion, one practical action to do when this warning message is encountered is to manually edit the index.html file so that the plugin gets loaded.

Technical information

Assume a plugin's name is plugin-js. reveal-init attempts to search the plugin's main JavaScript file by checking if any of these files exists (listed in order):

  • plugin-js.min.js
  • plugin-js.js
  • plugin.min.js
  • plugin.js
  • plugin.min.js (in this case, a duplicate)
  • plugin-js
  • script.js
  • index.js

Code here (version 1.1 RC and up):

# Guess plugin's index JavaScript file from the plugin's directory name

posb_fname=("$plugin.js" "${plugin:0:${#plugin}-3}.js" "$plugin" "script.js" "index.js")

for tfname in ${posb_fname[@]}
do
    if [[ -f "$dirname"/plugin/$plugin/${tfname:0:${#tfname}-3}.min.js ]]
    then
        js_indexf=${tfname:0:${#tfname}-3}.min.js
        break
    elif [[ -f "$dirname"/plugin/$plugin/$tfname ]]
    then
        js_indexf=$tfname
        break
    fi
done

if [ -z $js_indexf ]; then
    warn "Failed to get plugin '$plugin''s JavaScript file to load from, please do this manually"
    continue
fi

Errors

Theme [theme] ([$REVEAL_PATH]/css/theme/[theme].css) not found

Solution

  • Make sure the theme is presented in $REVEAL_PATH/css/theme/ as a CSS file.
  • Specify the theme's name correctly. Valid inputs to the -f or the --theme options can be listed line-by-line by using find like so:
find $REVEAL_PATH/css/theme -type f -name "*.css" -exec basename -s .css {} ';'

Technical information

. . .
elif [ -f "$REVEAL_PATH"/css/theme/$1.css ]; then
    theme="$1"
else
    err "Theme '$1' ($REVEAL_PATH/css/theme/$1.css) not found"
. . .
Plugin [plugin] ([$REVEAL_PATH]/plugin/[plugin]) not found

Solution

  • Make sure all plugins specified are presented in $REVEAL_PATH/plugin/ as directories. If you have a plugin that is presented in the plugin/ directory as a JavaScript file, place it in a new folder instead.(*)
  • Specify the plugins' names correctly. Accepted names can be listed line-by-line using the following Shell command:
find $REVEAL_PATH/plugin -maxdepth 1 -type d -not -name "plugin" -exec basename {} ';'

(*): Although it seems that Reveal.js plugins don't have to be presented as directories, reveal-init recognizes only those that are presented as directories, even in the current latest stable release. This is considered to be a reveal-init's problem and it will be fixed soon.

Technical information

[ -d "$REVEAL_PATH"/plugin/$1 ] \
  && [[ $plugins != "-" ]] && plugins="$plugins$1 " \
  || err "Plugin '$1' ("$REVEAL_PATH"/plugin/$1) not found"
-n: Invalid input for number of slides, option ignored

Solution

Only positive integers are accepted.

Technical information

A regular expression is used to detect if the input is a positive integer.

[[ $1 =~ ^[0-9]+$ ]] \
  && n_slide=$1 \
  || err "-n: Invalid input for number of slides, option ignored"
[$REVEAL_PATH]/css/reveal.css not found

Solution

Make sure $REVEAL_PATH/css/reveal.css exists.

Technical information

! [ -f "$REVEAL_PATH"/css/reveal.css ] && err "$REVEAL_PATH/css/reveal.css not found"
[$REVEAL_PATH]/js/reveal.js not found

Solution

Make sure $REVEAL_PATH/css/reveal.css exists.

Technical information

! [ -f "$REVEAL_PATH"/js/reveal.js ] && err "$REVEAL_PATH/js/reveal.js not found"

Fatal

Directory name not given.

Solution

The message is triggered if you don't give reveal-init command line arguments. To solve the problem:

  • Specify a generic option, like -h or -v:
reveal-init -h
reveal-init --help
reveal-init ?
reveal-init -v
reveal-init --version
  • Specify an output directory (either as the only argument or as the last argument). This is where reveal-init will copy files to. Additionally, specify non-generic options such as -n, --git, --theme:
reveal-init barebone
reveal-init -f league --title "An example slide deck" --header _TITLE example

Technical information

[ $# -eq 0 ] && \
    fatal "Directory name not given.\nInvoke '--help' for more information"
Directory [...] exists

Solution

This means that the directory you want to initiate your new slide deck in is already presented. Try a different directory name or remove the presented directory.

Technical information

[ -d "$1" ] && err "Directory '$1' exists" && exit 1
Invalid option [option], aborting...

Solution

This means you've given reveal-init an invalid option that reveal-init refuses to take. To see all valid options, refer to the help information by running:

reveal-init -h

Technical information

for arg in "$@"
do
    . . .

    case $opt in
        . . .
        *)
            case $1 in
                "-d" | "-t" | "-title" | "--title" | "-f" | "-theme" | "--theme" \
                | "-plugin" | "--plugin" | "-plugins" | "--plugins" \
                | "-header" | "--header" | "-n")
                    opt=$1;;
                "--git")
                    [ -z $(command -v git) ] \
                        && warn "--git: Git is not installed, option ignored" \
                        || git="true"
                    ;;
                "--short-tab") t="  ";;
                "--long-tab") t="    ";;
                *) fatal "Invalid option '$1', aborting..." && exit 1;;
            esac
            ;;
    esac
    shift
done

Appendix: Reveal.js repository's Directory Structure

This is the unmodified directory structure of the Reveal.js repository. Some parts are omitted. reveal-init assumes that the repository's clone on your computer strictly follows the directory structure.

Elements in bold text are required at all times. Elements in italics & bold may be required in certain situations (e.g. plugin/ is in italics & bold because it is not necessary if you don't wish to use any plugin).

  • index.html: Contains the slide deck's content.
  • css/: Contains the primary stylesheet, themes, and some other things.
    • reveal.css: The slide deck's primary stylesheet]
    • theme:
      • CSS files: Loadable themes, given as CSS files
      • source/: The SCSS source of the themes
      • template/: Contains necessary files to create a custom theme
    • print/: Necessary files to be used for PDF-exporting
  • js/:
    • reveal.js: The primary JavaScript file
  • plugin/: Contains Reveal.js plugins, usually presented as directories. Each plugin must present a main JavaScript file that will be loaded when the slide deck is opened
  • lib/: Contains CSS & JS libraries, as well as other assets like fonts
    • css/
      • zenburn.css: highlight.js's theme for code syntax highlighting
    • js/
      • head.min.js: Required to load Reveal.js plugins