_____100 |> F# Some Troubleshooting Linux

In the last article I wrote on writing a code kata with F# on OS-X or Windows, I had wanted to use Linux but things just weren’t cooperating with me. Well, since that article I have resolved some of the issues I ran into, and this is the log of those issues.

Issue 1: “How can I resolve the “Could not fix timestamps in …” “…Error: The requested feature is not implemented.””

The first issue I ran into with running the ProjectScaffold build on Linux I wrote up and posted to Stack Overflow titled “How can I resolve the “Could not fix timestamps in …” “…Error: The requested feature is not implemented.”“. You can read more about the errors I receiving on the StackOverflow Article, but below is the immediate fix. This fix should probably be added to any F# Installation instructions for Linux as part of the default.

First ensure that you have the latest version of mono. If you use the instructions to do a make and make install off of the fsharp.org site you may not actually have the latest version of mono. Instead, here’s a good way to get the latest version of mono using apt-get. More information can be found about this on the mono page here.

apt-get install mono-devel
apt-get install mono-complete

Issue 2: “ProjectScaffold Error on Linux Generating Documentation”

The second issue I ran into I also posted to Stack Overflow titled “ProjectScaffold Error on Linux Generating Documentation“. This one took a lot more effort. It also spilled over from Stack Overflow to become an actual Github Issue (323) on the project. So check out those issues in case you run into any issues there.

In the next issue, to be published tomorrow, I’ll have some script tricks to use mono more efficiently to run *.exe commands and get things done with paket and fake in F# running on any operating system.

OS-X and F# [Clone It, Build It, Install It, Hack It]

Ok.

Mission: Get F# running on OS-X and executing via repl.

There are a number of steps here, that if you don’t have everything covered things just won’t work. So let’s knock out the prerequisites first. This will include getting autoconf installed. There are some other tools that I’ve added below that are good to have installed too, so get autoconf, automake, and libtool installed.

export build=~/devtools # or wherever you'd like to build
mkdir -p $build
 
cd $build
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-2.68.tar.gz
tar xzf autoconf-2.68.tar.gz
cd autoconf-2.68
./configure --prefix=/usr/local
make
sudo make install
export PATH=/usr/local/bin
  
cd $build
curl -OL http://ftpmirror.gnu.org/automake/automake-1.11.tar.gz
tar xzf automake-1.11.tar.gz
cd automake-1.11
./configure --prefix=/usr/local
make
sudo make install
 
cd $build
curl -OL http://ftpmirror.gnu.org/libtool/libtool-2.4.tar.gz
tar xzf libtool-2.4.tar.gz
cd libtool-2.4
./configure --prefix=/usr/local
make
sudo make install

Now we’re ready to get some F# (64-bit flavors too) running on OS-X. This is very likely to take more than a few minutes because we’ve got two actual builds to do here.

First step is to get mono built and installed.

git clone https://github.com/mono/mono
cd mono
./autogen.sh --prefix=/mono64 --enable-nls=no
make
sudo make install

Now clone fsharp, build and install it.

git clone https://github.com/fsharp/fsharp
cd fsharp
./autogen.sh --prefix=/mono64
make
sudo make install

Finally get the binary executable paths added to the paths file.

vi /etc/paths

Add the following paths to the paths file.

/mono64/bin/mono
/mono64/bin

Once that’s done, run the tests to confirm everything has built right and is operable.

cd tests/fsharp/core
./run-all.sh

Now… that should all be ok.

repl

What I wanted now is something to sling some code and execute it. The easiest way, is to use the ‘fsharpi’ repl. At the OS-X terminal launch the repl.
Enter this line…

let x = 5;;

Then let y to a value…

let y = 20;;

Then enter…

y + x;;

…and you should see the math calculated. Then you can quit out of the repl with the following command.

#quit;;

The overall repl should come out looking like this.

> let x = 5;;

val x : int = 5

> let y = 20;;

val y : int = 20

> y + x;;
val it : int = 25
> #quit;;

- Exit...

Compilation – A Step Further

Just to show one more step. Let’s do a compile of a file with F# Code in it. Create a file called process.fs and enter the following code.

