Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Wednesday, June 13, 2012

A Lesson in Shooting Yourself in the Foot

Sometimes I forget everything I know.Take a Fedora 14 configuration issue, for instance, on one of my old machines:

Last week Nautilus was suddenly unable to access special GVFS URIs like Computer: or Trash:. Kind of annoying, but not a killer bug. I forgot about it for a few days, until I plugged in a USB drive and found that it didn't automount. Okay, more annoying, I thought, and probably related to the same GVFS error. Time for some Googling on the error message.


The first page of results revealed the problem to be my own fault: I had compiled Anjuta from source, and it required updated versions of GIO and GVFS, among many other GTK+ libraries. Unthinking, I had installed Anjuta and the new libs in /usr/local. Everything ran fine, until I rebooted. I only do that once every few months on this machine, and the error seemed disconnected from my earlier actions by that time. Once I read the post, it made sense. I renamed /usr/local/lib, lib64, etc. and rebooted, and Nautilus was fixed.

So this hiccup sparked a conversation between myself and a colleague: Why was it so easy to screw my system up, and what could or should be done about it? This, of course, led to a more philosophical discussion on the nature of an open-source OS, general UNIX principles inherent in Linux, and the ability to have one's cake and eat it too.

The basic UNIX principle that I failed to acknowledge when installing a new GIO/GVFS was the multi-user system. Users can be either remote (network) or local (physically at the console), and the system loads libraries, determines paths, and does a lot of other setup depending on what kind of user you are. This is accomplished by a simple but ingenious mechanism: directory inheritance and overriding via the PATH environment variable.

This principle extends to the individual user, where files or directories starting with "." in a home directory (~) can override system or local defaults. It is one of the features that makes Linux so infinitely customizable, meshing perfectly with the open-source philosophy. But it bit me this time; judging by the search for my simple error, this same oversight has bitten other users for years and will likely continue to do so. With root/administrative privileges, it is very easy to render any OS unstable or unbootable. I've seen more than one instance of users accidentally deleting their Windows system directories. Everything works until they reboot...

In a nutshell, the lesson learned is that almost any user installation or customization can and should be performed without root privileges. I should have installed the new libraries, and possibly Anjuta, in my home directory by specifying the prefix and libdirs during the build. So should anything be done to protect me from shooting myself in the foot again? Probably not. When one is constantly installing new development libraries and dependencies to hack and build the latest shiny version of application foo, some of them will inevitably conflict with application bar. The safest way to install, of course, is to use only the distribution's package manager and repositories. However, I can envision SELinux providing an extra layer of security by protecting distribution files.

Friday, February 19, 2010

IDE-Experienced

Since I've been working on a lot of Drupal sites lately, my primary Integrated/Idiosyncratic Development Environment (IDE) has been Eclipse. The PHP editor, debugger and other tools (part of the PDT)  as well as Subversion, CVS and a bunch of other plugins make Eclipse a good choice for cross-platform development teams working on a wide range of project types. It's usually easy to set up and extend, but I did experience one problem on my Linux (FC12) laptop: Eclipse Update did not work at all, so the usual simple installing/updating of plugins by checking them off a list wasn't an option.

After some googling, I found that the problem was a bug (also here and many other places), which may or may not have been fixed on certain GNU/Linux distributions or with certain versions of Eclipse. The workaround mentioned here was the quickest fix, with one small improvement: I renamed the "eclipse" executable to "runeclipse" and named the shell script "eclipse", which calls the renamed executable. This way, all references to the original executable (think menus, .desktop files, Eclipse restarting itself) run the shell script with GDK_NATIVE_WINDOWS=true. So, Eclipse problems solved. Subversion integration worked without a hitch, and I was up and running.

The next project I'm working on is a C#/ASP.NET web application, with a heavy API of its own and plenty of library goodness to develop and integrate. The app will run on Windows/IIS, but I want to use my native desktop environment (GNOME/Linux) for .NET development. Plus, I'd really like to hack some GNOME apps, many of which run on Mono. Rather than attempting to make Eclipse run everything, I thought it was time to try out the obvious choice, MonoDevelop. Browsing the Fedora repositories (including RPM Fusion), I found the newest package available was 2.1. Since MonoDevelop doesn't maintain a Fedora package (hmm, I'm starting to see a pattern here) and I wanted 2.22, I embarked upon a good old-fashioned installation from source.

Things got interesting right away. Using the instructions from the README file in the source directory, I typed:

./configure --prefix=`pkg-config --variable=prefix mono`

First error:

checking for MONO_ADDINS... configure: error: Package requirements  (mono-addins >= 0.4) were not met:

No package 'mono-addins' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix.

Alternatively, you may set the environment variables MONO_ADDINS_CFLAGS and MONO_ADDINS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

I already knew mono-addins was installed; I had done this earlier because I (almost always) RTFM. However, I had done it the nice, graphical Fedora/GNOME way: using gpackagekit to search for "mono-addins", selecting it and clicking "Apply". I checked just in case:


Yes, I actually make it a point to manage my system using the GUI tools provided with GNOME. After several years of remote Linux and FreeBSD systems administration using only SSH terminal sessions, I thought it was time to see how much functionality I could get out of a free desktop like a normal Windows or Mac user. It's the ultimate test for me and the feature set; I only resort to terminals when the GUI malfunctions or is missing a feature. Kind of like fisticuffs with one hand tied behind your back. More on that later.

Okay, then: man pkg-config tells me that pkg-config is a utility used to return metadata about assemblies to callers such as the configure script above. Running pkg-config --libs mono-addins returned:

Package mono-addins was not found in the pkg-config search path.
Perhaps you should add the directory containing `mono-addins.pc' to the PKG_CONFIG_PATH environment variable
No package 'mono-addins' found 

A quick check of the search path, and sure enough there was no PKG_CONFIG_PATH environment variable set. Yet pkg-config --list-all showed a long list of registered packages. Searching for *.pc, the configuration files turned up in both /usr/lib/pkgconfig and /usr/share/pkgconfig, but no mono-addins.pc. I had installed mono-addins from a Fedora repository, and confirmed that the libraries were in their correct locations. Then I checked some of the other libraries, such as monodoc:


What a surprise - the monodoc-devel package literally is just the .pc file. In fact, many of the devel packages for mono are just pkg-config files. Why package a 207-byte file separately? Who knows. I installed the devel packages for mono-addins and all the other mono and *-sharp packages, and configuration succeeded.

After this, I ran make and make install, which gave plenty of warnings but finished without error. It even installed a menu item in my Applications -> Programming list, and MonoDevelop started up quickly on the first launch. Hopefully this experience will help someone else, and I'll post more as I continue to use MonoDevelop.

Wednesday, December 9, 2009

Google Chrome comes to Linux (and other browser comparisons)

Just in time to save my Fedora experience from buggy plugin support and bad font rendering, along comes Google Chrome in its first public beta for Linux. First impression: this browser is so impressive I will probably leave Firefox for it.

I've used Chrome on Windows since the first public betas, and while it has been fast, simple and powerful, I never saw a compelling reason to switch from Firefox, of which I have been a faithful user and proponent since early betas as well. Until I decided to eat my own dog food and switch to Linux (specifically Fedora 12).

A picture is worth 1000 words, so without further ado check out the differences in rendering (click images to see full size). I'll update this post at some point with a full review of Linux browser options.


Google Chrome rendering Blogger



Firefox 3.5 rendering Blogger

Of course, the standard developer tools are present and accounted for:



For the fun of it, I took screenshots of some other Linux browsers. They look a lot like Firefox even though two use different rendering engines. Epiphany (bottom) and perhaps WebKit in general seems to do a little better at subpixel hinting.


Galeon, a good Gecko-based (like Firefox) browser for gnome

Konqueror, a full-featured KDE browser using KHTML

Epiphany, a Webkit-based (like Safari and Chrome) browser

Monday, December 7, 2009

NVidia Drivers on Fedora 12

I'm not the only one who had problems installing the proprietary NVidia drivers on Fedora 12, so I thought I'd post the surprisingly simple solution here. The color profile options and OpenGL support are well worth it:


  1. To save a lot of headaches, install the standard VESA video driver first. On a fresh install, select the second option for installation ("Install with a basic video driver" or something like that). This will allow the NVidia driver setup to load its kernel module without interference from other loaded modules such as the "nv" or "nouveau" drivers. Most errors during installation are a result of other modules being loaded. You can edit grub.conf and blacklist the loaded driver as suggested here, but starting with the VESA driver is much easier.
  2. There has been some confusion surrounding the Supported Hardware lists for different driver versions on the NVidia site. These lists comprise the latest chipsets supported by the driver version; in almost all cases the unified drivers continue to support legacy GPUs. In my case, an NVidia Quadro NVS 135M in a Dell laptop, version 190.53 works fine. Download the latest driver for your platform.
  3. Switch to a console session (e.g., Ctrl+Alt+F2) and shut down X. "init 3" should suffice.
  4. Run the driver setup (sh ./NVIDIA-Linux-x86-190.42-pkg1.run). It should automatically compile the correct kernel module and configure your xorg.conf or equivalent.
  5. Reboot. You should see the NVidia logo when the screen mode switches.
  6. The driver also installs a .desktop launcher for the X Server Settings interface shown above. If you don't see it on your app menu or anywhere else, the utility is called nvidia-settings and can be launched from a terminal window.
  7. Enjoy.

Notes:
  • To automatically apply any changes made in nvidia-settings when you start X, place the following in your .xinitrc or other startup script:
    nvidia-settings --load-config-only
  • There appeared to be a bug in KDE causing a huge delay in menu response when the proprietary NVidia driver is used. My solution was to use GNOME.
  • Fedora kernel updates may cause the video driver (and therefore X) not to load; if this happens simply reinstall the driver and it should recompile the kernel module.
  • I have since tried 190.52 and 190.53 on this laptop and found that the Fedora updates were slightly behind the driver releases. If you try a new driver version and it causes performance problems such as the smallest apps showing a "Starting " window for several seconds, wait for another system update then try the driver again.

Other Resources:

http://www.linuxquestions.org/questions/fedora-35/fedora-12-nouveau-nvidia-driver-solution-771248/

http://linuxsoftwareblog.com/blog/?p=232