疑难解答“[Errno 2]没有这样的文件或目录”

时间:2013-09-09 19:51:40

标签: ruby sass sublimetext2

当我尝试使用sass时,我得到“许可被拒绝”。我正在使用Sublime Text 2和当前版本的Ruby以及bones theme

以下是我的终端/代码的屏幕截图:

enter image description here

以下是我在SublimeText中保存的内容:

[Errno 2] No such file or directory
[cmd:  [u'sass', u'--update', u'/Users/jschreiber/sites/wp-content/themes/eddiemachado-bones-405349e/library/scss/_base.scss:/Users/jschreiber/sites/wp-content/themes/eddiemachado-bones-405349e/library/scss/_base.css', u'--stop-on-error', u'--no-cache']]
[dir:  /Users/jschreiber/sites/wp-content/themes/eddiemachado-bones-405349e/library/scss]
[path: /usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
[Finished]

这是我的gem env

administrators-MacBook-Air:~ jschreiber$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.7
  - RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [x86_64-darwin12.3.0]
  - INSTALLATION DIRECTORY: /Users/jschreiber/.rvm/gems/ruby-2.0.0-p247
  - RUBY EXECUTABLE: /Users/jschreiber/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/jschreiber/.rvm/gems/ruby-2.0.0-p247/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
    - /Users/jschreiber/.rvm/gems/ruby-2.0.0-p247
    - /Users/jschreiber/.rvm/gems/ruby-2.0.0-p247@global
  - GEM CONFIGURATION:
    - :update_sources => true
    - :verbose => true
    - :backtrace => false
    - :bulk_threshold => 1000
  - REMOTE SOURCES:
    - https://rubygems.org/

当我按照sublime文本说明运行subl时 - 仍然出现错误:

administrators-MacBook-Air:~ jschreiber$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
ln: /Users/jschreiber/bin/subl: No such file or directory
administrators-MacBook-Air:~ jschreiber$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
administrators-MacBook-Air:~ jschreiber$ subl
administrators-MacBook-Air:~ jschreiber$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
ln: /Users/jschreiber/bin/subl: No such file or directory
administrators-MacBook-Air:~ jschreiber$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
ln: /usr/local/bin/subl: File exists
administrators-MacBook-Air:~ jschreiber$ subl
administrators-MacBook-Air:~ jschreiber$ sites/wp-content/themes/eddiemachado-bones-405349e/library/scss
-bash: sites/wp-content/themes/eddiemachado-bones-405349e/library/scss: is a directory
administrators-MacBook-Air:~ jschreiber$ sass --watch style.scss:../css/style.css
>>> Sass is watching for changes. Press Ctrl-C to stop.
    directory ../css
Errno::EACCES: Permission denied - ../css
            Use --trace for backtrace.

1 个答案:

答案 0 :(得分:0)

让我们来看看你的“当前版本的Ruby”......

您的错误显示了您的路径:

[path: /usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]

将其分解为更具可读性的结果:

[
  path
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/local/bin
  /usr/bin
  /bin
  /usr/sbin
  /sbin
]

这有什么问题?除了你的路径中有18个/usr/local/bin冗余实例,这会在搜索路径时减慢所有命令行应用程序的速度,另一个问题是它们都不是当前的Ruby if您使用的是Mac OS,除非您是从源代码安装的。

  

我使用了RVM

然后,您要么没有关注the directions for installation,要么使用了系统范围的RVM安装,这是RVM作者不必要甚至不推荐的。阅读完整的“安装”说明,然后按照该页面上“尝试新的RVM安装”部分中的步骤进行操作。

要将Ruby与RVM一起使用,您必须修改~/.bash_profile以在shell的启动时加载RVM,此外您还必须告诉RVM使用哪个Ruby:

rvm use ruby-2.0.0-p247 --default

这包含在安装说明中。

Sublime也很可能没有正确设置。尝试使用subl命令从命令行启动Sublime,然后尝试运行代码。如果可行,则意味着Sublime不知道RVM托管的Ruby的适当路径,您需要修复它。 “Sublime Text 2 Integration With RVM and Rspec: Take Number 2”似乎很合理。

使用subl命令启动Sublime的原因与通过启动程序打开它的方式不同,命令行是否使用PATH变量,而启动程序则不然。要协调那些你需要修改plist文件。有关信息,请参阅“How to set PATH for Finder-launched applications”。