January 2, 2015 #thoughts

I consider myself strict at spending money. I would choose a station in 20 minutes walk distance over a 3 minutes one just to save less than 200 JPY yen. I would bypass a vending machine even though I’m thirsty but not buying a bottle of water. I would go into bathroom without turning on the light, and choose wearing more clothes rather than turning on underfloor heat to save electricity expense, the list goes on and on… (most of these habits are inherited from my parents, saving money is like a gene inside their body)

Some time ago I randomly picked up a book in bookstore, one chapter was about saving money. Can’t remember the exact word, but the general idea is this:

People who have the habits of saving money, tend to buy more and/or expensive stuff than they need, have low resist to the temptation, because they don’t know the joy of spending money, they think they have been suffered enough that they so deserve to have that one item.

That rings a bell. I do remember I say something like that to myself in the past when struggling with buy or not buy situation.

“Come on you’ve been working so hard, you definitely deserve this!”

“Look at others, see how they’ve spent money on drinks, clothes, parties, no harm to indulge yourself a bit this time!”

“It’s 50% off sale, you’ve got to buy something for yourself right?!”

And things I’ve bought under that mindset usually turns out to be a total waste: either I don’t like it, not using it anymore(like clothes), or over spec that’s higher than my need(pc parts).

Since I realized this pitfall, I’ve been really conscious about the conversations with myself. I stopped using the word “deserve”. Now it looks like this: “I choose to spend the money because of …, so that I could …, I’m 100% it’ll contribute to my …, I know it’s a clear YES, it’s a worthwhile investment, not because I deserve it, not because it’s on 30%, 50% or even 80% sale, not because I feel shy to say NO.”

I could be spending more money overall on food, books, self investment now than before, but that’s my rational choice & investment under conscious mind, with a purpose on health, learning, and self growth. Most importantly, I don’t feel the urge to indulge myself, the guilty when spending money anymore.

January 2, 2015 #diary

2014 has passed, this is the perfect season to write a personal review post. This one is organized in the perspective of family, relationship, friends work and self development.

Family

At the end of 2014 I took some day off and came back to China to visit my mom and dad. Probably 3 years since our last met.

As always my mom prepared everything for me: new clothes and coat, cloves, shoes(-20 degree in my hometown), good foods, money for me to use here… She kept all the gifts in the perfect shape I gave her before, always seek to connect, always support me… Amazingly I really can’t find any flaws from her as a mother, she’s perfect.

My dad is the same, so unique in his own way… I’m not a good talker just like him, we don’t talk that much, and don’t feel the urge to, which made me really relaxed, felt home. Sometimes I take the initiative and tell him my life in Tokyo, and after my talk he either suddenly leaves without a comment or change the subject completely to something he wants to talk about… And we’re totally fine about spending the time separately even though we’re in the same room, he checks his computer while I write blog, just like the old days.

Strangely for one moment I dreamed about, what if, what if they didn’t get divorced, how would it look like now? What if I look at the left there’s my mom, and turn right there’s dad? I know it’s 200% impossible already, but this is the first time for the last 10+ years I imagined such scene and I kinda want to say, “please don’t wake me up”.

Relationship

I remember early 2014 we were sitting at the dining table in our brand new house, having afternoon tea and cakes, enjoying the beautiful view from 27th floor and sharing stories to each other. That was such a peaceful picture in my memory, I wish I could freeze the time forever, I thought after all these years we finally managed to get the harmony moment, but we didn’t.

After that our relationship hit the bottom, it was the darkest time for me. I suffered a lot from distrust, every couple have fights and may even say some harsh words too, but nothing hurt more than distrust. I felt my character, loyalty and integrity was doubted, it made me feel all the things I had been fighting for was nothing, worthless. I started to ask the wrong questions. “Why me? Why shit things always happen to me? Why I can’t have a peaceful day? I’m not a perfect boyfriend but also not a bad guy shouldn’t I deserve a little better? Why I did nothing but is treated like I was cheating on her? It’s so unfair why?”

