質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.51%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Q&A

解決済

2回答

5918閲覧

rbenv上でbundle execを使うと、bundlerのbinファイルの読み込みに失敗します。

mitsuru793

総合スコア157

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

0グッド

0クリップ

投稿2016/04/15 20:56

現在Gemを作成しています。その際に、guardでテストを実行しようとするとエラーが起きるようになりました。今までは問題なく実行できていて、何が原因となったかはわかりません。test/以下に~.rbファイルがある場合に下記のエラーが起きます。~.rbファイルには何も記述していなくてもです。この原因、またはヒントなることがあれば、教えていただきたいです。

/Users/mitsuru/.rbenv/versions/2.3.0/bin/bundleの22行目のload Gem.activate_bin_path('bundler', 'bundle', version)からのファイルの読み込みに失敗しています。/Users/mitsuru/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/gemsというディレクトリ自体がありませんでした。

また、Gem.activate_bin_pathの挙動について書いてあるページもわかりませんでした。

どうぞよろしくお願い致します。

bash

1❯ bundle exec guard 221:43:56 - INFO - Guard::Test 2.0.5 is running, with Test::Unit 2.5.5! 321:43:56 - INFO - Running all tests 4/Users/mitsuru/.rbenv/versions/2.3.0/bin/bundle:22:in `load': cannot load such file -- /Users/mitsuru/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.11.2/lib/gems/bundler-1.11.2/bin/bundle (LoadError) 5 from /Users/mitsuru/.rbenv/versions/2.3.0/bin/bundle:22:in `<main>' 621:43:57 - INFO - Guard is now watching at '/Users/mitsuru/code/myrepository/dig_yaml_front_matter' 7[1] guard(main)>

環境

OS

  • ProductName: Mac OS X
  • ProductVersion: 10.11.1
  • BuildVersion: 15B42

** その他 **

  • zsh 5.2 (x86_64-apple-darwin15.0.0)
  • rbenv 1.0.0
  • ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]

設定ファイル

/Users/mitsuru/.rbenv/versions/2.3.0/bin/bundle

ruby

1#!/Users/mitsuru/.rbenv/versions/2.3.0/bin/ruby 2# 3# This file was generated by RubyGems. 4# 5# The application 'bundler' is installed as part of a gem, and 6# this file is here to facilitate running it. 7# 8 9require 'rubygems' 10 11version = ">= 0.a" 12 13if ARGV.first 14 str = ARGV.first 15 str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding 16 if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then 17 version = $1 18 ARGV.shift 19 end 20end 21 22load Gem.activate_bin_path('bundler', 'bundle', version)

Gemfile

source 'https://rubygems.org' # Specify your gem's dependencies in schema_validator.gemspec gemspec

Gemfile.lock

PATH remote: . specs: dig_yaml_front_matter (0.1.0) front_matter_parser GEM remote: https://rubygems.org/ specs: awesome_print (1.6.1) coderay (1.1.1) fakefs (0.8.1) ffi (1.9.10) formatador (0.2.5) front_matter_parser (0.0.4) guard (2.13.0) formatador (>= 0.2.4) listen (>= 2.7, <= 4.0) lumberjack (~> 1.0) nenv (~> 0.1) notiffany (~> 0.0) pry (>= 0.9.12) shellany (~> 0.0) thor (>= 0.18.1) guard-test (2.0.5) guard (~> 2.0) test-unit (~> 2.2) listen (3.0.6) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9.7) lumberjack (1.0.10) method_source (0.8.2) nenv (0.3.0) notiffany (0.0.8) nenv (~> 0.1) shellany (~> 0.0) pry (0.10.3) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) rake (10.5.0) rb-fsevent (0.9.7) rb-inotify (0.9.7) ffi (>= 0.5.0) shellany (0.0.1) slop (3.6.0) terminal-notifier (1.6.3) terminal-notifier-guard (1.7.0) test-unit (2.5.5) thor (0.19.1) PLATFORMS ruby DEPENDENCIES awesome_print bundler (~> 1.11) dig_yaml_front_matter! fakefs guard guard-test (= 2.0.5) rake (~> 10.0) terminal-notifier terminal-notifier-guard BUNDLED WITH 1.11.2

