Fix “Permission denied @ rb_file_s_symlink” error of installing homebrew

Today I tried to install homebrew on my macOS Mojave, and came across following errors:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
......
Already up-to-date.
Error: Failed to link all completions, docs and manpages:
  Permission denied @ rb_file_s_symlink - (../../../Homebrew/completions/zsh/_brew, /usr/local/share/zsh/site-functions/_brew)
Failed during: /usr/local/bin/brew update --force

After refering stackoverflow, I fixed it through following command:

$ sudo chown -R $(whoami) $(brew --prefix)/*

Illumos makes me nostalgic

During 20102014, I worked as a software engineer in a telecommunication company which uses Solaris&SPARC as its server, and the working experience is a really pleasant memory for me. So even I have already left the company for more than 5 years, when I meet illumos, it always lets me reminisce about some good old days.

Before I joined in that company, I had only used some Linux distributions, e.g, Fedora 4. Honestly, I didn’t know what is the difference between Linux and Solaris at that time. I still remember the first Solaris tool I learned is pstack, which my colleague showed me how to analyze application’s core dump in a brief way. Although Solaris ships its own debugger, i.e., mdb, it was a shame I was still used to use gdb (installed from Sunfreeware). Since only gdb 6.x was provided, I always tried to build cutting-edge gdb from source code, and it worked smoothly on Solaris.

When talking about our commercial server, IIRC, it had only 2GiB memory. Yes, in the second decade of 21st century, when notebook already has 8GiB memory, our 32-bit application run on 2GiB machine.  Both sever and application could date back to 2005. Our company didn’t have a big name, and throughput of our application was ~30 transactions per second. The server was surprisingly stable. I can’t remember we ever restarted it once during 20102014, and it matched what this picture has said (a Solaris server run for more than 10 years).

Last week, I came across this tweet, so I wanted to relive Solaris once again (even though it is called illumos now). Download and install OmniOS, quite straightforward. Build illumos code, meet some problems, but fix them with the help of enthusiastic people. Find a typo in manual, go through the whole flow of contributing: create issue, send patch to review, send RTI, done! The flow is stricter than “fire-and-forget” mode, but I think it is necessary for code quality. BTW,  I find some Solaris‘s peculiar still exist on illumos. E.g., even in 64-bit environment, gcc will generate 32-bit executable by default, and you should use “-m64” compile option to claim you want 64-bit one.

Thanks for your time and patience to read this ramble rants. If there is only one take-away, that is besides Linux and BSD families, there is another less-popular Unix: illumos. Though it is a small community, it doesn’t have outdated tools. You can give it a shot if you are interested, and maybe you will like it.

Build gdb on illumos

Claim: Since illumos provides its own debugger: mdb, I don’t want to convince anybody to use gdb instead of mdb. Compile and use gdb is just my personal hobby.

I use OmniOS, and I think this material should also apply to other illumos OSs and even Solaris:

(1) Download and extract gdb source code (currently the newest versin is 8.3);
(2) Enter the gdb directory and do configuration:

# cd gdb-8.3
# mkdir build
# ../configure CC='gcc -m64'  CXX='g++ -m64'

(3) Build it:

# gmake

After compiling, testing it:

# ./gdb-8.3/build/gdb/gdb --data-directory=./gdb-8.3/build/gdb/data-directory/ -q a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x4011b6: file test.c, line 4.
Starting program: /root/a.out
[Thread debugging using libthread_db enabled]
[New Thread 1 (LWP 1)]
[Switching to Thread 1 (LWP 1)]

Thread 2 hit Temporary breakpoint 1, main () at test.c:4
4               printf("%d\n", sizeof(long unsigned int));
(gdb) n
8
5               return 0;
(gdb)
6       }
(gdb)

So far so good!

Build illumos source code on OmniOS

To build illumos source code on OmniOS, you need to update system and install related tools (Assume you run as root) first:

# pkg update
# pkg install pkg:/developer/illumos-tools

Then clone illumos source code and compile ():

# git clone https://github.com/illumos/illumos-gate.git
# cd illumos-gate
# time ksh93 usr/src/tools/scripts/nightly /opt/onbld/env/omnios-illumos-gate

That’s it!

References:
Building illumos;
Build error of illumos-gate on OmniOS.

Install OmniOS on VirtualBox

Following document to install OmniOS is quite straightforward. I use r151030 version and pick Solaris 11 during selecting Operating Systems on VirtualBox. To use root login through SSH, I need to do following changes:

(1) Set PermitRootLogin‘s value to yes in /etc/ssh/sshd_config file;

(2) Restart SSH service:

# svcadm restart ssh

A fresh OmniOS is born:

Update:

When installing r151032, I found selecing Oracle Solaris 10 10/09 and later (64-bit) can work.

Reference:
Solaris : How to enable ssh login for root user after a fresh install.