Question shifts focus. Asking the wrong questions could only drive you crazy, making all possible negative impacts, so stop. Pain is a powerful tool, if you can make good use of it. There’s a technique introduced in the book “Awaken the Giant Within”, saying if you want to quit your bad habit, you should link massive pain to that. In my case this trust issue was such a huge pain for me I don’t want to experience it anymore, ever. So I tweaked the questions like this:

“What’s the root cause? Am I misbehaved? Or lack of communication makes me appear suspicious? Is it related to our past issue? Is it her issue? Is it fixable? What could I do now on my side? What are my choices?”

Immediately my focus shifted to the present, and helped me made a big decision then. I’ll leave all that pain to 2014, 2015 I will have a better, brighter life.

Friends

I like to hang out with friends, but not doing good job at inviting them. Always reluctant to send the message. 8:00 AM, maybe they’re on the train. 10:00 AM they must be working. 12:00 AM they’re probably having lunch with colleagues. 6:00 PM, hmm maybe working hard to get things done. 8:00 PM maybe they’re enjoying dinner with family/friends. 10:00 PM maybe too late… I’m such a genius to find no good time to contact during a whole day lol!

And even though I’ve been living in Tokyo for 7 years, I still don’t get the distance with Japanese friends(not those have experience abroad). I consider some are good friends, but not sure how they feel about me, the distance is still there. Don’t get me wrong they’re good people, polite and kind, but that also confused me about where we are, and how to develop it to the next level.

On the contrary, I’m glad the “gaijin” group get together regularly. BBQ, Chicago Pizza, fireworks, Bounenkai. The psychological guard is low, people are more open, more casual, easier to talk to.

Also appreciate my friends in China. Every time I come back, they all manage to come no matter how busy they’re, give me the welcome party and farewell party within 1 week, I’m flattered. I’ve known each other for over 10 years, I’ve seen them from slim to fat hah, from a boy to a father, yet we still drink like a teenage, talk in the same way, as if time never passed us.

Work

One big challenge was building Cooksnaps widget which is integrated to food blogs with fancy features like user login, browse and like cooksnaps, leave comments, auto post to facebook wall, admin tools to manage visibilities, etc. I did heavy javascript project before but this time is different. It’s a 3rd party javascript widget running on the food bloggers blog, the code is part of a rails project. Challenging but fun! Third-Party Javascript, this book written by Disqus engineers helped a lot!

Another big project is Cookpad global, it’s like a database-less rails app, we’re using API to transfer all the data we needed. At first we were using a gem called Her to let the model have ActiveRecord like interface, but due to performance problems and lack of maintenance we shifted to spyke.

Oh and almost forgot that I switched to VIM from Sublime Text, felt like long long time ago :) The transition phase didn’t take long, I used janus for a quick bootstrap then tweaked the parts one by one everyday. Love it so much.

Self

Some achievements on personal development:

  • Established the habit of going to gym 3 times a week
  • Established the habit of writing a journal every day
  • Challenging Audible audio book(“challenge” because of my English skill is still not enough to catch all the audio)
  • Shifting to principle centered person, made first draft of personal mission statement
  • Become an amateur Youtuber: published a gaming channel now have 566 subscribers, 500k views, generated about $277 income, estimated watched time is 3 years 280 days in total.

The Number of 2015

2015 = 1024 + 512 + 256 + 128 + 64 + 16 + 8 + 4 + 2 + 1. Such a beautiful number isn’t it!? Happy new year~!

December 31, 2014 #diary

三十而立

This year August I turned into 30, I wasn’t happy at all. In fact I was quite desperate. I felt I accomplished nothing, far away from who I expected to be. Now 4 months later, I finally managed to see the bright side, accepted myself and got physical and mental positive changes in life.

Gap Between Dreams and Realities

