2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vagrant で既存のディレクトリを共有したらファイルが全て消えた?

Last updated at Posted at 2019-03-19

環境

ホストOS -> Windows10
ゲストOS -> Ubuntu16.04

やったこと

rails new hello_rails

railsの勉強をするため、上記コマンドを打った後、作成されたファイルをWindows上のエディタから触ろうとして、Vagrantfileに下記の1行を追加する。

config.vm.synced_folder "./vagrant/hello_rails", "/home/vagrant/hello_rails", nfs: true

Vagrantfileを反映させる。

vagrant reload
vagrant ssh

すると、なぜか、railsのファイルが全てなくなっていた。
image.png

再度実行!

再度、railsを作成してみる。

rails new hello_rails

Windowsで確認すると、ゲストOS→ホストOSにファイルが反映されました。
image.png

結論

自分としては、ゲストOS→ホストOSにファイルが共有されると期待していたのだが、どうも、ホストOS→ゲストOSにファイルが共有されたため、空のフォルダがそのまま共有されて、ゲストOS側のディレクトリが全てクリアされたと思われる。くれぐれも、Vagrantfileを触ってファイル共有する時は、ゲストOS、ホストOS共に空の状態から共有しましょうという教訓でした。

2
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?