Skip to content

Instantly share code, notes, and snippets.

@kpheasey
Last active March 22, 2022 20:13
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save kpheasey/502f73c1d9cf2456c1f4291a6ec06a3e to your computer and use it in GitHub Desktop.
Save kpheasey/502f73c1d9cf2456c1f4291a6ec06a3e to your computer and use it in GitHub Desktop.
WSL, RVM & RubyMine; ubuntu on windows, bash on windows

Add inbound firewall rule for TCP 2222

  • Windows 10 has 2 new services, SSH Server Proxy and SSH Server Broker which will already be bound to port 22
  • Do not allow public connection on this rule, WSL is not proven safe

ConEmu

Add as cmd startup with bash.exe --login

Install the SSH server and some Rails essentials libraries in bash

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install openssh-server libxml2 libxml2-dev libxslt1-dev libmysqlclient-dev nodejs libqt4-dev libqtwebkit-dev -y

Configure the SSH server

Ensure the following values are set in the configuration file.

  • ListenAddress 0.0.0.0
  • UsePrivilegeSeparation no
  • PasswordAuthentication yes
sudo nano /etc/ssh/sshd_config

Restart the SSH server

sudo service ssh restart

Note: you will need to start the SSH server if you close the bash window.

Install RVM

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash
source ~/.rvm/scripts/rvm
rvm install 2.3.1
rvm use 2.3.1 --default
gem install bundle

If you are getting errors when running bundle install, it may be because of bad permissions on the bundle cache directory. Set them to 0755.

find ~/.bundle/cache -type d -exec chmod 0755 {} +

Add new remote interpreter in RubyMine

  • Go to Settings > Languages & Frameworks > Ruby SDK and Gems
  • Click '+' and select New Remote...
  • Choose 'SSH Credentials'
  • Enter the following
    • Host: 127.0.0.1
    • Port: 2222
    • User name: [UBUNTU USER]
    • Auth type: Password
    • Ruby interpreter path: /home/[UBUNTU_USER]/.rvm/gems/ruby-2.3.1
@daniel-romero-1
Copy link

@lynxnathan thanks! this is what worked for me.
Also note that in Rubyme inside run configurations you can set the path mappings: C:/ => /mnt/c/

@ckbkr
Copy link

ckbkr commented Jan 7, 2018

Not a bad idea.

You forgot to mention the sshd_config location which is /etc/ssh/sshd_config

In your changes for the config you missed to mention the port

For rvm users using 'which ruby' produces the path to use in rubymine. Which is easier to copy-paste than filling in the blanks and crashing on the ruby version.

Still a pretty neat idea.

A neat addition for people who just want to use ruby and not ruby rails there is a local to remote folder mapping in the same configuartion location: Settings => Language.. => Ruby SDK... => the Icon right of the Plus used before

In case you have your ruby files on D:\myAwesomeRuby\ that'd be mapped on /mnt/d/myAwesomeRuby/ then you can run it in your IDE just fine.

@cec
Copy link

cec commented Jan 10, 2018

I get

Directory '/opt/.rubymine_helpers' doesn't exist on remote server

I don't get it: FW rule for 2222 is working, sshd_config changes too (I can ssh from git bash into my linux subsystem)

I gave the path to my RVM gemset...

Did anyone encounter a similar issue?

@Thejaswi05
Copy link

I got it working @mausv

@talhait07
Copy link

talhait07 commented Jun 5, 2020

I get this error Error running Development: project-name: [No Rails found in SDK] in RubyMine while try to start debug
Can anyone say why this is happening?
I've tested with both local and remote sdk settings but either case I get that error.
I can't debug with RubyMine and I miss that to much.

@kpheasey
Copy link
Author

kpheasey commented Jun 5, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment