Rails generate error: No such file or directory - getcwd

牧云@^-^@ 提交于 2019-12-18 19:38:07

问题


When running rails generate on a new Rails 4.2 project, I keep getting the error:

~/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/spring-1.3.0/lib/spring/configuration.rb:37:in `pwd': No such file or directory - getcwd (Errno::ENOENT)

How can I fix this?


回答1:


The error is caused by an existing Rails Spring process running in the background.

You can easily solve this by running ps ax | grep spring to find the process id and then kill it.

There's an issue on the Rails GitHub about this: https://github.com/rails/spring/issues/247




回答2:


This error may also occur if you are working in a directory which was deleted from some other terminal instance.




回答3:


If the directory (or some sub directory Rails will work with) you are working was renamed or removed, you'll have to run

cd .

and then you can run rails generate [...].




回答4:


On my machine the same problem was arising because spring server stopped responding.

1:- To restart the spring server type in terminal

$: spring restart

2:- Try running the generator again.



来源:https://stackoverflow.com/questions/28390149/rails-generate-error-no-such-file-or-directory-getcwd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!