Sshfs, Textmate & Rails project, very slow - ruby-on-rails-3

I am a Linux user and I recently bought a MAC.
I work on a big project that needs to run on a dedicated server.
With Gedit and SSHFS, I had no problem to load the Rails project, same when I create a new controller/model from the command line, refreshing the files tree of Gedit is instantaneous, no slowdowns.
I installed Homebrew, then fuse4x and sshfs. I mount my server like on linux:
sshfs my.server.tld:/home/me Sshfs/my.server.tld/ -o 'volname=MyServer'
so far so good.
I open Textmate then I load my project ... disaster, two minutes+ to load the whole project
I'm switch another window... back to textmate... refresh again with the focus. But fixed with Remate after some research.
But now when creating new resources from command line, I need to refresh whole project for getting new files and it can take two minutes and more
Tried expandrive, same issue.
What the problem ? Textmate ? Sshfs on mac ?
I have googled long time, and most of people doesn't seem to have slowdowns with sshfs
I am a little depressed I had always dreamed to use TextMate !
EDIT:
So, this is definitely TextMate.
I have tried with Sublime Text 2 and it work very very good (better than gedit :p)
Save/open/project refresh are very fast
And even with an NFS share through a VPN it work good.

Both.
TextMate can be very slow and beachball-happy when working over slow networks or networks with big latency. Some years ago, when Fuse was ported to Mac OS X, a plugin was created that inhibited a few features to make TextMate more responsive in such cases. Here it is, I've never used it, though, so no guarantees.
I've never managed to enjoy using SSHFS on Mac OS X: slow save, slow copy, slow open… it was never worth the trouble, even on local network or using Expandrive.

You should try to start textmate from a different directory, so that it writes temp files to local disk.

Related

How to create and share a VM environment for development

I am working on a college project along with a group of people. Our goal is to add features to an already existing application that runs on the web. Currently, I'm in the process of getting the source code to run on my machine. This consists of cloning a bunch of repos, installing MySQL and some (very old and outdated :-| ) versions of Python, and running some scripts. The process sounds straightforward but it isn't; there are a lot of dependancies that need to be met for the code to run, which means that I need to spend a lot of time looking at error logs trying to figure out what package is missing and needs to be installed or downgraded. But that's not the point of this question.
I'd like to make it easier for people to pick up the project in the future and work on it without having to spend hours just to get the code to compile. I'd like to get the project set up on a Linux VM (something I know how to do using VirtualBox) and then somehow share (?) that VM so that other people can simply set it up and be able to immediately have the code compiling (something that I don't know how to do, or if it is even possible).
Additionally, I'd like to be able to do all the coding on the host OS if possible, and only do the compiling/running on the VM (something I also don't know how to do). I would like some help/pointers with all the "I don't know" 's, as I don't know much about VM's other than how to set one up using VirtualBox.
You can use Vagrant to automate the provisioning of the VM, and setup all your tools and dependencies using Docker.
There are many good tutorials and sample vagrantfiles online to get you started. There is a learning curve involved, but well worth the effort. Many companies use Vagrant to quickly provision dev environments.
Vagrant can automatically download a specific distro/version of a VM from the web if one is not already locally installed. It can also provision a Docker container, in which you can install any required dependencies, tools, etc. You can store the vagrantfile, dockerfile, scripts, etc. in GitHub for easy access by your colleagues. All they would have to do is install Vagrant and run vagrant up from the command line.
If you want to write code on the host machine and compile/test it on the VM, you will need to setup a shared folder in the VM using Guest Additions (see here). Be VERY careful with line endings if you are working in Windows and running in Linux. You can setup the shared folder with Vagrant as well (see here).

Install v4l2loopback in WSL2

