vim-preview icon indicating copy to clipboard operation
vim-preview copied to clipboard

Can't preview markdown format on Ubuntu Linux

Open iryston opened this issue 9 years ago • 14 comments

Hi! The error occurs with this plugin on Linux:

Preview: To preview markdown format you need to install redcarpet gem Press ENTER or type command to continue

$ which redcarpet /usr/local/bin/redcarpet $ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

The same configuration on my OS X machine with this plugin works as expected.

iryston avatar Jan 15 '16 19:01 iryston

Hi! Do you have redcarpet gem installed (not executable). Can you execute:

$ gem list | grep redcarpet

If you don't see it, you have install it with command:

gem install redcarpet

greyblake avatar Jan 16 '16 18:01 greyblake

I have redcarpet installed

$ gem list | grep redcarpet redcarpet (3.3.4)

it is installed in /usr/local/bin/ and is available in my $PATH

iryston avatar Jan 16 '16 20:01 iryston

Same issue here. (I have same redcarpet version installed). I'm running OS X El Capitan

brunodd avatar Feb 03 '16 09:02 brunodd

It's strange, because I use this Vim configuration (https://github.com/iryston/vim-wd) on both Xubuntu 14.04 and OS X El Capitan, and everything works fine in OS X.

iryston avatar Feb 03 '16 09:02 iryston

Could you please save the next file:

ruby <<RUBY_CODE
    puts RUBY_DESCRIPTION
    require 'rubygems'
    require 'redcarpet'
RUBY_CODE

And then type in your Vim keeping the file opened :so % What output do you get?

greyblake avatar Feb 03 '16 09:02 greyblake

I get: line 6: LoadError: cannot load such file -- redcarpet

However, if I run redcarpet --version in Terminal, I get output: Redcarpet 3.3.4%

brunodd avatar Feb 03 '16 09:02 brunodd

UPDATE: After saving the file

require 'redcarpet'
renderer = Redcarpet::Render::HTML
markdown = Redcarpet::Markdown.new(renderer)
text = '# THIS IS TITLE'
p markdown.render text

and running it, I get the expected output: "\<h1>THIS IS TITLE\</h1>\n"

UPDATE 2: When I run the original file from the terminal, output is correct: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]

brunodd avatar Feb 03 '16 10:02 brunodd

On OS X ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]

On Linux

ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
Error detected while processing /tmp/test.rb:
line    5:
LoadError: cannot load such file -- redcarpet

iryston avatar Feb 03 '16 10:02 iryston

@iryston , @brunodd Thanks guys. Looks like your Vims were compiled with ruby 1.9, but in your terminal you are using 2.3. I am not 100% sure, but this may cause the issue.

Also, do you guys use rvm or rbenv? Can you make sure that, when you run Vim redcarpet is accessible?

$ gem list | grep redcarpet  # make sure the gem is present
$vim                         # run vim
# Try to execute same ruby code in vim or preview markdown

greyblake avatar Feb 03 '16 11:02 greyblake

@greyblake My Vim was compiled with ruby 2.0: when I run your script from within Vim I get

ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
Error detected while processing /Users/brunodd/test.rb:
line    6:
LoadError: cannot load such file -- redcarpet

brunodd avatar Feb 03 '16 11:02 brunodd

@greyblake Thank you! My Vim is compiled with ruby 1.9 (default ubuntu package). I use rbenv.

$ rbenv global 1.9.3-p484
$ ruby -v
> ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
$ gem list | grep redcarpet
redcarpet (3.3.4)
$ vim /tmp/test.rb
:ruby puts RUBY_DESCRIPTION
> ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
# Try to execute same ruby code
:so %
> ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
> Error detected while processing /tmp/test.rb:
> line    5:
> LoadError: cannot load such file -- redcarpet

iryston avatar Feb 03 '16 11:02 iryston

@brunodd My Vim in OS X was compiled with ruby 2.0 too.

$ ruby -v
ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
$ gem list | grep redcarpet
redcarpet (3.3.4)
$ vim
:ruby puts RUBY_DESCRIPTION
ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]

And everything works fine.

iryston avatar Feb 03 '16 11:02 iryston

Those commands all give the exact same output on my machine. But when running the script from within vim using :so % I get the:

line    6:
LoadError: cannot load such file -- redcarpet

Error

brunodd avatar Feb 03 '16 12:02 brunodd

One more strange thing. In linux terminal:

$ wget https://raw.githubusercontent.com/greyblake/vim-preview/master/README.markdown -O /tmp/README.html; \
vim /tmp/README.html

In Vim:

:%!redcarpet
:exe ':silent !firefox %'

And it works!

But if I do it with plugin:

$ wget https://raw.githubusercontent.com/greyblake/vim-preview/master/README.markdown -O /tmp/README.markdown; \
vim /tmp/README.markdown

In Vim:

:PreviewMarkdown

There is an error Preview: To preview markdown format you need to install redcarpet gem

iryston avatar Feb 04 '16 07:02 iryston