Turning into 30 is quite a big thing in China. There is a saying “三十而立”, directly translated to “a man should be independent [steadfast] at the age of 30”, nowadays it’s interpreted as financially independent, emotionally mature, have a good family to take care of. I was born and raised in that culture and unavoidably affected by it. When I was in high school, I dreamed about the day when I’m 30 I’d be mature for sure like a real adult, disciplined and principled, knowing everything about life, handle any tough situations well, have a lovely wife, a happy family, maybe even with 2 children, a boy and a girl, and doing my best job to protect them. Sadly none of these happened.

Goals are dreams with deadlines. Even though I had been working hard these years, but I didn’t make it like a real goal with concrete steps to make it happen. That explains why I ended up like this.

I didn’t celebrate that day, I wanted to write a post but couldn’t finish it because of the dark energy. Part of me was still refusing to accept the fact that I’m 30, I felt not young anymore.

Everything Has To Become Worse Before It’s Getting Better

So what would you do if you’re not happy about the situation? You simply change it. One thing I know for sure that if I take the action it would definitely make a positive impact but I’ve never done it yet, is exercise.

Unlike early 20s when I could play intense games 12 hours straight overnight then still manage to finish a whole day lesson in college, nowadays even 1 hour Starcraft II game would make me feel exhausted. Sleeping 7-8 hours is supposed to be enough but I still have to drag myself out of bed each day. I know there must be so many rooms for improvement.

I’ve read it many times in different places that exercise regularly will generate more energy and boost your creativity. Understand it is one thing, but taking actions is another thing. This time I showed no mercy to myself. I went to the gym near my place, asked the staff to give me a tour and immediately signed the paper for the membership. They was suggesting there’s a program will be available soon that I could use a coupon to join with relatively cheaper price, only thing I have to do is wait for it, but I turned it down said I want to do it now, today, I commit to do it, don’t wanna give myself any other chance to make any excuses. I know taking the actions now is way more valuable than the extra percentage of the price for me.

My goal is not getting big muscles to make myself looking better to attract any females, I want to regain control of my life, to know that I’m capable of improving myself, to have more energies to accomplish the essential things in the future. I have the clarity, I’m absolutely sure about the direction, everything else just naturally happened without any resistance. It was as simple as that.

I am planning to write another post about my routines about going to the gym and some extra benefits.

Keep The Ball Rolling

Another side effect of having physical exercise is paying more attention to health. I became more conscious about what and when to eat, not like before I ate whatever I wanted, whenever I wanted without limitation. Have vegetables regularly, try to have dinner at least 3 hours before sleep, push dishes away even though there’s some left if I know it’s enough already, etc. I’m still have little knowledge in this area so I’m also gonna take a cooking lesson to learn more systemically.

Also found myself have more time to read books. Reading is such an effective way to learn great thoughts from great people, *asynchronously*. It allows me to constantly revisit my past and recognize which part could have been done differently to have better result. One great thing for getting older is that you could find so many references from your past when reading, to fully explore the idea in your context, in your real experience.

By reading “The 7 Habits of Highly Effective People” I realized I had been living with impulse not correct principles, and that was why I was so weak to temptations, made several bad decisions and hurt the people around me. I followed the suggestions from the book and got my first draft of personal mission statement done. Whenever I have to make tough decisions it’s the reference for me to look up, who I want to be, who should I put first, what’s my responsibility. Decisions are never easy, but having correct principles guide me, it makes me look from the big picture, be more determined to my choice and commit to the result no matter it turns out good or bad at that time.

Willing to Think About Life Plan

I was never a fan of making long term plan. Even just think about it made me headache. “I just want to enjoy everyday and forget those complex things”, I said to myself.

But now I’m really willing to take the challenge. I know I actually like to plan things, like for a trip, for Christmas, even plans in games. What stopped me from planning my life, was the fear of the future. Family issues, relationship issues, unresolved conflicts, fear of the unknown… Made me feel stressed and overwhelming, so I ran away, used “just enjoy everyday” as the excuse.

Every family has a issue, so does relationship. You can’t run forever. I started to explore the options and possibilities, it wasn’t as hard as I expected. I could still breathe, it didn’t kill me. Be proactive, take the initiative also applies here. It has to be me to handle these things.

