Petros Amiridis My Internet home.

Segmentation fault with sqlite3 and Rails console on macOS Sierra

I was trying to demonstrate some basic Active Record commands using the Rails console yesterday during the MSc Class I am teaching. I fired up the console as usual bin/rails console, and tried to create an instance of one of the models I had created, and got this:

Loading development environment (Rails 5.0.0.1)
irb(main):001:0> Task.new
.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:27: [BUG] Segmentation fault at 0x00000000000110

I couldn’t figure out what the problem was at that point. But today, I searched for a solution.

Here is what I have found so far:

  • That’s related to macOS Sierra and the default sqlite installation
  • The default sqlite does not play well with processes that fork it in memory
  • The solution is to install sqlite3 using brew
  • Uninstall any sqlite3 gems and install them again to pick up the new version

For my particular situation (I am using rbenv, bunlder, Ruby 2.3.1, and Rails 5.0.0.1) here is what worked:

brew update
brew install sqlite3 # At this point I restarted my terminal
cd into-my-rails-project-that-had-the-problem
gem uninstall sqlite3
bundle update

and it worked:

Loading development environment (Rails 5.0.0.1)
irb(main):001:0> Task.new
=> #<Task id: nil, title: nil, created_at: nil, updated_at: nil>
irb(main):002:0>

If my post saved your bacon, please don’t hesitate to let me know. :)

Autumn Saturday

I am sitting in my kitchen, drinking coffee and reading articles. I feel a bit chilly. It’s the time of the year in Greece when the sun still shines but isn’t working like it used to in August. It’s both unpleasant and cozy. You can’t pick one feeling over the other. When you try to pick unpleasant, cozy takes over and vice versa.

As I am enjoying my Saturday I am thinking about GitHub and life. It’s easy to get lost in what doesn’t work well. It’s easy for what doesn’t work well to appear on the surface. It takes effort to focus on what works well. We take it for granted.

Just some Saturday thoughts.

If you have similar thoughts, let me know.

Day one

Trying to revive my site starting with this post.

I have added a now page you can view here:

http://amiridis.net/now

This is not my idea. I have stolen it from Derek Sivers.

I hope you will be able to see what I am focusing on at any given point in time. I also hope I can go back read it and refocus if I start diverging.

Thoughts? Let me know.