成功安装后无法运行sass

时间:2014-03-01 23:08:06

标签: ruby rubygems gem sass

我做了sudo gem install sass,成功了。运行sudo sass -v工作正常,但以普通用户身份运行时:

$ sass -v
-bash: /usr/bin/sass: Permission denied

确实,可执行文件的权限是700.我将权限更改为755,但这导致:

$ sass -v
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'sass' (>= 0) among 4 total gem(s) (Gem::LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
    from /usr/bin/sass:22:in `<main>'

我已经谷歌了所有的东西,但无法找到解决方案。这是gem env的输出,如果我sudo gem env,则相同。

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [universal.x86_64-darwin13]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-13
  - GEM PATHS:
     - /Library/Ruby/Gems/2.0.0
     - /Users/ashish/.gem/ruby/2.0.0
     - /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/

我不得不使用sudo进行安装。否则,我得到:

$ gem install sass
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

2 个答案:

答案 0 :(得分:5)

它对我有用: - 首先我安装了Homewbrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

(不要在这一步使用sudo !!)

  • 使用以下命令验证安装:

    brew -v

  • 使用以下命令验证您的Ruby安装:

    ruby​​ -v

  • 使用

    安装sass

    gem install sass

  • 验证gem:

    sass --version

最后做:

rvm list known

现在我有: laomusics-mbp%ruby -v ruby 2.3.0p0(2015-12-25修订版53290)[x86_64-darwin10.0] 在OSX 1068中,MBP。

希望这有助于其他人!

答案 1 :(得分:1)

有同样的问题,也一直在四处寻找。最终我不得不卸载Ruby并重新安装它,只是这次我使用Homebrew,这是一个适合Mac的软件包管理器。

步骤:

现在一切都会好起来的。通过安装gem来测试它,例如sudo gem install sass,一旦完成,检查它是否与sass --version

一起使用

希望这对你有所帮助。