At Last

None of these changes require you to physically be the age of 30, but I surrendered to the fear of the future before and was unable to see things clearly, unwilling to deal with them, until now. For what it’s worth, I’m glad I overcame all the internal struggles, it’s never too late to make a meaningful life.

I’ll end with some of my favorite quotes:

Life is a gift, go make it count. - Michael Hyatt

The only true security in life comes from knowing that every single day you are improving yourself in some way, that you are increasing the caliber of who you are and that you are valuable to your company, your friends, and your family. - Anthony Robbins

December 13, 2014 #rails #test

TL;DR

# in config/initializers/delayed_job_config.rb
Delayed::Worker.delay_jobs = true

# in your spec
Delayed::Worker.new.work_off

Common Setup of DelayedJob

Assume you follow DelayedJob readme example to configure it like this: Delayed::Worker.delay_jobs = !Rails.env.test?, what it does is in test env it doesn’t delay the job, meaning DelayedJob is being transparent, the job you put will be executed in “real time”. In most cases you don’t even need to worry about it, your test should be just fine, but recently it caught me…

It Fails When…

To give some background, I’m working on a API centric rails project. In order to authenticate with API we pass in access token for every request, and that’s done in the middleware layer. Since access token is stored in cookie, and in middleware we can’t access browser cookie directly, so another tool called RequestStore is used. If in the same request, what you stored in RequestStore you can access it later no matter the context, a unrealistic example would be you store a cookie value to RequestStore then use it in model later. Don’t do that :).

The code below is a simplified version to illustrate the flow.

class ApplicationController < ActionController::Base
  before_action :set_api_access_token

  def set_api_access_token
    RequestStore.store[:access_token] = cookies.signed[:access_token]
  end
end

class Authentication < Faraday::Middleware
  def call(env)
    env[:request_headers]['Authorization'] = RequestStore[:access_token] if RequestStore[:access_token]
    @app.call(env)
  end
end

Every api request happened inside the rails ApplicationController stack should have the access token being set, but what would happen in a different context like rake task or DelayedJob where you need to send request to the API? The before_action is not gonna be executed there so RequestStore[:access_token] would be nil. This is an easy-to-spot issue if you try it once, but if you follow the TDD work flow and write test for it first, then it’ll fail you.

With Delayed::Worker.delay_jobs set to false in test env, the job will be executed immediately in the same request, so the RequestStore[:access_token] still contains the value and will pass to the Authorization header in the middleware, spec passed but but in real world env it failed. Typical false positive result.

To Run It Manually

# in config/initializers/delayed_job_config.rb
Delayed::Worker.delay_jobs = true

# in your spec
# here is the code to enqueue a job to DelayedJob queue
visit post_path(post)
# run it manually
Delayed::Worker.new.work_off
# expectation
expect(api_endpoint).to have_been_requested
end

Delayed::Worker.new.work_off returns an Array like [1, 0] indicating succeeded job counts and failed job counts. I’ve also seen some people testing against that like expect(Delayed::Worker.new.work_off).to eq([1, 0]), personally I don’t think it’s necessary.

  1. You have your own expectation right after that and that should be the main concern of the spec. If the job failed, your spec should be failed too.
  2. What if multiple jobs are enqueued while you’re only focusing one of them in the spec? Update the value to [2, 0]? That’s just noise.

I guess what I encountered is a rare case, but definitely an interesting case. I kinda prefer this way to mimic real world environment to prevent any possible regressions.

Commercial time: If you’re about to build a API centric rails app, be sure to check out the awesome gem called spyke made by @balvig, the slogan is “Interact with remote REST services in an ActiveRecord-like manner.”

November 18, 2014 #book

"Have you ever found yourself stretched too thin? Have you ever felt both overworked and underutilized? Have you ever found yourself majoring in minor activities? Do you ever feel busy but not productive?"

