My Rails Kali Linux Install Experience

08 August 2021

We have microservices developed using Ruby on Rails. I have to install several of these microservices to run another Golang microservice. Being a ruby noob, I find it challenging to install since I think the README assumes every developer is seasoned Ruby programmer.

The other challenge I have is that Kali Linux has out-of-the-box ruby which version is lower than what its Gemfile requires. I have to uninstall the existing ruby and install rbenv. But the hurdle doesn't stop there.

Customising Ruby

$ sudo apt remove ruby

$ sudo apt install rbenv

$ echo 'eval "$(rbenv init)"' >> ~/.zshrc

$ source ~/.zshrc

$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash  
Checking for `rbenv' in PATH: /usr/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /home/drmanalo/.rbenv/plugins/ruby-build/bin/rbenv-install (ruby-build 20210804-1-g57c397d)
Counting installed Ruby versions: 2 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK

$ rbenv install 2.7.4

$ rbenv global 2.7.4

Installing Rails

$ gem install rails

$ bundle install

# To mitigate issue with gem install pg
$ sudo apt install libpq-dev

$ bundle install
...
Bundle complete! 38 Gemfile dependencies, 139 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

Fixing Github private repo issues

I created a Github token on https://github.com/settings/tokens and added below to my .zshrc

export BUNDLE_GITHUB__COM=x-access-token:ghp_xxxxxxxxxxxxxxxxxxxxx

Running Rails

$ rake db:migrate

$ rails server
=> Booting Puma
=> Rails 6.1.4 application starting in development
=> Run `bin/rails server --help` for more startup options