41

I updated to the latest JekyllBuild (1.0.3) before I always used the RC. After updating the parsing of codes (with Pygments) doesn't work anymore. I always get the following error:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/posix-spawn-0.3.6/lib/posix/spawn.rb:162: warning: cannot close fd before spawn
←[31m  Liquid Exception: No such file or directory - /bin/sh in 2012-01-17-test-post.md←[0m

Did anyone also ran into this problem?

I have no clue about ruby, so I can not debug this myself :(

Sebastian Sebald
  • 16,130
  • 5
  • 62
  • 66

10 Answers10

51

I had the same issue. Seems there's a problem in Pygments.rb 0.5.1. By rolling back to Pygments 0.5.0 the error disappeared.

gem uninstall pygments.rb --version ">0.5.0"
gem install pygments.rb --version "=0.5.0"

Hope this helps.

Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
zzheng
  • 898
  • 11
  • 17
  • Perfect, worked for me as well. Clearly some incompatibility with pygments.rb 0.5.1. Thanks @zzheng – Gui Ambros Jul 07 '13 at 04:10
  • 2
    Did not work for me. OS: Win8. Lates Ruby, DevKit, Jekyll etc. Guessing the error lies in trying to get a taste of the "happyland" on Windows. – Daniel Jul 20 '13 at 07:26
  • 2
    I had similar problems, using Python 3.2. I uninstalled that, installed Python 2.7.5 instead and all worked well, even with pygments.rb version 0.5.2. I did have to set my codepage to 65001, using `chcp 65001` before running Jekyll, because my sources are utf-8. – Rudy Velthuis Aug 11 '13 at 17:44
  • thx. It helps me lot.. :) I must define Python's path and Python/Scripts dir path to windows Path variable too for making jekyll works. I'm using windows 8. – Muhammad Resna Rizki Pratama Aug 18 '13 at 02:22
  • Indeed, as @RudyVelthuis says, You must use `chcp 65001` before running jekyll... – konus Nov 11 '13 at 21:21
  • Worked thanks, I only need to uninstall 0.5.4 as it was the incompatible version installed on my machine. – huseyint Dec 07 '13 at 12:44
  • run `gem uninstall pygments.rb` without a version specified. If you happen to have multiple versions installed, like I did, it will let you select from the list to uninstall them. I had `0.4.2`, `0.5.4`, and `0.5.1` all installed, so I removed the two I didn't need, and it worked like a charm. – robabby Dec 14 '13 at 02:26
  • Win7, solution for me was downgrading to Python 2.7 – aurbano Dec 24 '13 at 14:45
17

Expanding upon zzheng's explanation, if you're still having issues try running gem list. Then make sure pygments.rb (0.5.2) isn't installed. If it is, just run this command.

gem uninstall pygments.rb --version "=0.5.2"

That should take care of your problem, and you should be able to publish with Jekyll happily on Windows once again.

EDIT: Also, based upon my own experience, this may cause another error. Liquid Error: Failed to get header. in 2013-07-20-post-name-here.md. The (unconfirmed) solution is to install Python 2.7.* if you have not already done so, although some people report that this does not fix the problem.

Further Reading:

Jekyll Github Issue #1181

Pygments.rb Github Issue #45

Run jekyll --server Failed in Win7

Community
  • 1
  • 1
Brandon Anzaldi
  • 6,884
  • 3
  • 36
  • 55
6

if you add highlighter: false to your config.yml, you can avoid loading Pygments at all

Alex Levine
  • 1,489
  • 15
  • 16
2

Lately, I've found the best way to deploy jekyll or whatever else environment on windows is using http://scoop.sh/ or https://chocolatey.org/.


This error is mainly for the reason that Windows Shell can not find this command 'which' but Cygwin and MinGW. I think the best solution is modifying the popen.rb

to this below:

# Detect a suitable Python binary to use. We can't just use `python2`
# because apparently some old versions of Debian only have `python` or
# something like that.
def python_binary
    if RUBY_PLATFORM =~ /(mswin|mingw|cygwin|bccwin)/
        return 'python'
    end
    @python_binary ||= begin
        `which python2`
        $?.success? ? "python2" : "python"
    end
end

There are also some details according to This page .

chris Ren
  • 71
  • 7
  • In addition: enabling markdown:redcarpet will calling python to exec some script.When I disable redcarpet , I even didn't need installing python anymore to run jekyll. This is another reason when running jekyll on windows.Therefore,another solution is using kramdown which is set by jekyll 2.4 default. – chris Ren Feb 07 '15 at 15:22
  • That worked for me. The `if RUBY_PLATFORM =~ /(mswin|mingw|cygwin|bccwin)/ return 'python' end` is the additional part here. – Neo May 08 '15 at 05:55
1

I know this is answered but sharing my experience. So it appears that the issue lies with pygments.rb of ruby installation. After installing jekyll and trying to run at localhost it would give an error at the default post file. By deleting the syntax highlighting code from the markdown file (see below) and removing the reference of pygments from _config.yml file, I was able to run it on the localhost.

{% highlight ruby %}
def print_hi(name) puts "Hi, #{name}" end print_hi('Tom') prints 'Hi, Tom' to STDOUT. {% endhighlight %}

Remove the striked-out lines

The changes worked however am yet to figure out if there is a possible way to use the pygments.rb for code highlighting.

pradyunsg
  • 18,287
  • 11
  • 43
  • 96
codingbbq
  • 4,049
  • 5
  • 35
  • 47
1

Adding to what @noobcode said, you can actually continue to use pygments.rb if you add the Python27 directory (wherever you stored it) to your path (as another user mentioned in a response to a thread above).

Those who don't have any idea how to add the directory to their PATH should visit this site.

Michał Rybak
  • 8,648
  • 3
  • 42
  • 54
1

Look at https://github.com/juthilo/run-jekyll-on-windows/. It helps with Jekyll problems on Windows, including Pygments (from https://github.com/juthilo/run-jekyll-on-windows/#install-python-environment and up).

1

For me, the fix was to add a symbolic link to python.exe called python2.exe

Do this, with elevated privileges, in the directory where python 2.x is installed:

mklink python2.exe python.exe
Thany
  • 285
  • 2
  • 11
0

Just for a reference to those who meet the same problem like me. I had python 2.7.6 installed first and then installed python 3.3.0. So re-install python 2.7.6 fixed the problem for me. pygments.rb (0.5.4) Python 2.7.6 ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0] jekyll 1.4.3 OSX 10.8.5

flashlib
  • 151
  • 1
  • 6
0

Go into the directory that has python.exe and copy and paste it into a new file named python2.exe. Fixed!

Micah
  • 10,295
  • 13
  • 66
  • 95