Guardfile

guard :test, cmd: "bundle exec test" do # Test files watch(%r{^test/.+_test\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" } watch('test/test_helper.rb') { "test" } end

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

.bundle/config.vendorを削除して、gemをホームディレクトリにある.rbenvから読み込むようにしたらbundle exec guardを実行しても、エラーが起きないようになりました。

投稿2016/04/16 00:41

mitsuru793

総合スコア157

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

ベストアンサー

思うところで言えば、bundle exec からguardを呼び出して、guardがさらにbundle exec を呼び出しています。
以下をしてみるとヒントが得られるかもしれません。

guardだけで叩いてみる。
bundle installを実行してみて、bundleが動くか試してみる。
フォルダ内で rbenv versionを叩いてみる。

投稿2016/04/15 21:15

miyamiya

総合スコア691

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

mitsuru793

2016/04/15 21:54

回答頂き、ありがとうございます。 `bundle install`と`rbenv version`は問題ありませんでした。 ```bash ❯ rbenv version 2.3.0 (set by /Users/mitsuru/.rbenv/version) ``` `guard`を叩いた際は、コードは実行されましたが2回も実行されています。警告は`bundle exec`を使うようにということでした。エラーは`test-unit`で起きていたようです。 ``` ❯ tree test test └── hello_test.rb ❯ cat test/hello_test.rb puts "hello" ``` ```bash ❯ guard Warning: you have a Gemfile, but you're not using bundler or RUBYGEMS_GEMDEPS 06:47:34 - INFO - Guard here! It looks like your project has a Gemfile, yet you are running > [#] `guard` outside of Bundler. If this is your intent, feel free to ignore this > [#] message. Otherwise, consider using `bundle exec guard` to ensure your > [#] dependencies are loaded correctly. > [#] (You can run `guard` with --no-bundler-warning to get rid of this message.) WARN: Unresolved specs during Gem::Specification.reset: power_assert (>= 0) WARN: Clearing out unresolved specs. Please report a bug if this causes problems. 06:47:34 - INFO - Guard::Test 2.0.7 is running, with Test::Unit 3.1.8! 06:47:34 - INFO - Running all tests hello hello /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/method_source-0.8.2/test/test_code_helpers.rb:1:in `<top (required)>': uninitialized constant MethodSource (NameError) from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:105:in `require' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:105:in `block in collect_file' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:123:in `add_load_path' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:103:in `collect_file' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:78:in `block in collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:76:in `each' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:76:in `collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:83:in `block in collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:81:in `each' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:81:in `collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:83:in `block in collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:81:in `each' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:81:in `collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:83:in `block in collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:81:in `each' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:81:in `collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:83:in `block in collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:81:in `each' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:81:in `collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:83:in `block in collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:81:in `each' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:81:in `collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:83:in `block in collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:81:in `each' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:81:in `collect_recursive' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:37:in `block (2 levels) in collect' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:34:in `each' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:34:in `block in collect' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:123:in `add_load_path' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/collector/load.rb:30:in `collect' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/autorunner.rb:94:in `block in <class:AutoRunner>' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/autorunner.rb:400:in `run' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit/autorunner.rb:59:in `run' from /Users/mitsuru/code/myrepository/dig_yaml_front_matter/vendor/ruby/2.3.0/gems/test-unit-2.5.5/lib/test/unit.rb:502:in `block (2 levels) in <top (required)>' 06:47:35 - INFO - Guard is now watching at '/Users/mitsuru/code/myrepository/dig_yaml_front_matter' Frame number: 0/0 [1] guard(main)> ```
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.51%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問