これが私のルビースクリプトです:
require_relative 'lib/say.rb'
say("hello")
私は経由でmacvimから実行し:w ! ruby
、得ました:
:w ! ruby
-:1:in `require_relative': cannot infer basepath (LoadError)
from -:1:in `<main>'
shell returned 1
vim! ruby %
コマンドは正常に動作しますが。また、を変更するrequire_relative...
ことrequire File.expand_path('../lib/say', __FILE__)
も役立ちます...
しかし...これらの友達の実際の問題は何ですか: require_relative
+ :w ! ruby
?
なぜこれが必要なのですか?vimで使用するだけで⌘</kbd> + R shortkey from the vim-ruby-runner plugin which is based on :w !ruby
vim command and have my code looks better with require_relative
...
PS SO で次の質問を見つけました: Ruby パスに現在のディレクトリがないのはなぜですか? 後者のソースも私の問題に対応しているようです...しかし、そこから必要なすべての回答を得るのは困難でした。