User:Woozle/Mastodon/setup/take 2

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< User:Woozle‎ | Mastodon‎ | setup
Revision as of 12:19, 31 December 2017 by Woozle (talk | contribs) (extracting "part"s into subpages)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

part 1

  • Is there a better way to install "yarn"? I got a message saying "npm WARN deprecated yarn@0.22.0: It is recommended to install Yarn using the native installation method for your environment. See https://yarnpkg.com/en/docs/install" -- but then it seemed to work anyway... From the link, it looks like I'd be advised to set up the repository. Will do that at some point.
  • The postgres (v9.5 (9.5.6-0ubuntu0.16.04)) installation generated about a dozen copies of this message: "Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78."
  • Tentatively, when it says "Under Ubuntu 16.04, you will need to explicitly enable ident authentication so that local users can connect to the database without a password", the "local users" are not users of the Mastodon app but the user(s) setting up and administering Mastodon who might need to do various operations in Postgres. The previous line seems to create a single Postgres user named "mastodon", heavily implying that yes, the app itself only needs the one db user. Possibly the whole business with identd could, theoretically, be skipped by setting up a password...
  • Another message which doesn't seem to have prevented anything from working:
pidentd.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable pidentd
  • When I got to the step about installing rbenv, I had to break off and install Webmin because that's the easiest way for me to manage users, and I needed to create a "mastodon" user:
    • <bash>dpkg -i webmin_1.831_all.deb</bash>
    • This generates dependency errors. To fix them:
    • <bash>apt -f install</bash>
    • ...and then I had to look up how to add a user from the command line so I could log in, and ended up just creating the mastodon user (and group) manually:
    • <bash>adduser --system --group mastodon</bash>
    • That command needs a little tweaking, because it defaults to disallowing login (shell is /bin/false). I had to change it to /bin/bash via Webmin.
  • Apparently the standard setup expects you to clone rbenv into ~/.rbenv rather than ~/rbenv. I don't know why it needs to be hidden; I used ~/rbenv which required minor tweaking of subsequent command(s). (Later note: apparently some stuff is hardwired to use .rbenv; this might explain problems I had with it after this.)
  • Turns out gcc is not installed by default; backed out to root, installed it, su mastodon, resume...
  • ...and again for make...
  • Note that the "export" command doesn't take effect until the next login -- so you have to log out to root and then log back into mastodon again...

I keep getting this message when I try to run bin/rbenv init:

# Load rbenv automatically by appending
# the following to ~/.bashrc:

eval "$(rbenv init -)"

I think I have to assume that this is advisory and not an actual error; I've done exactly as it asks, and still get the message.

...but ultimately, "rbenv isntall --list" said I didn't have rbenv installed, and suggested I install it from apt. (Why didn't you say so??)

...which ultimately led me to the question: why install Ruby via rbenv when I can just install it via apt? So I tried that... and found that it was already installed (presumably happened earlier in the instructions). So maybe rbenv just gives you better control over which version of Ruby is in use? Since I have as yet no reason to prefer anything but the most recent stable version, this control is not yet of any use.

...but wait: the instructions say the correct version for Mastodon is 2.4.1. What I have is 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]. We'll see if that's a problem...

And then this happens, and I think I need to take a break:

mastodon@cloud5:~/live$ gem install bundler
Fetching: bundler-1.14.6.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.3.0 directory.
mastodon@cloud5:~/live$ exit
exit
root@cloud5:~# gem install bundler
Fetching: bundler-1.14.6.gem (100%)
Successfully installed bundler-1.14.6
Parsing documentation for bundler-1.14.6
Installing ri documentation for bundler-1.14.6
Done installing documentation for bundler after 6 seconds
1 gem installed
root@cloud5:~# bundle install --deployment --without development test
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
Could not locate Gemfile
root@cloud5:~# su mastodon
mastodon@cloud5:/root$ bundle install --deployment --without development test
Could not locate Gemfile
mastodon@cloud5:/root$ cd ~
mastodon@cloud5:~$ bundle install --deployment --without development test
Could not locate Gemfile
mastodon@cloud5:~$ 

So I'm not supposed to run bundler as root, but when logged in as "mastodon", it can't find the gemfile. (Presumably it's somewhere outside of userland, where "mastodon" can't see it -- but who knows where. Running the "bundle install" command from /var/lib/gems/2.3.0/gems/bundler-1.14.6, /var/lib/gems/2.3.0/gems, /var/lib/gems/2.3.0, and /var/lib/gems produces the same result.)

Maybe it was expecting me to install the gem as "mastodon", but I couldn't. Maybe this is why you have to manually install Ruby using rbenv as user "mastodon"? Do I want to spend the time trying to find out?

Well, okay...

mastodon@cloud5:~$ rbenv install 2.4.1
Downloading ruby-2.4.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.bz2
Installing ruby-2.4.1...

...and there it sits, and all I can do is wait and see if it does anything before the connection times out.

part 2

It finally did complete:

Downloading ruby-2.4.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.bz2
Installing ruby-2.4.1...

BUILD FAILED (Ubuntu 16.04 using ruby-build 20170405)

Inspect or clean up the working tree at /tmp/ruby-build.20170423203550.27878
Results logged to /tmp/ruby-build.20170423203550.27878.log

Last 10 log lines:
installing rdoc:              /home/mastodon/.rbenv/versions/2.4.1/share/ri/2.4.0/system
installing capi-docs:         /home/mastodon/.rbenv/versions/2.4.1/share/doc/ruby
The Ruby readline extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Try running `apt-get install -y libreadline-dev` to fetch missing dependencies.

Configure options used:
  --prefix=/home/mastodon/.rbenv/versions/2.4.1
  LDFLAGS=-L/home/mastodon/.rbenv/versions/2.4.1/lib 
  CPPFLAGS=-I/home/mastodon/.rbenv/versions/2.4.1/include 