This book is about answers to these questions. The key messages and takeaways for me are:

  • Life is a tradeoff. You can’t have it all, therefore you have to choose, choose what matters the most. Less, but better.
  • You have to give yourself permission to say No to others, so you can say Yes to your goal and make highest contribution.
  • It’s not about getting more things done, it’s about getting the right things done. Effective over productive. I love this so much.

If You Don’t Have Time to Read it…

Here is a great video reviewing this book, and actually I started reading it because of this video. To be honest I think it might be arguably better than the book itself. If you don’t have enough time, just check out the video, should take you less than 25 minutes.

Chapters I Would Like to Read Twice

Part I: Essence: What is the core mind-set of an Essentialist?

  • CHOOSE: The Invincible Power of Choice
  • DISCERN: The Unimportance of Practically Everything
  • TRADE-OFF: Which Problems Do I want?

Part II: Explore: How can we discern the trivial many from the vital few?

  • SLEEP: Protect the Asset
  • SELECT: The Power of Extreme Criteria

Part III: Eliminate: How can we cut out the trial many?

  • DARE: The Power of a Graceful “No”

Part IV: Execute: How can we make doing the vital few things almost effortless?

  • PROGRESS: The Power of Small Wins

Overview

The first part, the "What" part, is really great. All the problems introduced there are so real, I could map literary everything to my real life. Very inspirational.

But sadly the following chapters, the "how" part, are less compelling to me. I agree with the general idea, it’s just the examples and evidences are not convincing enough.

Overall it’s a good book, I’d rate it 4 out of 5. It does give me positive energies and courages to improve my life, makes me pause to think about the past, which choices were made by “default”(others) and which were made by “design”(me), makes me think twice before purchase any non-essential items, makes me observe my bad habits & routines and fix them, makes me pursue less but better.

p.s. I didn't title this post as "Book Review", as I realized the word "review" is too big for me, makes me want to cover every aspect of the book, pros and corns, scan every note and highlight I made during the reading, that is overwhelming and will simplify stops me from writing. “Done is better than perfect”, indeed, the essential thing for me is to write this post and share my findings!

October 22, 2014 #rails

ActiveJob is the headline feature in Rails 4.2, the Active Job Basics on RailsGuides explains the philosophy and usage very well, make sure you’ve checked that first. However there’re some gotchas if you want to use it right now in your Rails 4.1 app. Here I’m gonna show you how to install it in 4.1, and things you need to take extra care of.

Install ActiveJob in Rails 4.1

Add activejob to your Gemfile then bundle install.

Create a active_job.rb file under config/initializers and paste code below.

require 'active_job'
# or any other supported backend such as :sidekiq or :delayed_job
ActiveJob::Base.queue_adapter = :inline

Now you should be abel to load ActiveJob in your rails app without error.

Note that the one you installed is not the one inside the rails repository, that has a version of 4.2.0.beta2 same as Rails at the time of writing, the one you installed is version 0. You can find the archived source code from its original repository.

Creating a Job

To create a job, you have to manually create the app/jobs folder first, then follow the same naming convention to create your job class file like app/jobs/guests_cleanup_job.rb.

class GuestsCleanupJob < ActiveJob::Base
  queue_as :default

  def perform(*args)
    # Do something later
  end
end

Enqueuing the Job

GuestsCleanupJob.enqueue(record)
GuestsCleanupJob.enqueue(record, options)

Differences between latest ActiveJob

  • no rails generator for jobs.
  • no callback mechanism like before_enqueue, before_perform etc.
  • doesn’t load itself to rails app by default, that’s why you need a initializer to load it manually.
  • enqueue syntax is slightly different, in Rails 4.2.beta2 enqueue has changed to perform_later.
  • internally it’s using activemodel-globalid instead of GlobalID(GlobalID is renamed from activemodel-globalid).
  • setting backend syntax is slightly different
# Rails 4.2.beta2
Rails.application.config.active_job.queue_adapter = :delayed_job

# Rails 4.1
ActiveJob::Base.queue_adapter = :delayed_job

p.s. I haven’t checked ActionMailer. I’m currently using it with DelayedJob and so far so good.

