Featured post

About this blog

tuxThis blog was created with the idea of collecting and linking information about Linux, Git, how to set things up, how to tweak the system here and there, in different architectures, in different distributions and different releases.

All the information presented here is available to public knowledge and can be found with one, two, or a few more Google searches if you persist. All of them were used at least once on productive activities.

Please share your experience and share your comments.

Advertisements

npm/yarn: live-server installation issue

Executive summary:

ISSUE:

$ live-server
zsh: command not found: live-server SOLUTION: $ export PATH=$PATH:/home/user/.yarn/bin/

DETAILS:

Today my attempt to install the live-server package in a Linux Mint Sylvia (Ubuntu Xenial) box using yarn failed. The installation went just fine, with just some info messages:

$ yarn global add live-server
yarn global v1.3.2
[1/4] Resolving packages...
[2/4] Fetching packages...
warning Pattern ["object-assign@latest"] is trying to unpack in the same destination "/home/dbkreling/.cache/yarn/v1/npm-object-assign-4.1.1-2109adc7965887cfc05cbbd442cac8bfbb360863" as pattern ["object-assign@^4.1.0","object-assign@^4"]. This could result in a non deterministic behavior, skipping.
info fsevents@1.1.3: The platform "linux" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "live-server@1.2.0" with binaries:
- live-server
Done in 1.98s

Cool! And then..

$ live-server
zsh: command not found: live-server

 

Whatta?

Digging it further I found it (no pun intended) hidden in my home directory:

$ sudo find / -name "*live-server*"
[sudo] password for dbkreling:
find: ‘/run/user/1000/gvfs’: Permission denied
/home/dbkreling/.yarn/bin/live-server
/home/dbkreling/.config/yarn/global/node_modules/.bin/live-server
<...snip...>

Looking at my PATH, I had no .yarn directory whatsoever, so this is what I got:

export_yarn_to_path

After adding ~/.yarn/bin to my $PATH I had no more problems  to run it:

$ export PATH =$PATH:$HOME/.yarn/bin

Cheers!

Multiple refs on .git/config

Recently I was trying to push my latest patch to Gerrit when I suddenly started to see an error (“suddenly” as I did not relate any recent changes made that could cause the error. More on it next…)

[09:51:10] sdk@f25:~/tools-devel$ git push review
error: dst ref refs/for/master receives from more than one src.
error: failed to push some refs to 'ssh://dbkreling@host.ltc.br.ibm.com:29418/tools.git'
error: dst ref refs/for/master receives from more than one src.
error: failed to push some refs to 'ssh://dbkreling@host.ltc.br.ibm.com:29418/tools.git'

This error is caused by multiple refs tree within refs/remotes/origin. So go to your project’s .git/config file and search for a [remote "origin"] section there and do what you need to do to get just one ref only.

Make sure you read some more on git remote in previous posts:

Git remove remote branch from repo via CLI
Selecting remote repository on git

Cheers!

Reference
http://stackoverflow.com/questions/13373528/git-1-8-it-push-error-dst-ref-refs-heads-master-receives-from-more-than-one-sr

VIM buffer commands

Commands from vim buffers can take long to get into our brains. Practice will lead to perfection… eventually.

Here are some tips to get them into memory faster:

Editor commands:    
  :e filename - Edit a file an existing file in a new buffer
  :sp filename - Open a file in a new buffer and split window
  :vs or :vsp Open a file in a new buffer and split window vertically 
  ctrl+ws - Split window to work in two places of the same file
  ctrl+wv - Split window vertically (and work in the same file)

Navigation commands:
  :bnext (or :bn) - go to next buffer
  :bprev (of :bp) - go to previous buffer
  :bd - delete a buffer (close a file)
  ctrl+ww - switch between windows
  ctrl+wq - Quit a window
    

With pictures to decorate this post:

vim_example1_call

Open up a new file called ‘example1’

vs_example2

With ‘example1’ open, type in ‘:vs example2’ to vertically split the window and edit a new file ‘example2‘. It will open up a new buffer to the left of ‘example1’

sp_example3

From the ‘example2’ buffer, type in ‘:sp example3’ to horizontally split the screen and edit a new file ‘example3‘. It will open a new buffer above ‘example2’

example3_text

All three buffers displayed. Use CTRL-W+W to cycle through them.

Cheers!

Reference: http://www.worldtimzone.com/res/vi.html

