RubyMine Issues

RubyMine is my preferred IDE for Ruby development. I chose it for local and remote debugging from the browser. It has some space for improvement but it’s also pretty good. And support is excellent.

These are the issues that I’ve reported. This list is mostly for my own use.

  1. Replace in Path should be integrated into Find in Path
  2. The ‘Replace in Path’ functionality is completely broken
  3. Number of ‘Found usages’ depends on wether the button ‘Merge usages from the same line’ is pressed or not
  4. Exclude external libraries from a custom scope of ‘Find in Path’
  5. In a big text file, it takes up to 2 seconds to move the caret only 1 char
  6. Depending on path tooltip position, displayed document is garbled
  7. Depending on caret position, displayed document is garbled
  8. Replace in Path (with a grouping RegEx) makes a mess (depending on input)
  9. File comparison should behave differently for ending lines
  10. Breakpoints dialog floats on top even if the parent project is closed (it has no closing button either)
  11. Extract CSS is broken
  12. Dream remote debugging with the PassengerDebugger option
  13. How to remotely debug Rails in Apache + Passenger + RubyMine

Fixing “uninitialized constant MysqlCompat::MysqlRes”

This is an old problem that affects an old Ruby gem: mysql (2.8.1). Apparently, it has a little bug somewhere that makes it look for a file in the wrong folder. I get this error always after installing a new app. The last time has been some minutes ago, after installing TracksApp 2.1, which is based on the old Rails 2.3.

The MySQL page about Ruby adapters speaks about two of them. One called MySQL/Ruby, and the other (after a huge name creation effort)… Ruby/MySQL. They are respectively provided by the gems mysql (2.8.1) and ruby-mysql (2.9.10). As you may have noticed, the first gem is the old version of the second. That is also confirmed by the dates they got updated, which is: 2.8.1, on 2009-08-21 and 2.9.10, on 2012-07-12.

Both adapters are authored by Tomita Masahiro. I do appreciate the effort he did, and his generosity in making them available to me, no doubt about that. But in my opinion, the name change was a mistake. I suppose he did it to tell the world they were two very different adapters (the old one C-based and the new one Ruby-based). Nonetheless, they really were two subsequent versions of the same thing.

The problem with TracksApp is exactly that. If Tomita Masahiro had stuck to the mysql name, then gem “mysql” in TracksApps would have referenced the latest version (what today is instead ruby-mysql) and all would have worked fine. But now, even with ruby-mysql installed, that gem requirement in TracksApp makes my system install the old mysql gem. That in turn makes Rails prefer mysql over ruby-mysql (why? lexical order?) and due to the known bug all my apps break.

My solution is to manually uninstall mysql each time it gets installed by some app. In fact I don’t know how to make my global Rails environment ignore mysql (2.8.1) even if some app requires it. I’ve tried with “bundle install –without mysql”, but mysql is a gem, not a group, so it does not work… My fix works because ruby-mysql perfectly replaces mysql and it’s just a drop-in, sharing the same adapter name (mysql).

Clearly, TracksApp is a new version of an old software, even if it is still based on Rails 2.3. If I was developing it, I’d have updated the Gemfile…

 

How to neatly deploy with Git on OSX and Linux

First and foremost, let me apologize if you got here by a misleading title. I always strive to find a good title for my posts but this time I’m not satisfied. This post is about my specific needs in the described scenario, and I decided to publish it mainly for my own record. Unfortunately, a more precise title would have had an unfeasible length.

Lately I’ve been making changes to a web project I had downloaded to my Mac from a Linux server provided by 1and1. My first mistake was to use FTP on the root tree. Even if I have a 50 Mb connection at home, it was a never ending task. After hours waiting for the download to complete, I found out that both FileZilla and Cyberduck had problems with some filenames.

