On 27 Nov 2021, at 01:00, Matt Neuburg via TextMate <textmate@lists.macromates.com> wrote:

You cannot mean that I should be installing any gems using the system Ruby. It is off limits, and has been since Catalina. You are _supposed_ to install your own Ruby, and I have done so.

I didn’t say that. I said you should use the version of Ruby that TextMate invokes when invoking that command. It can be system Ruby and it can be something else.

And TextMate _is_ using it. When I run a TextMate ruby script consisting of `puts RUBY_VERSION`, I get `2.6.3`. When I say in the Terminal `ruby --version`, I get

   ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin20]

Moreover, when I run a TextMate ruby script consisting of

   require 'redcarpet'
   markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, extensions = {})
   puts markdown.render("This is *bongos*, indeed.")

I get the expected

   <p>This is <em>bongos</em>, indeed.</p>

So I don't think you can deny that TextMate Ruby sees redcarpet. The question is why the GitHub Markdown bundle does not see it.

Running a Ruby script and running a bundle command is not the same thing. When running a Ruby script from within TextMate  you’re invoking the “Run” bundle command in the Ruby bundle. This will invoke Ruby 1.8.7 [1], which will invoke the ruby_script.rb [2] script inside the Ruby bundle. This script will later use the TM_RUBY environment variable, if it’s set, or otherwise fall back to what’s in the PATH environment variable to find the appropriate Ruby to execute your script with.

I can just go on using Typora for Markdown, but it would be nice to use TextMate. But I need GitHub-flavored Markdown for this project.

m.

PS It is clear that the GitHub Markdown bundle is working in the sense that if I use code fences with a language, it is correctly formatted in the `.md` file. The problem is that I can't _render_ the Markdown.

When it comes to the Markdown preview command, you can see here [4] that it’s invoking Ruby 1.8.7. As for the redcarpet part, that comes from GitHub-Markdown bundle, which is invoking system Ruby here [5]. If you change [5] to the path of your Ruby 2.6.3p62 it should work.

[1] https://github.com/textmate/ruby.tmbundle/blob/efcb8941c701343f1b2e9fb105c678152fea6892/Commands/Run.tmCommand#L10

[2] https://github.com/textmate/ruby.tmbundle/blob/efcb8941c701343f1b2e9fb105c678152fea6892/Commands/Run.tmCommand#L12

[3] https://github.com/textmate/ruby.tmbundle/blob/efcb8941c701343f1b2e9fb105c678152fea6892/Support/RubyMate/run_script.rb#L46

[4] https://github.com/textmate/markdown.tmbundle/blob/c6b2d79cafcd8619c79acd79a04e7f5927062aa1/Commands/Markdown%20preview.plist#L12

[5] https://github.com/textmate/GitHub-Markdown.tmbundle/blob/2b58b061e3a59d794b1c5e3a87526f2a544898f2/Support/bin/redcarpet.rb#L1

-- 
/Jacob Carlborg