【问题标题】:Vim Command-T plugin error: could not load the C extensionVim Command-T 插件错误:无法加载 C 扩展
【发布时间】:2011-12-16 21:41:58
【问题描述】:

我正在尝试安装 Command-T 插件。

我按照此评论中的说明编译了 vim:Installing vim with ruby support (+ruby)

所以现在有了 +ruby 标志,但是当我尝试使用该插件时仍然出现此错误:

command-t.vim could not load the C extension
Please see INSTALLATION and TROUBLE-SHOOTING in the help              
For more information type:    :help command-t

我的系统上有红宝石:

> ruby -v
> ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

建议?

【问题讨论】:

  • 您可能想看看ctrlp.vim,它与Command-T 基本相同,但用纯Vimscript 编写。这意味着它既不需要在 Vim 中启用 Ruby 支持,也不需要编译一些用 C 实现的 Ruby 扩展。
  • Ctrl+P 也不错,但它处理大型项目的能力不如 Command+T

标签: ruby vim plugins


【解决方案1】:

Command-T 需要一个已编译的组件。错误消息表明您没有完全按照插件的安装说明进行操作。

【讨论】:

    【解决方案2】:

    查看安装说明:https://github.com/wincent/Command-T 在该页面上搜索标题“安装”。您很可能没有遵循此官方自述文件中的说明。如果您使用的是 RVM,请确保使用系统 ruby​​。这些都在文档中注明。

    【讨论】:

      【解决方案3】:

      转到插件目录并运行以下命令:

      rake make
      

      它编译你需要的插件扩展。

      【讨论】:

      • @CoreyRothwell 做到了 2 天。天哪,有时我需要在一遍又一遍地查看文档之前使用谷歌搜索。
      • RVM 用户确保您使用的正是 Vim 在错误消息中所说的 ruby​​ 版本
      【解决方案4】:

      我遇到了同样的错误,但在仔细阅读手册后,我发现以下内容很有帮助。

      标记自 https://github.com/wincent/Command-T 中的 INSTALLATION 部分

      然后必须构建 C 扩展,这可以从 shell 完成。如果你 使用典型的 |'runtimepath'|然后将文件安装在 ~/.vim 和 您可以使用以下方式构建扩展:

      cd ~/.vim/ruby/command-t/ext/command-t
      ruby extconf.rb
      make
      

      【讨论】:

      • 上面建议rake make 的评论对我不起作用。我用 vundle 安装了 CommandT,但没有 Makefile。要添加到此答案,我必须转到 ~/.vim/bundle/Command-T/ruby/command-t 并运行此处建议的命令。对于我的系统,这还涉及安装 ruby​​-dev 软件包。谢谢 peralmq!
      • 现在 extconf.rb 的正确目录是:“/command-t/ruby/command-t/ext/command-t/”。如果再次更改,您可以在github.com/wincent/command-t/find/master 搜索“extconf.rb”。
      • 使用与 vim 相同的 ruby​​ 版本运行 ruby​​ 命令“ruby extconf.rb”。这不应该使用 rvm 或其他 ruby​​。它应该是您系统上安装的 ruby​​。
      【解决方案5】:

      您必须使用与 Vim 本身链接的相同版本的 Ruby 执行构建。

      您使用的是 RVM 还是 rbenv?就个人而言,我使用的是 rbenv 和 MacVim。我有这个错误是因为我尝试使用 ruby​​ 1.8.7 补丁 352。我使用rbenv shell system 切换回1.8.7 补丁249 之前 运行ruby extconf.rbmake,然后一切正常。

      之后,您可以使用 rbenv shell --unset 恢复您的 shell。

      【讨论】:

        【解决方案6】:

        如果您确定您按照the github project 上的说明进行操作,您可能需要重新启动 vim 和终端。我遇到了同样的问题,当我重新启动 Vim 时,它终于成功了!

        【讨论】:

          【解决方案7】:

          在 debian 挤压上,我还必须使用 apt-get install libjson-ruby1.8 为 ruby​​ 安装 json 库

          【讨论】:

            【解决方案8】:

            我遇到了类似的错误,并按照其中一个答案的建议尝试了rake make,该答案也运行ruby extconf.rb,但出现以下错误

            ─$ rake make
            /usr/bin/ruby2.3 extconf.rb
            mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
            rake aborted!
            Command failed with status (1): [/usr/bin/ruby2.3 extconf.rb...]
            /home/shreedhan/.vim/bundle/command-t/Rakefile:84:in `block (2 levels) in <top (required)>'
            /home/shreedhan/.vim/bundle/command-t/Rakefile:83:in `chdir'
            /home/shreedhan/.vim/bundle/command-t/Rakefile:83:in `block in <top (required)>'
            Tasks: TOP => make
            (See full trace by running task with --trace)
            

            您需要安装ruby-develruby-dev,具体取决于您的发行版上是否有yumapt

            yum install ruby-devel
            

            $ apt install ruby-dev
            

            【讨论】:

              【解决方案9】:

              最终,经过反复试验,我在处理 Mac OS 问题的 command-t FAQ 中找到了这个命令。我正在运行“High Sierra 10.13.4”:

              ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future ruby​​ extconf.rb

              这似乎生成了一个成功运行编译的 Makefile。虽然我尝试了很多东西,但这个解决方案感觉有点货物狂热。

              【讨论】:

                【解决方案10】:

                我通过以下步骤解决了这个问题:

                1. 在你的 ~/.vim 中找到你的 ruby 文件夹,因为在 ~/.vim/ruby 中找不到我的文件夹
                2. find . -name "extconf.rb"- 找到 extconf.rb 文件,该文件可能位于 command-t 文件夹中
                3. ruby extconf.rb
                4. make
                5. 重新打开vim

                阅读 vim 中的文档可能也很有用 (:help command-t)

                【讨论】:

                  猜你喜欢
                  • 1970-01-01
                  • 1970-01-01
                  • 2012-06-02
                  • 2014-03-06
                  • 2014-07-06
                  • 2015-08-30
                  • 2017-09-20
                  相关资源
                  最近更新 更多