Then I discovered that 1and1 has a file manager in the admin interface that allows you to make a zip. My second mistake was to think that the feature would work as advertised. That was not the case. Apparently you can select many files and directories at once an compress them to a zip file by means of a button. The button pops up a second window from where you can choose the filename. When you accept, it starts working, and working, and working, up to when it exhausts the time allowed for running the task (15 minutes, I think).

I made two wrong assumptions here really: first that selecting multiple files had an effect on the subsequent operation and second that the button would do it. Luckily for me, I discovered that if I selected just one file or directory and used the compress option from its contextual menu, it worked fine. It took some time to compress about 500 MB but the resulting file took merely a bunch of seconds to download by FTP.

I started making my changes to the code and testing them on localhost. Meanwhile, also the remote web tree was changing because users were uploading to and deleting files from the web. (If I make a web, code and data are clearly set apart, such that a trunk cannot branch without control. But this is not a web I made, and the code is so weird and highly duplicated that I understand it with some difficulty.)

It was at that point in time when I discovered that 1and1 had Git installed and ssh was available. So I realized Git could help me deploy changes from my development environment back to the production environment with minimum downtime. I wanted to be able to move changes the other way around too, for example to get new data files. My third mistake was to think that I could do all of it with a production repo cloned to a development repo. Unfortunately, Git (by default) don’t allow to push to a standard (non-bare) repo. Neither could I easily pull from the development repo to the production repo, because of my dynamic IP at home.

I understood that I needed three repos: a development repo, a production repo, and a proxy, internet-reachable, bare repo. Not only I had to find a place for the proxy repo but it also needed to exist before the other two, so that I could clone them from it. The problem I faced was that the website was already fully deployed right into the htdocs directory and 1and1 didn’t allow me to write outside. Thank Git, a clone is equal to each other (mostly) and .gitignore is very effective, so I solved it like this:

  1. init a production repo into htdocs
  2. add /bare.git/ to htdocs/.gitignore
  3. commit anything (to the production repo)
  4. bare-clone the production repo (htdocs/.git) to the proxy repo (htdocs/bare.git)
  5. reverse the clone relationship between both repos

I know it’s weird but works like a charm.

$ cd /<path>/htdocs
$ git init
$ cat > .gitignore

/bare.git/<CTRL+D>

$ git commit -a -m "initial files"
$ git clone --bare -l ./ ./bare.git
$ cd bare.git
$ git remote rm origin
$ cd ..
$ git remote add origin /<path>/htdocs/bare.git
$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master

After cloning the proxy repo to the development repo I could push and pull without any issue, but my fourth mistake was to think that all was nearly done. Instead UTF-8 filenames were my next headache because git status detected all those files as untracked. I tried hard to solve that issue, but in the end I decided just to work around it by committing those untracked files again.

$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   .gitignore
#   ".../1... Foz d'Iguac314247u 2010.doc"
$ git add ".../1... Foz d'Iguac314247u 2010.doc"
fatal: pathspec '.../1... Foz d'Iguac314247u 2010.doc' did not match any files
$ git add ".../1... Foz d'Iguaçu 2010.doc"
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   new file:   ".../1... Foz d'Iguac314247u 2010.doc"

One of the problems is that Git/OSX is showing escaped filenames in the output of git status, but it wants them added unescaped. After adding, committing and pushing those files I got this from Cyberduck (I only clipped the same confidential data from all the lines):

Mirrored copies of the same files, also with the same filenames! Oh, that’s weird! Of course they have different encodings.

Git/Linux and Git/OSX work perfectly well inside their respective operating systems with UTF-8 filenames but as soon as you cross the border of a system, issues arise. Linux and OSX support UTF-8 filenames differently. I think Git is to blame because it should offer a state of the art layer for supporting a distributed VCS. I read something about it being fixed in a new version, but I cannot install anything on the remote Linux machine to test it.

Even after all of the above, at some point (I do not remember how it happened) git status kept showing again the pathspec error. So I completely removed all the data files directories from Git and added them to .gitignore. That solved all the issues… hopefully.