Mount HFS+ as R/W without a MacOS

If you created a usb flash drive using MacOS, chances are you might have an HFS+ (journaled) file system device in your hands.

NOTE: If you do have a Mac sitting around, try this before.

In case you do not have access to a Mac, you may have to tweak a little to get your device working normally.

When you try to use your usb stick in Linux, you will have it mounted as a Read Only file system.

/dev/sdb3 on /media/dbkreling/dbkusb type hfsplus (ro,nosuid,nodev,uhelper=udisks2)

A filesystem check (fsck) did not work for me:

$ sudo fsck /dev/sdb3
fsck from util-linux 2.20.1
fsck: fsck.hfsplus: not found
fsck: error 2 while executing fsck.hfsplus for /dev/sdb3

Let’s install it then. The name of the package is hfsprogs:

$ sudo apt-get install hfsprogs

Preparing to unpack .../hfsprogs_332.25-11_amd64.deb ...
Unpacking hfsprogs (332.25-11) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up hfsprogs (332.25-11) ...

Now let’s try fsck again:

$ sudo fsck -f /dev/sdb3
fsck from util-linux 2.20.1
** /dev/sdb3
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking Catalog hierarchy.
** Checking Extended Attributes file.
** Checking volume bitmap.
** Checking volume information.
** The volume dbkusb appears to be OK.

Nice! Making progress… Then create a mounting point for it, other than the default one (without this step, I could not make it work, so make sure you do it):

$ mkdir /mnt/usb

Make sure the flash drive is unmounted and remount it at the new mount point, forcing r/w mode:

$ sudo umount /dev/sdb3
$ sudo mount -t hfsplus -o force,rw /dev/sdb3 /mnt/usb/
$ mount
....
/dev/sdb3 on /mnt/usb type hfsplus (rw,force)

Cheers!

References:

https://askubuntu.com/q/332315

https://superuser.com/a/84447

Git remove remote branch from repo via CLI

Quick shot: To remove a remote branch on your git repo:

git push [remote-name] --delete [branch-name]

Example

dkreling@dkreling:~/RobotFramework|devel ✔ ⟫ git branch -r
origin/devel
origin/master
origin/test

dkreling@dkreling:~/RobotFramework|devel ✔ ⟫ git push origin --delete teste [8:46:33]
remote: Updating references: 100% (1/1)
To ssh://dkreling@:/RobotFramework.git
 - [deleted] test

Cheers!

Setting up mLab addon on Heroku

If you live outside the US or Europe, chances are you cannot provision some addons to your Heroku application. If you try to create one using the heroku config comand, you end up getting:

$ heroku addons:create mongolab:sandbox
Creating mongolab:sandbox on ⬢ radiant-stream-99649… !
▸ Please verify your account to install this add-on plan (please enter a credit card) For more information, see https://devcenter.heroku.com/categories/billing Verify now at
https://heroku.com/verify

The default heroku command: $ heroku addons:create mongolab:sandbox does not work.

If you try to add it from the web interface, same thing:

Screen Shot 2017-11-14 at 7.51.10 AM11-14-17

Although mLab MongoDB is a free add on, it is not possible to provision it without providing a credit card number

Even so, it is still possible to add the mLabs addon to your application on Heroku. You can do it via your mLabs account:

1) Head over to https://mlab.com and create an account or log in;

2) In the Home screen, click “Create new”:

create_new_db

2.1) Select ‘Sandbox (Free)’:

sandbox-free

2.2) Pick a region;
2.3) Give your DB a name;
2.4) Submit your order (should be $0.00)

Your DataBase should be created. Then go ahead and..

3) Click on your just-created DB;

4) Create a user:

create_db_user

5) After it has been created, use the information mLab gave you to fill out the MONGODB_URI variable line displayed above, replacing <dbuser> and <dbpassword>.

mlabs_guest

6) Set it up as a Heroku environment variable from your terminal :

You should then configure the environment variable by hand with:

$ heroku config:set [MONGODB_URI-provided-by-mLab]

in my case:

$ keroku config:set mongodb://mlabs_guest:<dbpassword>@ds264255.mlab.com:59255/test-database-d

This image shows how I set mine up for another project:

heroku_config_mongodb_uri

That should be it: now your MONGODB_URI is set and configured, and you can now connect it to heroku.

Good luck with your project,

Cheers!