Categories
Programming

Fixing missing NVM Node for RubyMine

I have Rubymine installed locally. Recently for work, I had to install NVM in a new machine. However when I then load Rubymine on this new machine and start a task such a Rails project using the Configuration pane, I was treated with following error

.../.rvm/gems/ruby-2.4.10/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect': Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
...

So basically it can’t find the NVM JavaScript runtime.

After digging a bit further, I noticed that RubyMine is launched via /bin/dash. So it seems the same environment variable available in Bash shell was not available.

So my fix was:

Create /etc/profile.d/nvm.sh. (or something similar)

Put following content in the file

if [ -d "$HOME/.nvm" ] ; then
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
fi

It is similar to the script mentioned in: https://github.com/nvm-sh/nvm#git-install. I just check if the directory exists before running other commands. Basically it will set the add the NVM node path to PATH.

Add following line to .bashrc.

source "/etc/profile.d/nvm.sh"

Log out and login

Now when you start the configuration, it should work in Rubymine.

PS: If you know a better way to fix it, let me know.

Categories
Programming

An intro to Debugging

In this article I’ve gathered my thoughts to help developers to get better in debugging especially if they find debugging really hard. The article also lists a set of tools which will help them to debug efficiently and to improve their skills. Hopefully you will find some value in this article, if you are also looking for debugging advice.

Categories
Programming

An approach to use service workers to replace load balancer

In this article, I’m going to discuss a novel way to distribute network load of a highly distributed web based application service.

Categories
Programming

Serving Flask app with Nginx

So you have build a Flask application and now you want to server the application in the web. In this tutorial, I’m going to teach how you can do that with Nginx on an Ubuntu platform.

Categories
Programming

Updating Rails app gems

Past few weeks, we have been focusing on updating Gems of our Rails application.

Categories
Programming

DynamoForms : a library to validate forms only with HTML

This article about my recent work I have done in creating a JavaScript based HTML form validation library.

Categories
Programming

Debugging CkEditor for tests

This week has been an interesting week as it was mostly debugging and fixing tests.

Categories
Programming

Control Philips Hue with Google Assistant SDK on Ubuntu

In this article, I’m going to teach how I manage to integrate Philips Hue bridge with Google Assistant SDK to control my smart lights.

Categories
Programming

Sometimes you have to look back when debugging

Last week has been a firefighting week at work (i.e. debugging and troubleshooting). I’m writing this article to share my experience with debugging a system configuration at work. In the end of article, I have placed some lessons learned points so hopefully someone can learn from it to improve their career.

Categories
Programming

Opening Right-click Menu / Context menu with Selenium WebDriver

Selenium WebDriver providesActionBuilder to perform complex user interactions with a web page. It allows chaining multiple actions together to perform a complex action.

You can create a complex action and execute the action (perform) it in the following manner. (Ruby)

driver.action.key_down(:shift).
              click(element).
              click(second_element).
              key_up(:shift).
              drag_and_drop(element, third_element).
              perform

 

The action to open the context menu is context_click() .

driver.action.context_click(webdriver_element).perform

By default, it will click on the middle of the element if you provide one.  Otherwise, it will click where the mouse pointer is at.

If you want to move the pointer to a specific location of the page before clicking, use methodmove_to.

 

If you want to select an item from the context menu use arrow keys and enter then perform the action. You can also further pinpoint the cursor position by using  custom position from your element reference

page.driver.browser.action.move_to(webdriver_element, 5, 10)
 .context_click
  .send_key(:arrow_down)
 .send_keys(:enter)
 .perform

 

Ref: http://www.rubydoc.info/gems/selenium-webdriver/Selenium/WebDriver/ActionBuilder