Summary

ActiveJob is very convenient, it provides a unified interface for the job infrastructure that allows you to switch the backend easily.

But as you can see there’re big diffs between the latest developed version and the one now we’re able to install in Rails 4.1.

Is it worth it to make the effort to try it now, and push these small upcoming changes when you upgrade to Rails 4.2 to your mental stack? My suggestion is if you’re just right about to implement a queue system and willing to adapt to it, then it’s OK, otherwise maybe better just leave the current app running as is and wait for a more mature timing.

September 23, 2014 #event

I went to Rubykaigi 2014 last week, there were lots of great talks about ruby itself, rails tips and more. Here I’ll share 3 things I feel worth to share for rails developers.

Synvert

Speaker page on Rubykaigi2014

Synvert = syntax + convert, makes it easy to convert ruby code automatically

Synvert is a gem made by the same author of bullet gem. Using it you can convert your rails 3 before_filter to rails 4 syntax before_action, rspec should have to expect(…).to have or ruby 1.8 hash to 1.9 hash syntax with just one command, and it does support more. It’s well tested so no worry for human error.

You could define your own rules to convert code, or use those built-in very common used snippets for rails, rspec and factory_girl.

Installation and usage

gem install synvert

# fetch snippets to ~/.synvert directory
synvert --sync

synvert -r factory_girl/use_short_syntax

Run git diff I got

- user = FactoryGirl.create(:user)
+ user = create(:user)

How does it work

AST(Abstract Syntax Tree) is used internally, it parses your source code to meaningful structures. It’s like grammar in English, one phrase can be broken down to words and some are noun, some are verb, it’s like saying “let’s replace all the verb ‘walk’ to ‘run’”. I highly recommend you to check out the slide if you want to learn more.

Example of attributes for AST node

For instance, it breaks a method call to receiver, message and arguments. A typical method call is a type of “send node”, class definition is “class node” and there is “block node”.

Links

Going the distance

Speaker page on Rubykaigi2014

To be honest I’m not sure I fully understand the algorithm of calculating distance between 2 words, but the great part is @ schneems used it to improve rails generator command to suggest possible commands when you had a typo.

Please see the pull request for details. Emit suggested generator names when not found #15497

If you ever make a cli command, you could follow the same pattern, using the algorithm to suggest candidates instead of just showing plain error message.

Good to see how how he adapted scientific algorithm to solve real world problem.

Speeding up Rails 4.2

Speaker page on Rubykaigi2014

Interesting to see how @tenderlove find room for optimization and how to measure it.

Tools mentioned:

  • benchmark-ips, benchmarks a blocks iterations/second. For short snippits of code, ips automatically figures out how many times to run the code to get interesting data. No more guessing at random iteration counts!
  • allocation_tracer, allows to trace object allocation.

Slide on speakerdeck

March 1, 2014 #octopress

Here I'll show you how to recover or restore your local octopress
repository, for instance you're on a new machine, or just lost your
local copy of it.

It requries you to have a repository on github that you've deployed your
octopress posts.

First I recommend that you read this post: Clone Your Octopress to Blog From Two Places, the Recreating a local Octopress repository section.

And here is what worked for me, please replace kinopyo with your user
name.

git clone -b source [email protected]:kinopyo/kinopyo.github.com.git octopress
cd octopress

gem install bundler
bundle install

rake preview
open http://localhost:4000

Tips on Converting HTML to Markdown

Somehow the latest 3 posts are still missing after I git cloned my
remote repository. I checked in advance and saved those copies as html.
And after I restored my octopress repository I used Pandoc to convert those html to markdown.

It works like:

pandoc -f html -t markdown your_html_file.html

Thoughts on Disaster

