Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / Ruby

Build Issue with Ruby in macOS --- Bundler Installation and Bootstrap `docs` Script Run

0.00/5 (No votes)
10 Dec 2018CPOL3 min read 4.6M  
I needed Ruby in order to run `npm run-script docs` in Bootstrap's project, but the command failed in macOS 10.14.2. It was because Bootstrap's site seems to be created with Jekyll, which works on Ruby, and Ruby installed by default or with XCode did not work well for this purpose.

I needed Ruby in order to run `npm run-script docs` in Bootstrap's project, but I had not used Ruby and did not know much about it.

Native Extension Build Error from Bootstrap's `docs` Script

The command failed at first because the site of Bootstrap seems to be created with Jekyll, which works on Ruby, and I hadn't installed it. macOS (10.14.2) has ruby and gem by default, however, once running `sudo gem install jekyll`, it turned out to have some problem with native extension build because the ruby installation lacks some C header file.

Attempt with Ruby Installation by Homebrew

Then, I tried to install ruby by Homebrew (brew), and added required environmental set-up in ~/.bash_profile, which was mentioned at the end of installation. Then, the installation of Jekyll succeeded.

After that, I got back to `npm run-script docs`, but now it claimed it could not find jekyll, with an advice to run `bundle install`. As per the advice, I ran bundle install at the project root directory, and saw a failure with some error. Whatever the error is, first of all, I saw some warning message at the beginning of this command output, which mentioned that Bundler version I used (1.16.6) was older than the version that created the lockfile (1.17.1).

Trouble with Bundler 1.17.1 Installation

So, I ran `sudo gem install bundle`, but surprisingly, it didn't upgrade bundle to the latest, which was 1.17.1. In addition, I noticed that there's `bundler`, which looks the same as bundle. I was so confused. Looking around the Web to know more about those, and learnt that those are actually the same. However, as I experienced, passing the name `bundle` and `bundler` to `gem` command is different. In this case, `bundler` did the right thing, which provided the latest version as 1.17.1, and `bundle` didn't, where even `gem install bundle -v 1.17.1` replied that it didn't find the version. Hmm...

Eventually, `sudo gem install bundler` installed Bundler 1.17.1, and now, `bundle install` went through to the end successfully... which was what I wanted to see, but unfortunately, it was not. I got a native extension build error again. This time, it was for eventmachine. Accommodatingly again, the error message gave me an advice to make sure that `gem install eventmachine -v '1.2.7' --source 'https://rubygems.org/'` succeeds beforehand. I tried this command, and it succeeded... which I didn't expect to do.

Attempt with rbenv and rvm

Mysteriously, it looked as if some other Ruby version was used in some part of these builds during the command `bundler install`. I was completely upset at this phase. Because it is related to Ruby version handling, I tried rbenv, but it didn't help. It might be because I didn't set things up in a right way, but in the end, I gave up with it. Secondly, I tried rvm. I installed it as it is described in its home page, and installed Ruby 2.5.3 by running `rvm install '2.5.3'`.

At this stage, I thought I should remove what I added to .bash_profile for the Ruby installed by Homebrew. While removing the lines, I noticed there was one additional line that I think was added by rvm installation, which looked like `[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"`. Applying this change in .bash_profile in the terminal, I could see Ruby version with the command `ruby -v`. I hoped it would make `sudo gem install bundler` work.

And it worked! I got bundler 1.17.1, and when I ran `bundler install`, I didn't get the warning message this time, and moreover, it succeeded!! Then, finally, I got all the way back to `npm run-script docs` in Bootstrap project, and the script finished successfully without any problem.

Conclusion

I recommend using Ruby Version Management (rvm) when you get some Ruby-related build problem in macOS. Installing and managing Ruby versions with rvm helped in my case with Bundler installation and Bootstrap `docs` script run.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)