找不到用bundler安装的gem

时间:2015-08-06 07:17:29

标签: php symfony sass bundler compass

对于我的PHP Symfony应用程序,我需要Compass和Sass。两者都应该安装在我项目的vendor/bundle文件夹中。

这是我到目前为止所做的:

$ gem install bundler
Successfully installed bundler-1.10.6
1 gem installed

$ bundle install --path vendor/bundle
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
// ... Installing some gems
Using bundler 1.10.6
Bundle complete! 2 Gemfile dependencies, 10 gems now installed.
Bundled gems are installed into ./vendor/bundle.

现在问题就出现了。当我执行其中一个已安装的宝石时,我收到以下错误:

$ vendor/bundle/ruby/1.9.1/bin/compass 
/usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:315:in `to_specs': Could not find 'compass' (>= 0) among 30 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/usr/local/rvm/gems/ruby-1.9.3-p551:/usr/local/rvm/gems/ruby-1.9.3-p551@global', execute `gem env` for more information
    from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:324:in `to_spec'
    from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_gem.rb:64:in `gem'
    from vendor/bundle/ruby/1.9.1/bin/compass:22:in `<main>'

我认为它看起来在$ GEM_PATH中,当然找不到它。但是我该如何解决这个问题呢?我不想将gem路径更改为项目文件夹。

1 个答案:

答案 0 :(得分:2)

使用Bundle,您应该使用Bundle Exec command启动应用程序。对于发射指南针,你可以做,例如:

$ bundle exec compass watch

$ bundle exec compass compile

查看this nice article了解更多信息。

希望这个帮助