p.s. I stored my blog octopress repository on Dropbox and somehow it
just all gone, it really shocked me. Probably it was my fault not
theirs, but still I always thought Dropbox is a safe place, but I don't
even have a clue why it happended and somehow could't see the history and
restore from their website. After I noticed it everytime I came up with
something to write I've had used it as an excuse, or maybe I was not in
the mood to deal with it(also I didn't know how...).

So I need a fallback solution about Dropbox, every disaster changes you to rethink
about current seems comfortable situation. And hope I'll write more often :)

November 11, 2013 #work

Lots of big changes happened in my life recently, one of them is my
workplace. Lucky enough, now I got a chance to embrace the modern
style of work, that is working remotely.

I suppose you know more or less about remote. 37signals has published
their new book, REMOTE: Office Not
Required
, where all the benefits you can
get from remote is described. I’m half way done of that book, and
probably will write another post once I finished it and compared it to
my real experience. So here I’m gonna talk about only one thing, a key
thing, trust.

I’m a true believer of remote work. As in the book says,

The bottom line is that you shouldn’t hire people you don’t trust, or
work for bosses who don’t trust you. If you’re not trusted to work
remotely, why are you trusted to do anything at all?

I totally agree with that. But in reality is, well at least the
environment around me is even every single manager or boss is good and
kind, we still fall into the traditional working style, 9:00 - 18:00+ in
the office, that’s the norm, so dominant, I didn’t even try to convince
anyone to change that.

Fortunately I got a very unique opportunity to do remote work. After the
first day, I should say the biggest and most important “get” is not
about the productivity, freedom or flexibility, although they’re truly
there, it’s about the trust I’ve never experienced at work.

“I trust you. So no matter what, when and where you do the work, I don’t
care, as long as we’re moving forward.” That was pretty much the key
conversation I had. It was a really warm feeling. I don’t know how to
explain it in words exactly, to be honest I did see that remote work
coming before I joined. But when it really happened, I was flattered!
I’ve never got this kind of tremendous trust, it means a lot to me as a
person. I’m sure I’m not gonna waste it.

Trust is the first step to remote work. It’s personal and
fundamental.
If you trust your teammate, with proper tools and
communications I really think remote work will work!

October 29, 2013 #capybara

I got a brand new Mac Air recently, when I tried to install
capybara-webkit I encountered some problems.

The Error

Got this error when bundle install one rails app.

Installing capybara-webkit (0.12.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/qihuan-piao/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb


Gem files will remain installed in /Users/qihuan-piao/.rvm/gems/ruby-2.0.0-p247/gems/capybara-webkit-0.12.1 for inspection.
Results logged to /Users/qihuan-piao/.rvm/gems/ruby-2.0.0-p247/gems/capybara-webkit-0.12.1/./gem_make.out

An error occurred while installing capybara-webkit (0.12.1), and Bundler cannot continue.
Make sure that `gem install capybara-webkit -v '0.12.1'` succeeds before bundling.

Tried brew install qt didn’t get luck, raised this error:

brew install qt4 --build-from-source
==> Downloading http://download.qt-project.org/official_releases/qt/4.8/4.8.5/qt-everywhere-opensource-src-4.8.5.tar.gz
Already downloaded: /Library/Caches/Homebrew/qt-4.8.5.tar.gz
==> ./configure -prefix /usr/local/Cellar/qt/4.8.5 -system-zlib -confirm-license -opensource -nomake demos -nomake examples -cocoa -fast -release -no-3dnow -L/opt/X11/lib -I/opt/X11/include -pl
==> make
                                   ^
7 errors generated.
make[2]: *** [.obj/release-shared/qdrawhelper_ssse3.o] Error 1
make[1]: *** [release] Error 2
make: *** [sub-gui-make_default-ordered] Error 2

READ THIS: https://github.com/mxcl/homebrew/wiki/troubleshooting

These open issues may also help:
    https://github.com/mxcl/homebrew/pull/22283
    https://github.com/mxcl/homebrew/issues/23480

Solution

Checked all those links and tried several things, eventually downloading
qt installer from the qt-project website solved my problem.


Download link

Just install the debug libraries, qt libraries then bundle install
again.

Note

If you already got qt installed and capybara-webkit worked before
upgrade to Mavericks, then it’s probably gonna work as well.