“No such file or directory - getcwd” error on ruby

2019-02-02 19:41发布

I'm trying to launch a heroku console that uses rubygems but I keep getting this error:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:471:in `expand_path': No such file or directory - getcwd (Errno::ENOENT)
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:471:in `find_files'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:470:in `map'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:470:in `find_files'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:1103
    from /usr/bin/heroku:9:in `require'
    from /usr/bin/heroku:9

I'm using Mac OS Lion 10.7.3. Any ideas on how to fix this? Thanks!

12条回答
霸刀☆藐视天下
2楼-- · 2019-02-02 20:03

This just happened to me while I was running a Sinatra app on my localhost and this is what I found.

Scenario: I'm using Git as my version control and I switched branches from development to master to merge my branches. After the merge, with an active server running, I made a minor html change which shouldn't have blown up the app and when I went to check the change in my broswer my "request" came back with OP's error - just to note this app isn't deployed to heroku.

My guess: I'm not familiar with the intricacies of Webbrick (or equivalent programs) but I'm guessing you had an active server running (like me) and it was was looking for specific file(s) in memory and when they were modified on a possible branch change or an important file was modified/deleted - Webbrick freaked out and didn't know where to find it/them and threw up this error.

I'm not sure what version control you're using but I know git is popular for heroku so I think this might have something to do with your issue.

Fixing the issue for myself was as simple as restarting the server, hope this helps future trouble shooters.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-02-02 20:09

Restart system fixed this problem in my case

查看更多
混吃等死
4楼-- · 2019-02-02 20:10

I solved this problem by closing and restarting my terminal, setting the correct Ruby version in the new Terminal to

$ rvm use 2.1.1

(or whatever Ruby version is relevant to your program)

查看更多
兄弟一词,经得起流年.
5楼-- · 2019-02-02 20:14

Maybe the current working directory of the shell that's used to start your heroku process doesn't exist (maybe removed by another process, as in my case), and therefore getcwd throws an error.

查看更多
Summer. ? 凉城
6楼-- · 2019-02-02 20:14

I had the same thing, just type cd in the terminal, then navigate back to where you were and it works.

查看更多
Viruses.
7楼-- · 2019-02-02 20:16

I encounter a same one, it happened when the working directory has actually been removed.

查看更多
登录 后发表回答