Blog 1

Random Talk on Random Thoughts

Rake Aborted Due to a Vim Swap File

| Comments |


I’m using fugitive.vim for efficient verson control.1


Tonight, I wrote an article about Venn diagram, and I attempted to publish it using the Vim editor command

:Gpush|!rake gen_deploy && rake notify

After that, the following error message popped up.

[owner@localhost ~/octopress]$ vi
   c6c422a..fc8d6b8  source -> source

## Generating Site with Jekyll
    write source/stylesheets/screen.css
Configuration file: /home/owner/octopress/_config.yml
            Source: source
       Destination: public
 Auto-regeneration: disabled. Use --watch to enable.
cp -r source/_posts/.2016-02-09-my-venn-diagram-mistake.markdown.swp public/_posts/.2016-02-09-my-venn-diagram-mistake.markdown.swp
rake aborted!
Errno::ENOENT: No such file or directory @ rb_sysopen - public/_posts/.2016-02-09-my-venn-diagram-mistake.markdown.swp
/home/owner/octopress/Rakefile:276:in `block (2 levels) in <top (required)>'
/home/owner/octopress/Rakefile:275:in `block in <top (required)>'
/home/owner/octopress/Rakefile:265:in `block in <top (required)>'
/home/owner/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
/home/owner/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => copydot
(See full trace by running task with --trace)

shell returned 1

Press ENTER or type command to continue

When one sees an error message like above for the first time, one needs not look directly into code, even though one is writing code in an IDE. Instead, one may view the error log to see what’s wrong.

From the command cp -r ..., I realised that the problem came from Rakefile, which tried to copy the non-existent .2016-blablabla.markdown.swp in the public folder in the local folder for this blog to the _deploy folder.2 (There are no _posts folder under the public folder.)

How can I do the task within Vim?


I googled “rake generate ignore swp”, and clicked on the first search result, which is Octopress issue #1073. It provided a link to issue #600. Bradon Mathis said that this has been fixed in 2.1. Unluckily, after hitting that hyperlink, I found that the version of Rakefile shown online was different from mine. Finally, I installed vim-octopress to solve this problem.3 If this plugin supports background tasks like rake preview, the blogging experience using Octopress within Vim will be further enhanced.

Lessons learnt

I’ve learnt to use the HTML cite tag when I directly quote a short phrase from others to avoid being penalised by the Google search engine for lacking originality.

Moreover, I revised the usage of these two Vim plugins.

  1. Visual Star Search: Select text in visual mode and search it with an asterisk *.
  2. textobj-lastpat: Add the last search pattern as a text object.

  1. I’ve used this Vim plugin for more than a year

  2. Strictly speaking, the public folder isn’t in the Git repository because this folder isn’t *tracked by the version control system (VCS). 

  3. For more details, you may see my gist for the .vimrc on Ubuntu at version a2c8028