使用带有Vagrant的本地编辑器 [英] Using a local editor with Vagrant

查看:169
本文介绍了使用带有Vagrant的本地编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常使用原子编辑器进行任何编码工作,并使用代码在我的计算机上安装文件夹。在我的Mac OS电脑上做了一些更新之后,一些红宝石停止工作,rvm不再响应,并且自制软件给了我很多麻烦。我想防止这种情况再次发生,并认为我会使用Vagrant。我喜欢它到目前为止,它工作正常,但是我想使用我的Atom编辑器。

通常,我使用gulp或grunt来处理项目,并在任何更改时编译这些文件。虽然我设法通过FileZilla连接到Vagrant,但我不知道如何将atom连接到它。我需要的只是编辑Vagrant VM中的文件,就像我将它们存储在Mac上的常规目录中一样。任何想法如何解决这个问题?

解决方案

你当然可以使用你当前的工作流程,但你不一定需要连接到你的虚拟机使用Filezilla或其他协议。



最好的方法是查看同步文件夹并同步您的项目目录。默认情况下,vagrant会将您的当前目录(Vagrantfile所存储的目录)同步到vm中的 / vagrant 目录。所以如果您可以将您的项目目录放置在同一个文件夹中,它们将自动同步。



如果 Atom (我不是这个用户编辑器)有一个专门的文件夹存放你的项目文件,你可以添加这个文件夹作为同步文件夹。将以下内容添加到您的Vagrant文​​件中

  config.vm.synced_folder/Users/fhenri/project/tac.local,/项目

在我的例子中,我的主机(mac os)文件夹 /用户/ fhenri / project / tac.local 到vm文件夹 / project ,所以每当我在这个文件夹中进行更改时,如果您使用ruby和gems,那么在本地安装gem可能会很好(在您的项目结构中可以在主机和主机之间共享)。当您进行更改时,它们会自动反映到2个环境中。



当您使用 gulp grunt 你可以从vm启动它们,在一个同步文件夹上工作,并且你将通过mac os host进行的所有更改会自动在vm上找到。我记得在使用默认的虚拟盒子共享文件夹时,自动不闪光灯,你应该允许延迟几秒钟,但它仍然在工作。

如果性能成为问题,您可以查看 nfs同步类型通过进行更改

  config.vm.synced_folder/ Users /fhenri/project/tac.local,/ project,输入:nfs

它应该会提高一点点

I typically use the atom editor for any coding work and have folders on my computer with the code. After doing some updates on my Mac OS computer, some ruby gems stopped worked, rvm no longer responded and homebrew gave me a ton of trouble. I want to prevent this from happening again and figured I'd use Vagrant instead. I like it so far and it works fine, however I want to use my Atom editor nevertheless.

Normally I work on projects using gulp or grunt and they compile the files whenever any changes are made. While I have managed to connect to Vagrant with FileZilla, I have no idea how to connect atom to it. All I need is to edit the files in the Vagrant VM, as I would if they were stored in regular directories on my Mac. Any idea how to solve this?

解决方案

you can certainly use your current workflow but you do not necessarily need to connect to your vm using Filezilla or another protocol.

The best is to look at Synced Folders and synchronized your project directory. By default vagrant synchronized your current directory (where the Vagrantfile is store) to the /vagrant directory in the vm. so if you can place your project directory within the same folder, they will be automatically synchronized.

If Atom (I am not user of this editor) have a special folder where you store your project files, you can add this folder as synchronized folder. Add the following to your Vagrantfile

config.vm.synced_folder "/Users/fhenri/project/tac.local", "/project"

In my case this synchronized my host (mac os) folder /Users/fhenri/project/tac.local to the vm folder /project so whenever I make a change in this folder, I can see the exact same change from the vm.

If you use ruby and gems, it might be good to install the gem locally (within your project structure that you can share between the host and the guest) so they are automatically reflected in the 2 environments when you make a change.

When you're using gulpor grunt you would launch them from the vm, working on a synchronized folder and all the changes you will make from the mac os host would automatically be picked up on the vm. I remember when working with default Virtual box sharing folder, automatically is not flash light, you should allow a few seconds delay but still it is working.

If performance is becoming an issue, you can look at nfs synchronization type by making the change

config.vm.synced_folder "/Users/fhenri/project/tac.local", "/project", type: "nfs"

It should improve a bit

这篇关于使用带有Vagrant的本地编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