Skip to content

Getting files to open in rubymine #548

@x9sim9

Description

@x9sim9

I couldn't get files to open in rubymine, debugged the issue and this is how I got it to work

  1. create a bash script to parse the url

/bin/handle_rubymine_url.sh

#!/bin/bash

url=$1

# Extract file path and line number from the URL (adjust regex if needed)
# The URL format is typically rubymine://open?url=file://FULL_LOCAL_PATH&line=LINE_NUMBER
file_path=$(echo "$url" | sed -e 's/rubymine:\/\/open?url=file:\/\///' -e 's/&line=[0-9]\+//g')
file_path=$(echo "$file_path" | sed "s/%2F/\//g")

line_number=$(echo "$url" | sed -e 's/rubymine:\/\/open?url=file:\/\/[^&]\+&line=//')

# Use the command-line launcher (e.g., 'mine') to open the file at the specified line
rubymine --line $line_number "$file_path"

(don't forget to chmod +x /bin/handle_rubymine_url.sh)

  1. create a desktop file that points to your bash script

~/.local/share/applications/rubymine_url.desktop

[Desktop Entry]
Name=RubyMine URL Handler
Exec=/bin/handle_rubymine_url.sh %u
Icon=rubymine
Terminal=false
Type=Application
MimeType=x-scheme-handler/rubymine;

  1. add the mime type to xdg

xdg-mime default rubymine_url.desktop x-scheme-handler/rubymine

  1. add this to your project

/config/environments/development.rb inside Rails.application.configure

BetterErrors.editor = "rubymine://open?url=file://%{file}&line=%{line}" if defined?(BetterErrors)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions