Archives

bundle install fails with strange message: invalid option -7 (Ruby on Rails)

This was driving me crazy but even after solving it, I fell fairly stupid.

I am running bundle install inside a new app – while studying RoR – and I am getting this error:

computer:timetracker user$ bundle install

Fetching gem metadata from https://rubygems.org/………
Fetching additional metadata from https://rubygems.org/..
Using rake 10.1.0
Using i18n 0.6.9
Using minitest 4.7.5
Using multi_json 1.8.2

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/Users/user/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
/Users/user/.rvm/rubies/ruby-2.1.2/bin/ruby: invalid option -7 (-h will show valid options) (RuntimeError)

extconf failed, exit code 1

Gem files will remain installed in /Users/user/workspace/safari-ruby-course/safari-ror-course-all-files/Chapter 7/timetracker/vendor/bundle/gems/atomic-1.1.14 for inspection.
Results logged to /Users/user/workspace/safari-ruby-course/safari-ror-course-all-files/Chapter 7/timetracker/vendor/bundle/extensions/x86_64-darwin-13/2.1.0-static/atomic-1.1.14/gem_make.out
An error occurred while installing atomic (1.1.14), and Bundler cannot continue.
Make sure that `gem install atomic -v ’1.1.14′` succeeds before bundling.

The problem is – and I bet everybody but me knew – is the space in the name of one of the directory (“Chapter 7″).

The only consolation – if any – is that I would have never created a directory with a space – it’s part of the tutorial I am studying.

 

Recover from lost root password on xubuntu

The following was executed on xubuntu running in a VirtualBox VM inside a MacOS X Maverick.

user@xubuntu64:~$ uname -a
Linux xubuntu64 3.11.0-19-generic #33-Ubuntu SMP Tue Mar 11 18:48:34 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

You need to have access to the grub menu.

1) boot your VM
2) at the grub menu, press “e” on the ubuntu entry
3) go to the line starting with linux and add at the end “rw init=/bin/bash” (if you have “ro” at the end, remove it – don’t leave both ro and rw)
4) press cntrl-x to boot the VM
5) you will end up at the bash shell (no password asked)
6) verify that the root filesystem is mounted in rw mode (touch /etc/aa; rm /etc/aa)
7) execute “passwd root” and provide the new password
8) execute a “sync” (quite certainly useless but it won’t harm)
9) send your VM a cntrl-alt-del via VM menu (here reboot, init, halt and shutdown commands will not work and if you type “exit” the kernel will panic)

Screen Shot 2014-06-02 at 12.00.05

Screen Shot 2014-06-02 at 12.00.13

Screen Shot 2014-06-02 at 12.00.29

Screen Shot 2014-06-02 at 12.01.39

 

Screen Shot 2014-06-02 at 12.02.45

Screen Shot 2014-06-02 at 12.04.33

Executing “service docker status” I get “docker dead but subsys locked”

I did a

killall docker

I should have used the service command instead.
After the killall, if I check the status of the service I get an unusual message:


[root@steve run]# service docker status
docker dead but subsys locked

A lock file has been left behind:


[root@steve run]# cd /var/lock/subsys/
[root@steve subsys]# ls -l
total 0
[...]
-rw-r--r--. 1 root root 0 May 30 20:03 docker
[...]
[root@steve subsys]# fuser docker
[root@steve subsys]# rm docker
rm: remove regular empty file `docker'? y
[root@steve subsys]# service docker status
docker is stopped

In /var/run there was also a docker.sock file which I also removed.

This workaround applies to any service either killed by hand or crashed which had a lock file in /var/lock/subsys.

A shell question about metacharacter expansion I should have answered correctly (but I didn’t)

Got asked this question and miserably failed.

“I am at a shell prompt and I type “cp a*. What happens?”

What happens depends on what files and directories exists in your current directory.

One scenario is the following.

[root@steve tmp]# ls -l

total 4

-rw-r–r–. 1 root root    0 May 30 22:00 a-file01

-rw-r–r–. 1 root root    0 May 30 22:02 a-file02

-rw-r–r–. 1 root root    0 May 30 22:02 a-file03

-rw-r–r–. 1 root root    0 May 30 22:02 a-file04

drwxr-xr-x. 2 root root 4096 May 30 22:03 a-file05

 

Note that despite the name, a-file05 is a directory.

Now execute:  “cp a*”

The shell has not complained and it has done something.

If you ls the a-file05 directory, you will see that the 4 files have been copied there:


[root@steve tmp]# ls a-file05

a-file01  a-file02  a-file03  a-file04

This works because a-file05 – the directory – is the last in the ordered list, so when the “*” is expanded it’s the last one and the copy can work.

If you had instead:


[root@steve tmp]# ls -l
total 4
-rw-r--r--. 1 root root 0 May 30 22:00 a-file01
drwxr-xr-x. 2 root root 4096 May 30 22:07 a-file02
-rw-r--r--. 1 root root 0 May 30 22:02 a-file03
-rw-r--r--. 1 root root 0 May 30 22:02 a-file04

this would not work:


[root@steve tmp]# cp a*
cp: target `a-file04' is not a directory

 

MySql: calculate the size of all DBs in your instance

SELECT table_schema "DB NAME",
 Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB SIZE (MB)"
 FROM information_schema.tables
 GROUP BY table_schema;