当我在vagrant上运行rails时,我收到以下错误。似乎文件“/home/vagrant/Realarts/tmp/pids/server.pid”不存在,但是rails试图访问它。我该如何解决这个问题?
[vagrant@localhost Realarts]$ rails s
=> Booting WEBrick
=> Rails 4.2.4 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:354:in `initialize': Permission denied @ rb_sysopen - /home/vagrant/Realarts/tmp/pids/server.pid (Errno::EACCES)
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:354:in `open'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:354:in `write_pid'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:276:in `start'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/server.rb:80:in `start'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `server'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
from /home/vagrant/Realarts/bin/rails:8:in `require'
from /home/vagrant/Realarts/bin/rails:8:in `<top (required)>'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/client/rails.rb:28:in `load'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/client/rails.rb:28:in `call'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/client/command.rb:7:in `call'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/client.rb:28:in `run'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/bin/spring:49:in `<top (required)>'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/binstub.rb:11:in `load'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/binstub.rb:11:in `<top (required)>'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/vagrant/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/vagrant/Realarts/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
答案 0 :(得分:13)
就像Sri提到的那样,Rails需要所有权来在每次服务器启动时编写和重写pid。
您需要确保您的文件夹可以访问,最简单的方法是从VM运行
sudo chmod -R 777 /home/vagrant/Realarts/tmp/
您也可以使用Vagrantfile
,例如
config.vm.synced_folder ".", "/vagrant", owner: "vagrant",: mount_options => ["dmode=777"]