I then installed libreadline-dev (as root) and tried to re-run "rbenv install 2.4.1" as "mastodon", but got "/usr/bin/rbenv: line 20: cd: /root: Permission denied". So then I ran rbenv as root, and that appears to have succeeded.

So, now we're re-trying "gem install bundler"... doesn't work as "mastodon", but does work as root:

mastodon@cloud5:~/live$ gem install bundler
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.3.0 directory.
mastodon@cloud5:~/live$ exit
exit
root@cloud5:~# gem install bundler
Successfully installed bundler-1.14.6
Parsing documentation for bundler-1.14.6
Done installing documentation for bundler after 5 seconds
1 gem installed

And now "Fill in the important data, like host/port of the redis database, host/port/username/password of the postgres database..." -- Did I even install redis? Where do I find the port? Where do I find port/username/password for postgres? I'll have to come back to this.

part 3

Finally noticed the earlier section for Ubuntu 16.04 where it tells you how to create the Postgres db. Apparently it was already created, and pidentd is configured to let local users use it without a password. Why this is a good idea, I don't know... but apparently there's no password.

Then we get to the bit in .env.production where it says to generate secrets using "rake secret":

root@cloud5:/home/mastodon/live# rake secret
Could not find activesupport-5.0.2 in any of the sources
Run `bundle install` to install missing gems.
root@cloud5:/home/mastodon/live# bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.

...does a bunch of stuff...

Using rack-protection 1.5.3
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/nio4r-2.0.0/ext/nio4r
/usr/bin/ruby2.3 -r ./siteconf20170522-3453-l5lu92.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nio4r-2.0.0 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-2.0.0/gem_make.out

An error occurred while installing nio4r (2.0.0), and Bundler cannot continue.
Make sure that `gem install nio4r -v '2.0.0'` succeeds before bundling.
root@cloud5:/home/mastodon/live# su woozle
woozle@cloud5:/root$ cd /home/mastodon/live
woozle@cloud5:/home/mastodon/live$ rake secret
Could not find activesupport-5.0.2 in any of the sources
Run `bundle install` to install missing gems.
woozle@cloud5:/home/mastodon/live$ bundle install

...asks for my password twice, does a bunch of stuff...

Using rack-protection 1.5.3
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /tmp/bundler20170522-3646-1tm2wbtnio4r-2.0.0/gems/nio4r-2.0.0/ext/nio4r
/usr/bin/ruby2.3 -r ./siteconf20170522-3646-1vnz3ib.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20170522-3646-1tm2wbtnio4r-2.0.0/gems/nio4r-2.0.0 for inspection.
Results logged to /tmp/bundler20170522-3646-1tm2wbtnio4r-2.0.0/extensions/x86_64-linux/2.3.0/nio4r-2.0.0/gem_make.out

An error occurred while installing nio4r (2.0.0), and Bundler cannot continue.
Make sure that `gem install nio4r -v '2.0.0'` succeeds before bundling.
woozle@cloud5:/home/mastodon/live$ gem install nio4r -v '2.0.0'
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.3.0 directory.
woozle@cloud5:/home/mastodon/live$ sudo gem install nio4r -v '2.0.0'
Building native extensions.  This could take a while...
ERROR:  Error installing nio4r:
	ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/nio4r-2.0.0/ext/nio4r
/usr/bin/ruby2.3 -r ./siteconf20170522-3790-48r61c.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nio4r-2.0.0 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-2.0.0/gem_make.out
woozle@cloud5:/home/mastodon/live$

At this point, I have no effing idea.

part 4

Running "apt install ruby-dev" broke the logjam... but then I ran into a new error:

Make sure that `gem install unf_ext -v '0.0.7.3'` succeeds before bundling.

Okay... woozle@cloud5:/home/mastodon/live$ gem install unf_ext -v '0.0.7.3'

Fetching: unf_ext-0.0.7.3.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.3.0 directory.
woozle@cloud5:/home/mastodon/live$ sudo gem install unf_ext -v '0.0.7.3'
Building native extensions.  This could take a while...
ERROR:  Error installing unf_ext:
	ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/unf_ext-0.0.7.3/ext/unf_ext
/usr/bin/ruby2.3 -r ./siteconf20170522-25866-9iissq.rb extconf.rb
checking for main() in -lstdc++... yes
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.3/mkmf.log

current directory: /var/lib/gems/2.3.0/gems/unf_ext-0.0.7.3/ext/unf_ext
make "DESTDIR=" clean

current directory: /var/lib/gems/2.3.0/gems/unf_ext-0.0.7.3/ext/unf_ext
make "DESTDIR="
compiling unf.cc
make: g++: Command not found
Makefile:207: recipe for target 'unf.o' failed
make: *** [unf.o] Error 127

make failed, exit code 2

Gem files will remain installed in /var/lib/gems/2.3.0/gems/unf_ext-0.0.7.3 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.3/gem_make.out

Contents of mkmf.log are unenlightening. "make: g++: Command not found" suggests that maybe gcc isn't installed, but it is, so I've no idea which command is not found.

part 5

Apparently gcc is not g++. There is a separate g++ command, which is in the "g++" package. "apt install g++" fixes this.

The next sticking point is this:

Couldn't create database for {"adapter"=>"postgresql", "pool"=>5, "timeout"=>5000, "encoding"=>"unicode", "database"=>"icmstdn", "username"=>"mastodon", "password"=>(redacted), "host"=>"localhost", "port"=>5432, "prepared_statements"=>true}
rails aborted!
PG::ConnectionBad: FATAL: Ident authentication failed for user "mastodon"

I tried it first without a password, as in the instructions, but that had the same problem.

For reference: Stack Overflow Ubuntu