I am currently struggling with v4l2loopback installation on WSL2.
Some context:
Recently, I have read about create a virtual video device in Linux and then mock its output from an image or video file.
This is quite important for testing or developing purposes, for example in order to attach a virtual webcam that reproduces a video file as a loop to the android emulator.
After some research I got to the conclusion I don't want to use desktop applications and it might be easy to run even in a CI or similar, therefore v4l2loopback looks nice, but I am currently a Windows user.
I enabled WSL2 on my machine, downloaded the repo, and tried to execute make command like in the repo description.
Building v4l2-loopback driver...
make -C /lib/modules/`uname -r`/build M=/home/angel/v4l2loopback modules
make[1]: *** /lib/modules/4.19.84-microsoft-standard/build: No such file or directory. Stop.
make: *** [Makefile:43: v4l2loopback.ko] Error 2
I googled a little bit and i found that issue on GitHub where a similar output (for another tool) is mentioned.
There, someone mentioned that WSL2 Kernel Config can be adjusted in order to add more modules ( maybe and hopefully one of them could make work v4l2-loopback 😂 or at least that I think).
I also googled in order to check out custom WSL builds but I am not really sure what I need to make it work or even if I am going in the right direction.
Is there something I 've missed in order to make v4l2loopback work?
In the case only a custom WSL2 build would work, how should I proceed?
Thanks in advance 🤘
I am not familiar with WSL...
-- Ah, it appears WSL doesn't have a linux kernel at all: see
https://unix.stackexchange.com/questions/594470/wsl-2-does-not-have-lib-modules .
So it's useless building the v4l2loopback mod; even if you'd be able to build it, there's nothing, no kernel, to load it!
Maybe an alternative for you might be running Virtualbox (it's free, and available for Windows) on your windows machine, and load a real Linux distro of your own choice in it. Then build the v4l2loop module, after installing the kernel development headers, and install the mod (after building, as root do insmod v4l2loop.ko) and play with it.
Thus, you are on your way. Far more elegant, and far easier. Also will have you make an enormous and important climb on the 'getting familiar with Linux' ladder, as well as maybe familiarize yourself with a virtual machine(?).
I'd definitely go for that.

How do you use a repl with Vagrant?

I'm looking at simplifying the initial developer setup at my company by using Vagrant. On the surface, it seems pretty nice: I write a Vagrantfile once and commit it, and then new developers just install VirtualBox and Vagrant, git clone our project's source code, and type vagrant up, and they have a running web app, with all the dependencies handled automatically.
The one piece that I'm not sure about is the repl. It's common to run the command to start a shell with the web server's environment, for experimentation or testing or debugging or whatever. (I mean something like rails console. I'm sure every web framework has something similar.)
How do Vagrant users typically do this? Do you just keep a vagrant ssh window open, and run your repl in there? It seems awkward to have to use (potentially) a different window (and operating system) for just this one thing. But in order to run it natively, I'd need to install the whole development environment natively, which defeats the purpose of Vagrant in the first place.
Am I overthinking this? Is there some other practice that people typically use for this?
I think you are overthinking this a bit -- most modern deveopment requires an open command prompt or three, having it be SSH'd into a different box isn't really much different than running it locally in many cases.
Another angle for some things -- like code and scaffolding generation -- is to run those on the local box. Since there is that shared folder it will land on the server and you don't need to switch environments.

Updated OS X to 10.7.5, now I can't connect to local PostgreSQL databases

I'm developing several Rails 3.2 applications on Mac OS X Lion. Last night, I updated from 10.7.4 to 10.7.5, and I found this morning that I'm no longer able to connect to my development Postgresql databases (while my production environments are working just fine, with the same codebases). This is the case for all applications I'm developing locally which use PostgreSQL.
The error message I'm getting every time I try to connect:
PG::Error: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I've read a few other SO posts about similar problems, but most of them suggest PATH changes in ~/.bash_profile. When I run which psql (as suggested in the other posts), though, /usr/local/bin/psql is returned, which is correct (according to the other posts).
I'm hesitant to uninstall and reinstall PostgreSQL again (even via Homebrew), as I don't want to mess with my existing PostgreSQL databases for all of my applications. (Perhaps that's not a potential problem—I'm not confident enough to say.)
I've uninstalled and reinstalled the pg gem several times, closed and reopened my shell session, restarted my machine (and every combination thereof), all to no avail.
Where can I go from here?
Your issue is that PostgreSQL is not running. First I highly recommend backing up PostgreSQL db's before doing OS upgrades because sometimes things don't go well. If you have a dump, you have a lot more options if things go south. I do agree that recompiling on a new OS poses some questions regarding your existing dbs.
The first thing to do of course is to try to start PostgreSQL normally. Maybe it is just missing a startup script. Something like sudo -u postgres pg_ctl -D /path/to/postgresql/data/dir
If that doesn't work you need to look at the error message and try to resolve that. Hopefully it works without problem. If it doesn't work copy your data directory, if you can, to a system running the old version. Try to dump it from there. After you have your copy (important, back up files first!) you may see if you can get pg_upgrade to work. If that fails, try to compile (via homebrew) the same major version you were running before.
If that fails, hire an expert.

