How to debug ruby tasks on Rubymine

Lets do an example creating a new task

First create a task file in your rails project, for example:

touch lib/tasks/debug.rake

And add one task in this file:

namespace :debug do
  desc 'Test rubymine debug feature'
  task :something => :environment do
    hello = 'world'

    p hello
  end
end

Now put a breakpoint on the line that we print the variable hello, and lets config the debugger.

To config the debugger, first go to menu “Run/Edit Configurations…” and add a new configuration using a rake template.

Configure Debugger

Now fill the first field with you task name.

Configure Debugger 2

And now you’re ready to debug, you just need to click on the bug button with your task selected.

Configure Debugger 2

You can use the interactive console, see the traces and see the log console too.

It’s a wonderful tool and you can use for solving problems in a “clean environment” and make sure your tasks works good.

Have fun!!!

Failed to mound folders in linux guest

Problema

Failed to mount folders in Linux guest. This is usually because the "vboxsf" file system is not available. Please verify that the guest additions are properly installed in the guest and can work properly. The command attempted was:

mount -t vboxsf -o uid=id -u vagrant,gid=getent group vagrant | cut -d: -f3 home_vagrant_ieducar /home/vagrant/ieducar mount -t vboxsf -o uid=id -u vagrant,gid=id -g vagrant home_vagrant_ieducar /home/vagrant/ieducar

The error output from the last command was:

stdin: is not a tty mount: unknown filesystem type 'vboxsf'

Solução

Caso este erro aconteça ao iniciar sua máquina virtual, execute o comando abaixo para que suas pastas sejam compartilhadas corretamente.

vagrant plugin install vagrant-vbguest

vagrant up; vagrant ssh -c 'sudo ln -s /opt/VBoxGuestAdditions-4.3.10/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions'; vagrant reload

Problema de certificado SSL ao baixar uma box no vagrant!

Olá, hoje ao tentar iniciar uma nova box utilizando Vagrant, acabei tendo problemas com certificação. Como não achei solução específica e em português pela internet, resolvi compartilhar pra ajudar quem possa ter o mesmo problema.

Problema retornado pelo GitShell no windows:

An error occurred while downloading the remote file. The error message, if any, is reproduced below. Please fix this error and try again.

SSL certificate problem: unable to get local issuer certificate
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

Solução encontrada:

O comando abaixo foi adicionado no meu Vagrantfile para que ignorasse o certificado SSL que estava impedindo o download da box.

config.vm.box_download_insecure = "https://caminhoparadownload.nomedabox.box"

Após alterado o Vagrantfile, basta executar “vagrant up” novamente.

Referencias: https://docs.vagrantup.com/v2/vagrantfile/machine_settings.html