Skip to content
Go back

HOWTO install s3_website on macOS

| Last edited: Yesterday

While converting my various websites to hugo static sites, I looked at various ways to push my local changes to production. Ultimately, I chose s3_website as the best choice for my setup. The tool is static site generator agnostic so works well with jekyll, middleman, hugo and others but in case you are curious, the tech stack I use is:

Installing s3_website on macOS

Installing s3_website on macOS requires a few dependencies so I wanted to document them here for anyone else interested in using it. Note: this article only covers the installation of s3_website so you will still have to configure it for your specific website.

Install rbenv on macOS

Like most folks, I started out following the directions from the s3_website repo README file (gem install s3_website) and immediately hit a snag (on a fresh macOS High Sierra 10.13.6 install):

{{< highlight bash >}} hiro@h42:~|⇒ gem install s3_website Fetching: thor-0.20.0.gem (100%) ERROR: While executing gem … (Gem::FilePermissionError) You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory. {{< /highlight >}}

At first, I tried a few solutions like using the --user-install options but ran into issues further down the line. Ultimately, it make sense to install a ruby environment manager like rbenv to update user install ruby runtimes but not change the system install.

To install rbenv, let’s use brew:

{{< highlight bash >}} $ brew install rbenv {{< /highlight >}}

then initialize it (which will provide shell specfic directions, in my case zsh):

{{< highlight bash >}} $ rbenv init

Load rbenv automatically by appending

the following to ~/.zshrc:

eval ”$(rbenv init -)” {{< /highlight >}}

Go ahead and add that eval line to the end of your shell’s rc file. Next, check your install with rbenv-doctor:

{{< highlight bash >}} $ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash {{< /highlight >}}

which will then request that you install a ruby version. At this time, it suggest ruby v2.2.4 but you can google for the latest version and use that:

{{< highlight bash >}} $ rbenv install 2.5.1 {{< /highlight >}}

Almost done. For simplicity, I do actually set the global ruby version to the freshly isntalled 2.5.1:

{{< highlight bash >}} $ rbenv global 2.5.1 {{< /highlight >}}

Then restart my shell and viola:

{{< highlight bash >}} hiro@metaverse:~|⇒ ruby —version ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16] {{< /highlight >}}

Install s3_website on macOS

Now go ahead and install the s3_website gem:

{{< highlight bash >}} $ gem install s3_website {{< /highlight >}}

and then run the built in install command:

{{< highlight bash >}} s3_website install {{< /highlight >}}

At this point, you need to configure s3_website for your website. Then when you try the --dry-run option you’ll hit your next issue:

{{< highlight bash >}} hiro@metaverse:~/git/mfio|master⚡ ⇒ s3_website push —dry-run No Java runtime present, requesting install. {{< /highlight >}}

Install jEnv on macOS

However, at this time, s3_website isn’t compatible with Java 10 (the version you will get with a standard brew install) so you have to install the older Java 8 runtime. Since w already went down the path of installing a ruby environment manager, might as wll do the same for Java. Enter jEnv, which is pretty straight forward to install:

{{< highlight bash >}} $ brew install jenv {{< /highlight >}}

and then setup in your shell (zsh in this case):

{{< highlight bash >}} $ echo ‘export PATH=“$HOME/.jenv/bin:$PATH”’ >> ~/.zshrc $ echo ‘eval ”$(jenv init -)”’ >> ~/.zshrc {{< /highlight >}}

Next we use brew to install the current and older versions of Java:

{{< highlight bash >}} $ brew cask install java $ brew tap caskroom/versions $ brew cask install java8 {{< /highlight >}}

add these to jEnv so it knows about the runtimes:

{{< highlight bash >}} jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/ jenv add /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/ {{< /highlight >}}

then change into your website directory (where you s3_website.yml file is) and run this command:

{{< highlight bash >}} jenv local 1.8 {{< /highlight >}}

Running s3_website

You’re finally ready! As I mentioned before, I always start by running s3_website with the --dry-run option to make sure everything looks correct for the push to production. Common things I foget to do are to remove and re-build the website with hugo or to set the environment variables for my AWS account. But hopefull your s3_wbsite setup will now work on macOS.


Share this post on:

Previous Post
HOWTO setup a private git server on Ubuntu 18.04
Next Post
Password Hints Can Be a Good Thing