Upgrading to Ruby 2.2; General Installation OS X

(Andrés N. Robalino) #1

We decided to try out Discourse and see how complex it would be to get it up and running on OS X. Our goal is to make Discourse installation as easy as possible for any user running a Mac, either for development or just to try it out and show it to people.

After hours having patience we were able to get it up (Initially Ruby 2.1.5-p273). We tried different Ruby builds (static builds) but most of the time the goal was to boot the app. This means that lots of tests failed.

We finally did a static build of Ruby 2.2.0-p0 (released yesterday) and booted successfully.

Looking at high number of failing tests had me uneasy, though. Started following the instructions for advanced developers and the OS X specific instructions. A surprise we had was that Discourse can’t work if one tries Ruby 2.2.0 (this can be addressed, we made minor changes to Discourse’s Gemfile and Gemfile.lock for this)

Without much options left, we decided to rebuild another Ruby (2.1.3-p242) and try it out. We were able to boot Discourse and have all tests passing.

The Tokaido we are going to release either today or tomorrow will come with Ruby 2.2.0-p0 and Rails 4.2.0.

We care about making everyones live easier to get up and running with Discourse. We will release this Tokaido with the ‘convert’ binary that Discourse uses, Redis binary, Postgres.app detection, and the mail catcher gem.

My question is, what are the plans for upgrading Discourse to Ruby 2.2.0? I’m currently trying to get the tests passing. So far I have noticed conflict with the freeze_time mocker on spec_helper and I’m not sure where it comes from, perhaps problems with mocha/api and Ruby 2.2.0? I changed the helper method slightly and brought the failing tests down a bit, still got 2 failing out of the 3953 examples.

It would be nice to learn the state of this. If anyone would like to try Discourse on Ruby 2.2.0 you need to do the following:

// You need Xcode
// (needed for qunit tests) Install PhantomJS (you can install it directly with homebrew, or you could use homebrew to install nodejs first and then run $ npm install -g phantomjs)

// manually first
Download Postgres.app (search the web)
$ gem install stackprof --no-ri --no-rdoc
$ gem install memory_profiler --no-ri --no-rdoc
$ gem install mailcatcher --no-ri --no-rdoc

In your Gemfile
gem 'stackprof', require: false, platform: :mri_21
gem 'memory_profiler', require: false, platform: :mri_21
gem 'stackprof', require: false, platform: :mri
gem 'memory_profiler', require: false, platform: :mri

// In your Gemfile.lock
Find rbtrace (0.4.5) and replace to rbtrace (0.4.6)
Open Postgres.app

Run $ redis-server (separate shell)
Run $ mailcatcher (separate shell)

cd to your discourse directory and run:

$ bundle
$ bundle exec sidekiq (separate shell)
$ bundle exec rake db:create db:migrate db:test:prepare
$ (optional) bundle exec autospec
$ bundle exec rails server

(Sam Saffron) #2

Thanks for the tips, I’ll get it working Australia monday

(Andrés N. Robalino) #3

No problem, Sam.

Here is the hack that I did to get rid of 6 failing tests. The remaining 2 failing examples are listed there too.

Before reaching this point, I noticed a couple of things. For instance, the document titled Developing under OS X Without Vagrant seems outdated.

  1. The instructions to prepare the database, rake db:seed_fu seems unnecessary because rake db:migrate already invokes the seeder (so you are seeding twice)
  2. With Postgres.app, not much configuration is needed as long as you add Postgres.app’s bin path first.

Other things to note:

  • rake db:test:prepare is deprecated. spec_helper, however,
    does not have the code to call ActiveRecord’s Migration checker.
  • When running the specs (bundle exec rake autospec) I see
    Seeding uncategorized category!
  • Before running the tests I always have to run redis-cli flushall; bundle exec rake db:reset autospec, without flushing redis, I get
    random failures.

These three warnings before specs are ran:

/Users/andras/.tokaido/Gems/gems/fog-core-1.24.0/lib/fog/core/collection.rb:148: warning: circular argument reference - filters

/Users/andras/.tokaido/Gems/gems/fog-1.22.1/lib/fog/rackspace/mock_data.rb:42: warning: duplicated key at line 80 ignored: "name"

/Users/andras/.tokaido/Gems/gems/htmlentities-4.3.2/lib/htmlentities/mappings/expanded.rb:465: warning: duplicated key at line 466 ignored: "inodot"

I’d be more than happy to contribute the instructions for developing under OS X without Vagrant. Perhaps would be useful another document for developing with Tokaido too.

(Sam Saffron) #4



(Sam Saffron) #5

Raised this issue with PG


(Sam Saffron) #6

At this point I am tempted to simple leave 2.2 as sort-of-working while upstream figures out what to do.

(Andrés N. Robalino) #7

Oh my. See what have we done, Sam? :smile:

We haven’t released yet. Ideally we’d like to release it once Discourse runs Ok (without the gem installs, Gemfile and Gemfile.lock instructions I listed first) with 2.2 (for testing purposes). Would it be reasonable if we could open a thread (or this same one) asking the community to try out the unreleased Tokaido and report the experience?

I’d be more than happy to upload the binary.

(Sam Saffron) #8

I don’t recommend 2.2 for mass consumption until the last niggling issues are resolved.

Historically all the Ruby p0 releases have been flawed, 1.9.3p0 / 2.0.0p0 and 2.1.0, considering 2.2.0 ships with some very big infrastructure changes (symbol gc, incremental gc, new uri parser) I would strongly recommend holding off 2.2 till at least 2.2.1 unless you are comfortable applying patches against Ruby.

Discourse is going to have to be slightly buggy until pg release a new stable gem (they are shipping a year old gem) and the uri parsing issue gets some level of resolution.

Additionally bundler does even ship with :mri_22 which means you need to hack up gemfiles with horrid monkey patches.

(Andrés N. Robalino) #9

Thanks. Will check and see if we could do two separate releases then (2.1.5, 2.2)

(Carlos Castellanos Vera) #10

Has anybody tested discourse with ruby 2.2.1?. Do you recommend it for production environments?

(Sam Saffron) #11

not yet, I do plan to experiment with it in the upcoming months.

(Erick Guan) #12

Bundler regression for mirror setting.