How to remotely develop software?

Suppose I have a server that runs on Linux on which I would like to develop software (mainly OCaml, C/C++ and Java).
Is there a way to "remote develop" these things? I mean an IDE that allows me to modify files remotely (they are then uploaded when modified and saved) and to compile through SSH (basically invoking make or omake).
I was looking for something that makes this process transparent to the developer, without caring of doing things by hand. I'm used to use Eclipse so I wonder if a plugin to achieve this exists or if are there other choices?
Mind that it may happen that the local machine it not able to build software I intend to (for example for OCaml) so it should rely just on remote connection.
Thanks in advance
You can use X11 forwarding. Even if you are connecting from a Windows machine.
If you are on Linux, connecting with ssh -Y might work right out of the box for you:
ssh -Y user#your_server
eclipse &
Well the simplest idea I can think of, though it is rather brute force would be to just open up a file share to the server and then edit the file directly through Eclipse.
If that doesn't work for Java at least you could make use of Maven to do some of those tasks. I am less certain about invoking Make though.
I think your answer is IDE-centric.
KDE's ioslaves support access over both SFTP and SSH (using fish, which uses a Perl script uploaded to the remote machine). I believe Gnome also has a virtual file system (gvfs) which supports remote filesystem access.
My recommendation, therefore, is to choose an IDE which supports a virtual filesystem that can operate over SSH/SFTP and allows you to specify the build command. You would then only need to specify the build command which would get its output from the remote make command (for example, vim has a makeprg option which can be set to any arbitrary command).
Depending on how 'remote' this is; why not ssh in and run the IDE remotely over X?
Using a build tool (Hudson for example) you could put a build agent on your remote server, check your changes into your repository as normal, and have it do a build when you check in changes (it will either do a repository hook or poll for changes, probably). Your build process will be the same, it will simply be automated. :-)
emacs has tramp, which lets you both open and save remote files, and open a shell on a remote system. Working with tramp is almost exactly like working with local files, except for the filename. To open 'foo.c' on the machine 'bork' as user 'joe' I open it with the standard emacs commands, giving it the pathname /joe#bork:foo.c
I use vim for remote development. (Well, I use vim also non-remote.)
If building is the problem, have you thought about simply using an automated build system where you commit to svn and the system then automatically builds the software? I've heard many good things about these sorts of systems, although I haven't quite tried any out myself.
As for remote development, a SVnDAV solution might be reasonable. It basically commits your every save and is completely transparent to the text editor you're using. However a probably much nicer solution would simply be to use a networked drive/directory and edit files remotely. On all unix-based systems this should work completely transparently to both the developer and the text editor.
Your choice of IDE will have the most impact on the answer to "can I?". If your IDE of choice is CLI based than you can always just SSH in, fire up screen (so that your CLI session is persistent across SSH sessions), and have at it!
Use vim or emacs since they will offer you speed. I know there is a learning curve associated with these editors; but once you get comfortable in any of them; you will be able to work on them as good as with Eclipse or any other IDE.
If you already have a linux server then I would suggest setting up a simple VPN server. I have done this in the past and it works pretty well. This way you can connect and modify/build your files with any "local" OS. I did this cause I use mac, pc and linux through various parts of the day and in multiple locations, so the VPN allowed me to edit files remotely w/out having to allow file sharing over the internet.
There are plenty of tutorials about how to achieve this even if you are newer to linux. I use ubuntu server on my linux box and here are the tutorial I have used.
http://www.ubuntugeek.com/howto-pptp-vpn-server-with-ubuntu-10-04-lucid-lynx.html
Netbeans 7.3 has a new feature which addresses your problem (and mine). Here's the tutorial.
https://netbeans.org/kb/docs/cnd/remotedev-tutorial.html
note: I realize it has been 3 years since this question was asked so the answer may be irrelevant to #Jack now.
One IDE that supports exactly your language set is Nuclide. It adds some packages to Atom and is used internally in Facebook exactly as you have described - full-fledged remote development in C++, Java, and Ocaml.
If a friendly file editor is enough for you then I'd recommend to use Jupyter.
Super fast installation
Built in server/file editor that starts with one command