vim-preview
vim-preview copied to clipboard
Can't preview markdown format on Ubuntu Linux
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.
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
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
Same issue here. (I have same redcarpet version installed). I'm running OS X El Capitan
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.
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?
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%
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]
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 , @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 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
@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
@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.
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
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