open System

[<EntryPoint>]
let main (argv :string[]) = 
    printfn "Hello World" 
    Console.ReadLine() |> ignore
    0

Now run the compiler ‘fsharpc’.

fsharpc process.fs

Now before you freak out screaming “OMG WTF am I supposed to do with a process.exe file…!!!” just calm down and execute the following command.

mono process.exe

There you’ll see the execution of “Hello World”. Welcome to F# on OS-X. More to come, Keep thrashing code!

Note: I’ve got a github repo for this and coming F# coding available at sharpgrounds.

git-flow

No excuse not to have your branching strategy taken care of, because: git-flow

First, get it installed. This takes less than a minute, at least on a *nix based machine. I’ve no idea what it takes on Windows, but hey, at least it’s available there too! I did a clean curl and install as shown. It took about 14 seconds solely because I wasn’t typing very fast today.

12:28 $ curl -L -O https://raw.github.com/nvie/gitflow/develop/contrib/gitflow-installer.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  2145  100  2145    0     0   1732      0  0:00:01  0:00:01 --:--:--  1732
~
12:28 $ sudo bash gitflow-installer.sh
Password:
### gitflow no-make installer ###
Installing git-flow to /usr/local/bin
Cloning repo from GitHub to gitflow
Cloning into 'gitflow'...
remote: Counting objects: 1407, done.
remote: Total 1407 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (1407/1407), 623.29 KiB | 428.00 KiB/s, done.
Resolving deltas: 100% (689/689), done.
Checking connectivity... done.
Updating submodules
Submodule 'shFlags' (git://github.com/nvie/shFlags.git) registered for path 'shFlags'
Cloning into 'shFlags'...
remote: Counting objects: 454, done.
remote: Total 454 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (454/454), 130.91 KiB | 0 bytes/s, done.
Resolving deltas: 100% (337/337), done.
Checking connectivity... done.
Submodule path 'shFlags': checked out '2fb06af13de884e9680f14a00c82e52a67c867f1'
install: gitflow/git-flow -&gt; /usr/local/bin/git-flow
install: gitflow/git-flow-init -&gt; /usr/local/bin/git-flow-init
install: gitflow/git-flow-feature -&gt; /usr/local/bin/git-flow-feature
install: gitflow/git-flow-hotfix -&gt; /usr/local/bin/git-flow-hotfix
install: gitflow/git-flow-release -&gt; /usr/local/bin/git-flow-release
install: gitflow/git-flow-support -&gt; /usr/local/bin/git-flow-support
install: gitflow/git-flow-version -&gt; /usr/local/bin/git-flow-version
install: gitflow/gitflow-common -&gt; /usr/local/bin/gitflow-common
install: gitflow/gitflow-shFlags -&gt; /usr/local/bin/gitflow-shFlags
~

For installation instructions check out the link here: https://github.com/nvie/gitflow/wiki/Installation

Now that everything is setup. Here’s the quick getting started of creating a repo, linking it up to a remote and working in a repository. The first step is to initialize a new repo. Continue reading

Getting Started with Swift, For NON-Apple Devs

This past weekend I attempted to get started with Swift coding. Since I have not been an Apple Developer for a while, it wasn’t immediately obvious how to get started. But once I fumbled around a few minutes I realized I needed a developer account to get the latest XCode. Jeez, it really shows how much Apple loves to lock you in hard core to their development ecosystem. An unfortunate trait of a company that is actually extremely closed in much of its behavior, while taking advantage of so much of the open source community. But I digress, this isn’t a rant about the unethical behavior of Apple. I’ll reserve that for the novels worth of material it deserves.

One I signed up for the developer program, which costs $99 bucks, I immediately made my first huge mistake. This damnable mistake blew the entire weekend of hacking. I added under “Company” my simple DBA (Doing Business As) name. I already had an account, and because of this change for making this existing account become a developer account from a personal base level account, sprung a red flag. I checked back frequently over the weekend, but it wasn’t until Monday that somebody checked the app, realized the Company name I added was merely a DBA and ok’d my account. So far, 38 hours down the drain for getting started hacking on Swift! Dammit.

However, this morning I was happy to find everything was ok’d, and thus, the remaining bit of this blog entry is a bit more example and a little less story of my day.

Developer @ Apple

Developer @ Apple

Getting XCode 6 beta

I wanted to do Swift hacking, the first step was to download XCode 6 beta. That’s available via download on the iOS Developer page (and I suppose the Mac Developer page). Scroll down on that page until you find the XCode Download button.

The Warnings and the Download XCode 6 beta page.

The Warnings and the Download XCode 6 beta page.

Also note, if you’re looking to do Swift hacking like I’m doing here, I’d actually advise against getting the iOS 8 beta or OS-X Yosemite Developer Previews right now. Best to keep as stable a machine while toying around with a new language. At least, that’s what the conversations have been so far…

OS-X Yosemite & iOS 8

OS-X Yosemite & iOS 8

Once I got Xcode 6 beta installed I dove right into creating a Swift Project. I created a simple new project that is empty to just check out what Xcode 6 provides out of box for the Swift Project.

Selecting an empty Xcode 6 beta project to use with Swift.

Selecting an empty Xcode 6 beta project to use with Swift.

The next dialog is where the Swift magic is selected.

Selecting Swift, entering a project name and other information dialog.

Selecting Swift, entering a project name and other information dialog.

After that I just clicked through on defaults until I got into the Xcode IDE with the project open.

Selecting the appropriate simulator.

Selecting the appropriate simulator.

Next I executed the project. Since I’d had my phone attached it wanted to run it there, but I have 7.1 iOS on it which won’t execute Swift code. I had to select the appropriate simulator then to run the application project. Once that ran, since I’d not done so on this particular computer, I needed to enable developer mode.

Enabling developer mode.

Enabling developer mode.

I did so and the empty application launched.

An empty iOS 8 iPad Retina Application.

An empty iOS 8 iPad Retina Application.

So that’s the basic getting started, no code actually slung. But rest assured I’ll have another post soon detailing some first code snippets. I also hope to get some comparisons written up between XCode with Swift and Xamarin Studio and C#. It’s cool that Apple finally has a modern feature rich language, so it’ll be interesting to see how each stacks up from a language and IDE perspective.

References:

Using SSH Locally to Work With Ubuntu VM + VMware Tools Installation via Shell

I do a lot of work with Ubuntu, 90% or so of that work is from an Ubuntu instance. Often that instance happens to be a local VM running in VMware Fusion (or sometimes Virtual Box). Often I’ll start with a base server image which isn’t entirely setup for SSHing into the instance. These are the steps to get that installed and ready to go.

First install the image, in this particular situation I’m using the Ubuntu 12.04 LTS Server image.

Ubuntu 12.04 Server. Click for full size image.

Ubuntu 12.04 Server. Click for full size image.

That will take a few minutes to install, on machines these days I’ve experience just about 8-15 minutes. There are a million other options to do this too, such as starting with a clean Ubuntu image using Vagrant, which takes all of about 1-2 minutes, sometimes a bit more if you have to download the image. But either way, get one built and running.

Installing Ubuntu using VMware Fusion. Click for full size image.

Installing Ubuntu using VMware Fusion. Click for full size image.

Once the image is installed, login and install openssh-server and openssh-client.

sudo apt-get install openssh-server openssh-client

Once that’s installed I pull up my IP address with ifconfig.

ifconfig

The ifconfig command shows a lot of information regarding the network configuration associated with the various network adapters in the machine that it is executed on. In the image I’ve circled the local IP address that is assigned to the instance.

The local IP address using the ifconfig command. Click for full size image.

The local IP address using the ifconfig command. Click for full size image.

Now that you have the local IP of the instance, bring up a local terminal (in this case I’m on OS-X, but if you’re on Windows pull up Putty or on Linux or another *nix variant pull up a shell). In the terminal you can now enter the follow SSH command to log in from the local machine versus the running instance. This comes in handy when you want to treat the machine like an actual hosted machine somewhere, in which you wouldn’t be directly logged into the server.

ssh username@192.168.77.197
Logged In.

Logged In.

Getting VMware Tool Installed

This assumes that you mount the installation files (aka the cdrom) via the built into mount option in the VMware Fusion menu.

Selecting 'Reinstall VMware Tools' to mount the installation files. Click for full size image.

Selecting ‘Reinstall VMware Tools’ to mount the installation files. Click for full size image.

Once that’s mounted, the machine is ready to install the tools on. However, there are a few other things to install just before installing these. First get the latest updates for apt-get with the update command.

sudo apt-get update

Now install the latest gcc, make, kernel headers and other important tools.

sudo apt-get install gcc make build-essential
sudo apt-get install linux-headers-$(uname -r)

In the above, everything can be put on one line, but I separated the linux-headers just for extra clarity. I can now via remote SSH on the local machine or directly into the virtual machine and run the following commands to install the VMware Tools.

sudo mkdir /mnttools
sudo mount /dev/cdrom /mnttools
tar xzvf /mnttools/VMwareTools-x.x.x-xxxx.tar.gz -C /tmp/
cd /tmp/vmware-tools-distrib/
sudo ./vmware-install.pl -d

Finish everything up with a good reboot.

sudo shutdown -r now

Now I have the VMware Tools installed and able to SSH remotely, giving me the ability to use the virtual machine as I would an actual hosted instance.

That Was Fun, Done With The Lenovo Carbon X1, Back to GSD!

Over the last couple of months I’ve been double laptoping it. I’ve had a Lenovo Carbon X1 with Windows 8 and Ubuntu dual boot configuration with 8GB RAM, 256GB SSD and i7 and I had a Mac Book Air (MBA) 8GB, 512GB SSD and i7 Proc. The MBA was my primary work machine with the Lenovo being a secondary machine that I was using to test and build Windows 8 Applications and for building native Linux services and related code work.

Windows 8 Critique

Simply, Windows 8 is one of the most broken operating systems I’ve used since Windows ME. Forget Vista, I consider it officially dethroned. Let me clarify what is and isn’t horrible about Windows 8 though. It isn’t that it technically is a bad operating system, it’s that the idea and approach that Microsoft has taken is inherently flawed at several key points.

First, having a desktop on a tablet, which is almost impossible except for all but the finest of finger pointing tablet users, is blindingly stupid. Just go into any place where there is a Windows 8 tablet user and watch them whacking away when they get into the desktop.

The Windows 8 desktop on a tablet is patently absurd for the vast majority of potential Windows 8 users.

However, the straight Metro Interface of Windows 8 (which Microsoft now calls the Windows 8 interface because of legal reasons) is magnificent for tablet usage. There are a few major things that need fixed: responsiveness related to connection state, update status and the availability of high quality applications. Once those things are fixed Windows 8 will be as competent as iOS or Android in the usability department. Until then, it’s a nice dream, with a small number of usable apps with a huge potential.

Now the desktop is the tried and true classic desktop of Windows. Thus, when you’re on a desktop machine or a laptop with a dedicated pointing device or touch screen the back and forth is fine. Matter of fact it is great! I find myself using the touch screen regularly to do a number of tasks, and hope to see its use increase more and more on a number of platforms (yo Apple, got game on this yet or not, OS-X can definitely use a touch interface).

Overall though, Windows 8 – unless you solely do Windows 8 Development, is not a reason to buy a Lenovo X1 Carbon.

Ubuntu Critique

Minus the touch screen, which Ubuntu has no clue what to do with except treat it like a pointer, this is how you see the real power and beauty of the Lenovo X1 Carbon. Ubuntu loads 2x faster and shuts down 2x faster than Windows 8. Comparable builds in IntelliJ, C, C++, Erlang and other compilers are regularly 1.2-3x faster than on Windows. The servers that one would build against, such as GlassFish (see this for my latest on setting up GlassFish & Java 7) are also routinely faster, more responsive and less prone to difficulty than in Windows.

One of the problems that is ongoing, is it is hard to move to Ubuntu unless you are doing dev. Using Adobe tools is a non-starter, best to stick to slow Windows or get real fast using OS-X. Again though, if it runs on Windows and Linux, I’d take a safe guess that the Linux versions will be faster, probably more stable, and all around it’ll likely work better over time. There is something to that whole unix way about building things. One other big booster for Ubuntu, is writing JavaScript, which I do regularly these days is a much better experience than on Windows. I use standard tools, that usually are available on Windows, but launching Sublime 2 or WebStorm is just faster, noticeably, on Linux versus Windows 8 (or whatever version really).

So overall, if you’re going to get a Linux machine, the Lenovo X1 Carbon is a prime choice. If not one of the best. If I understand correctly, there may even be some solid Linux software out there that would make the touch screen more usable too. So if you’re adventurous you may be able to solve that one single issue that I had with Linux running on the X1.

Would I Give Up My Mac for the X1?

This is easy, the answer is absurdly simple. However I did give up the Mac Book Air I had in parallel with the Lenovo for several months, as it belonged to Basho (which I’ve departed from).

Hell no!!!

Matter of fact, even though I’ve used the laptop extensively with Ubuntu and Windows 8, I’ve just bought a new Mac Book Pro Retina 15″ to do all of my work with Ubuntu, Windows 8 and OS-X. The solidness of the MBP is untouchable compared to the X1. The screen is better, the keyboard is more consistent and easier to type on, the ghost tracking of the track pad is non-existent on the air, versus the X1 Carbon. In this case, I’d even turned off the trackpad entirely on the X1 Carbon. Simply, the X1 Carbon just doesn’t measure up to the Mac Book Pro.

Other observations I’ve made about the two machines. The Mac Book Pro is far more solid, the construction is just not even comparable. The X1 feels solid but compared to the MBP it feels cheap and flimsy. Considering the hardware works flawlessly with the software on the MBP is also no competition. The Carbon regularly needed driver updates, things would flake out and I’d have to restart. This would be prevalent in windows or linux, it didn’t matter. Fortunately a restart would fix it, but none of these issues exist on the MBP, using either OS-X or running a VM with Windows 8 or Ubuntu.

Also, even though the MBP design is over a year old now, the i7, 16 GB RAM and 512 GB SSD makes the X1 Carbon seem like a morbidly out of date, slow and antiquated device even though it is actually a newer device!

So, would I give up my mac for the X1?

Getting Distributed – BOOM! The Top 3 Course Selections

A few months ago I posted a poll to ask what courses I should put together next. I just wrapped up and am putting the final edits and finishing touches on a Pluralsight Course on distributed databases, focusing on Riak. On the poll the top three courses, by a decent percentage of votes included the following:

  1. Node.js Distributed Systems – Bringing the Node.js Nodes together for Distributed Noes of Availability and Compute @ 12.14% of the vote.
    1. A Quick Intro to Node.js
    2. Introduction to Relevant Distributed Patterns
    3. How Does Node.js Fit Into the Distribution
    4. Working With Distributed Systems (AKA Avoiding a Big Ball of Mud)
    5. Build a Demo
  2. Distributed Systems Programming with Javascript @ 10.4% of the vote.
    1. Patterns for Distributed Programming
    2. …and I’m figuring the other sections out still for this one…  got ideas? It needs to encompass the client side as well as the non-client code side of things. So it’s sort of like the above course, but I’m focusing more on the periphery of what one deals with when dealing with developing on and around distributed systems as well as distributed systems themselves.
  3. Vagrant OS-X, Windows and Linux – how to build, manage and ship machines to use for development and recreation of production environments.
    1. Vagrant, What is it?
    2. OS-X, Linux and Windows
    3. Using Vagrant Machines
    4. Building Vagrant Dev Machines
    5. Vagrant the Universe!

Now I might flip this list, but either way they’re all going to be super cool. So stay tuned and I’ll be working up these into courses. So far here’s the sub-bullets above are the basics of the curriculum I intend to put forward. Am I missing anything? Would you like to see anything specifically? Leave a comment and I’ll be sure to get everything as packed in there as possible!!