Recently, I need to move some Rails projects I was working on to new computer and this needs me to install all the dependencies for these projects. While using bundler to install the gems; I encountered the following error:
extconf failed, exit code 1
Gem files will remain installed in /Users/ash/.rvm/gems/ruby-2.2.1/gems/libv8-18.104.22.168 for inspection.
Results logged to /Users/ash/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-14/2.2.0-static/libv8-22.214.171.124/gem_make.out
An error occurred while installing libv8 (126.96.36.199), and Bundler cannot continue.
Make sure that `gem install libv8 -v '188.8.131.52'` succeeds before bundling.
Fortunately, with homebrew fixing this (on OSX 10.11, El Capitan at least) worked perfectly. Simply execute these commands:
brew install v8
gem install therubyracer
gem install libv8 -v '184.108.40.206' -- --with-system-v8
There can be no doubt that the easiest way to increase the performance of an old Mac is to replace it’s hard disk with a shiny new Solid State Drive (SSD). The problem with this is that officially Apple only supports TRIM on Apple’s SSDs, effectively removing TRIM support from 3rd party SSDs. TRIM is a system-level command that allows the operating system and the drive to communicate about which areas of the drive are considered unused and thus ready to be erased and rewritten to. In the absence of TRIM, users can see significantly slower drive writes as the drive begins to fill up.
There are tolls people have written to try and get TRIM working for 3rd Party drives, but luckily, with El Capitan, Apple is relaxing the reins and allowing TRIM to be re-enabled for 3rd party SSDs.
To do this, simply open Terminal and execute the command:
sudo trimforce enable
Apple does give you a warning:
This tool force-enables TRIM for all relevant attached devices, even though they have not been validated for data integrity while using that functionality. By using this tool to enable TRIM, you agree that Apple is not liable for any consequences that may result, including but not limited to data loss or corruption.
…but after a reboot (the utility will prompt you) TRIM should be enabled and you’ll be good to go.
As always: Proceed at your own risk. Enjoy.
If you ever need to copy a large amount of data over a network (especially if its a huge number of small files) you can pipe a tar command through a ssh connection, and because tar copies whole blocks at a time, it will be far, far, faster than using SCP.
To execute it, simply:
$ tar czf - <files> | ssh user@host "cd /wherever; tar xvzf -"
I recently had to import a 30GB MySQL database from a backup of a client’s production database. My development workstation really struggled with the hundred’s of thousands of INSERT queries, and the import either took an unacceptably long time or failed outright.
Fortunately, there is a sure-fire way to increase the import though (in my case a 100 fold increase in speed).
Simply open Terminal and type:
> mysql -uXXX -pXXX
…and replace the X’s with an appropriate username and password and then paste this at the MySQL prompt:
CREATE DATABASE my_database;
set global net_buffer_length=1000000;
set global max_allowed_packet=1000000000;
A few notes: ‘set global net_buffer_length’ and ‘set global max_allowed_packet’ only apply if your source filename and path are over a network. Also simply omit the ‘CREATE DATABASE my_database;’ line if you already imported the blank schema, or the database already exists.
Previously I have mentioned an awesome little command-line tool called ‘pv’. Recently, I was trying to restore a clients of legacy database on my development machine, which was a staggering 30GB .sql file. I was having quite a few problems trying to wrestle this beast, the worst of which being that I had no idea how much longer the import would take, or if it had locked up. Luckily, PV comes to the rescue.
Normally, when importing a MySQL dump file, you can just type:
mysql -uxxx -pxxx dbname < /sqlfile.sql
…to import directly from the file. However, you can pv the file and pipe it into the mysql executable like:
pv sqlfile.sql | mysql -uxxx -pxxxx dbname
And you will get an awesome progress bar about how completed the task is. You can also use it in the reverse. You’d be surprised how useful it can be.
I recently had some database woes. I needed to restore a MySQL database of a clients existing website that was dozens of gigabytes in size. I had a great deal of trouble trying to import that data, but that’s a story for another time. This was about getting MySQL installed in the first place (for a development environment).
At first, I tried using Homebrew – because its awesome and I like it. But sadly, for one reason or another the default configuration just wasn’t working for me. It was simple and blind, but too well hidden and I didn’t feel like there was enough “control” (like getting setting/getting the default root password for example). If you’re going to automate something, then automate it – but don’t ask me to run stuff to secure my install when your supposed to be automating it for me. Bah humbug!
However, the wonderful folks at macminivault.com solved all my problems. It was simply perfection. Exactly the right balance of automation and control.
Just open up Terminal and paste this into it:
bash <(curl -Ls http://git.io/eUx7rg)
It will tell you or prompt you for the rest. And don’t forget to get the text file containing the root password, before you mistakenly delete it.
(comic property of http://www.brainstuck.com/)
Installing Ruby with RVM on Mac is a cinch, simply execute:
\curl -sSL https://get.rvm.io | bash -s stable --ruby
But recently, while trying to install RVM instead of the default Mavericks Ruby, the script that normally just “works” fails with the ominous message:
: Requirements installation failed with status: 1.
It turns out to be something funky with Mavericks and the Homebrew step of the installation. Luckily, despite the failure of the script, you can simply install Hombrew manually to solve the problem. Installing Homebrew is a triviality, simply execute the following command in Terminal:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
It will first install the XCode Command Line Tools (don’t worry if you already have it, just hit “install” and let it do it’s thing) and then once the Xcode dialog disappears, hit [any] key in Terminal and it will auto-download and auto-install itself. Once its all finished (and it can take a few minutes, just be patient), simply re-execute the command to install RVM Ruby.
Just like when using Windows, sometimes it is necessary to make special hidden system files visible to Finder. There is no preference for it, but with a simple Terminal command, things can be made visible very easily, on a privileged user account.
Simply open the ‘Terminal’ application, and at the prompt, type:
defaults write com.apple.finder AppleShowAllFiles TRUE
This will cause all Finder windows to close and then reopen with the hidden files, visible and identifiable with a ghost-like appearance. You should be able to interact with them normally now.
Forget what I said. Install Homebrew (really, do it now) and use HomeBrew to install it.
Pipe Viewer (pv) – is a terminal-based tool for monitoring the progress of data through a pipeline. It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion. However, it isn’t included by default in Mac OSX.
The good news is that there are several ports of pv, you just need to go and grab one:
- HomeBrew: Run “
brew install pv” to get the latest version.
- MacPorts: Run “
port install pv” to get the latest version.
- Or (recommended) install the Rudix pv port (a simple package installer)
Pv allows you to get a really awesome progress of your terminal commands to see how things are going; especially useful for long operations (such as cp or tar etc) so you know everything is ticking over time (and perhaps even giving an ETA for completion):
13.2GiB 1:33:17 [3.57MiB/s] [================================> ] 67% ETA 0:44:4
I highly recommend this for anyone doing long, large or complicated terminal commands. It’s outstanding! To learn more about using Pipe Viewer, this is a great resource.