Category: programming

ruby – update default bundler

Whenever I get this error, I have to again do a google search. So, this post is for me not to do that again!

Could not find 'bundler' (2.1.4) required by your .Gemfile.lock.
 (Gem::GemNotFoundException)
To update to the latest version installed on your system,
run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.4`

Unfortunately, the suggestions don’t quite work.

The correct way to fix this is to run these three commands:

gem install --default bundler
gem update --system
bundler update --bundler

Courtesy of StackOverflow. (The correct answer on StackOverflow didn’t quite work either!)

ruby Open3 module

What a fantastic module!

Every once in a while I get to know a bit more of Ruby and I feel the joy which Matz talks about!

From: The Philosophy of Ruby

For me the purpose of life is partly to have joy. Programmers often feel joy when they can concentrate on the creative side of programming, So Ruby is designed to make programmers happy.

Today I was looking for executing a program from within Ruby. Now this program takes command line input and gives some output as well. So, I went around trying the usual %x(program.rb) but obviously that didn’t work.

Finally I came across Open3 which is a core module of Ruby!

Continue reading

ruby Classes and Modules

Classes and Modules in ruby have always intrigued me!

So, I thought I’ll write some code to understand what they were.

Besides the standard Class aspects of ruby, there are a lot of interesting things that can be done with them – like singleton objects.

Modules, of course, give another level of flexibility.

Continue reading

remove favicon request error in Chrome

Chrome has this weird habit of requesting for a favicon to show on the tab. For developing applications locally this is a major pain.

There is a way to overcome this, however.

chrome favicon request

To avoid this, we can add a very small snippet in the in the head of index.html file.

<link rel="icon" href="data:image/gif;base64,R0lGODlhEAAQAAAAACwAAAAAAQABAAACASgAOw==">

ruby – ‘rvm not found’ when running cron or ssh command

rvm or the Ruby Version Manager, works perfectly fine when there is a single version of Ruby to be run on the system (among multiple versions installed, of course) around the entire system. In a production scenario, updating ruby itself is a task which is not taken lightly!

This worked perfectly until I encountered two quite different situations –

One scenario was where I wanted to execute a command via ssh into the server. So something like –

ssh user1@server1 'ruby ~/program.rb'

The other being when I wanted to run a ruby program via cron

In both these cases, I kept getting the error rvm not found. Initially, I couldn’t understand this at all, because every time I logged in and ran the program or the command it would run prefectly.

And then I learnt about the difference between a login and a non-login shell.

Continue reading

Copyright © 2024 the möbius trip

Theme by Anders NorenUp ↑