Git on Ubuntu in Visual Studio Code

I found myself getting frustrated with Visual Studio Code (vsc) today on Ubuntu with GitHub. I had a repository that was properly cloned, yet vsc insisted that “The folder currently open doesn’t have a git repository”.

vsc init repo message

I installed the GitHub extension and confirmed my account was set in vsc and still no joy. Finally went to the terminal in vsc and ran git status and received the following:

fatal: detected dubious ownership in repository at '/media/sf_vm_share/notpublicrepo/vsc-projects/mytrailhead'
To add an exception for this directory, call:

        git config --global --add safe.directory /media/sf_vm_share/notpublicrepo/vsc-projects/mytrailhead

and then there was

VSC Commit Option

Facebooktwitterredditlinkedinmail
© Scott S. Nelson

Tailing in Windows with a Right-Click

Being late to Linux in my career, I’m fascinated by things many probably already find mundane, like tailing logs. Someone finally suggested to me that I could use Cygwin to do this in Windows. He was my hero for the day!

Speaking of heroes, the members of Stackoverflow have a great way to open a Cygwin console in any directory with a right-click, described at http://stackoverflow.com/questions/9637601/open-cygwin-at-a-specific-folder. I used the registry trick because the command-line approach didn’t work for me.

Facebooktwitterredditlinkedinmail
© Scott S. Nelson

Tar That There Here

Authorization in Linux can be very fine-grained, a feature that admins take advantage of to keep the non-admins from making a mess of things. This is generally a good thing, though it can occasionally be frustrating. One such occasion is when newbies need to tar up a folder they have permissions on but do not have permissions to create files in that folder’s parent. For example, as a developer role on a machine I have ownership of myapp that is inside apps, which is owned by root. This would look something like:

[scott@mylinuxbox /]$ ls -l
drwxr-xr-x.   7 root   root    4096 Aug 11 16:13 apps
[scott@mylinuxbox /]$ cd apps
[scott@mylinuxbox apps]$ ls -l
drwxr-xr-x.  7 devs devs  4096 Jan  9 14:07 myapp

The tar command creates a tar file from where it is run. If I wanted to create myapp.tar.gz I would normally run tar czf myapp.tar.gz myapp from inside the /apps path. But with no create permissions in that folder, I just get a snarky response from Linux.

[scott@mylinuxbox apps]$ tar -czf myapp.tar.gz myapp
tar (child): myapp.tar.gz: Cannot open: Permission denied
tar (child): Error is not recoverable: exiting now

Skipping the details of head banging on desk and key banging on Google, I found the following approach that does the trick.

From a path you have write permissions to (almost always your home directory if no where else), run
tar -czf [TARFILENAME].tar.gz -C [PARENT_DIR]/ [DIR_TO_TAR]
For example:
tar czf folder.tar.gz -C /var/www/ folder

The ‘-C’ tells tar to start from the path following rather than where you are at. So the following steps:

[scott@mylinuxbox apps]$ cd ~
[scott@mylinuxbox ~]$ tar czf myapp.tar.gz -C /apps/ myapp
[scott@mylinuxbox ~]$ ls -l *.gz
-rw-rw-r--. 1 devs devs  675453427 Jan  9 14:33 myapp.tar.gz

creates myapp.tar.gz in my home directory.

Problem solved. Of course, I only made this tar file because there were problems with the app, so there is still the problem of debugging, but I think we can both do that already.

Cheers

Facebooktwitterredditlinkedinmail
© Scott S. Nelson