Sometimes, when you run rails server or rails s , it ends up with this error

A server is already running.

This is because you’ve left a server in suspended status. The shortest solution is to kill this process starting the server again. Run these commands to do this

To kill the process (suspended server)

sudo kill -9 $(lsof -i :3000 -t)

Then run the server with

rails s



To run a Rails project, had issues installing therubyracer and libv8
And came out to solve them with following commands

gem install therubyracer -v '0.12.3' -- --with-system-v8


gem install libv8 -v '' -- --with-system-v8

So — — with-system-v8 was the key.

And if you’re using Mac OS and face issue with v8 directory, follow these

brew install v8@3.15
bundle config build.libv8 --with-system-v8
bundle config build.therubyracer --with-v8-dir=$(brew --prefix v8@3.15)
bundle install



On macOS, tried to isntall ruby-filemagic and ended up with this error

ERROR:  Error installing ruby-filemagic:ERROR: Failed to build gem native extension.*** ERROR: missing required library to compile this module*** extconf.rb failed ***

It turned out that I didn’t have necessary libraries install on my mac.
Running this…



On my Mac, somehow i quitted gitk inappropriately. Onward to this, whenever I tried to open git gui via gitk , it came up with an error like

objc[1323]: autorelease pool page 0x7fb3a18fd000 corrupted

After googling it a lot, this solved the issue.

rm ~/.config/git/gitk



When you delete a git branch and want it back, simplest way is to fetch the branch again.

git fetch origin branchNmae

Wrongly, I just deleted my master branch. Being master parent of all branches, I wasn’t able to just fetch it. I was left with only one option. Clone the project again and set it up all :(

After making queries on google, I cam to know a workaround. The following command worked for me

git branch branchName <sha1> 

git branch -D tells you the sha1

Look at the following commands

user@MY-PC /C/MyRepo (master)
$ git branch -D master2
Deleted branch master2 (was 130d7ba). <-- This is the SHA1 we need to restore it!

user@MY-PC /C/MyRepo (master)
$ git branch master2 130d7ba




I want to undo some changes on git like this

$ git checkout HEAD foo/bar.txt
error: path 'foo/bar.txt' is unmerged
$ git reset HEAD foo/bar.txt
Unstaged changes after reset:
M foo/bar.txt

And ended up with the error above.

These commands made my way.

$ git reset foo/bar.txt
$ git checkout foo/bar.txt